Skip to content

Conversation

@skryukov
Copy link

This PR introduces a layer of serialization and frontend type safety by integrating the Alba and Typelizer gems. It replaces manual serialization and hand-written TypeScript types with auto-generated serializers and types, streamlining the way data is shared between Rails controllers and Inertia.js React components. The changes improve maintainability, consistency, and developer experience across the stack.

  • Controllers now use Alba-based resource serializers (e.g., SharedPropsResource, TopicsIndexResource) instead of manual .as_json calls and explicit prop hashes, simplifying data preparation for Inertia responses.
  • Manual TypeScript interfaces in app/frontend/types.ts are removed and replaced with auto-generated types in app/frontend/types/serializers/, ensuring the frontend matches backend data structures exactly.
  • All React components and pages are updated to use the new auto-generated types.
  • All keys are transformed to lowerCamelCase via transform_keys :lower_camel

Added gems:

  • Alba — JSON serializer for Ruby
  • Typelizer — A TypeScript type generator for Ruby serializers
  • Alba::Inertia - Support for all Inertia prop types, lazy evaluation for all props by default (no lambdas required), auto-detection of serialization classes based on controller/action naming
  • Listen - Watches for serialization classes changes to update typescript types on-the-fly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants