Skip to content

Repository files navigation

Camille

Gem Version

Camille lets you define type schemas for your Rails API in Ruby, then generates typed TypeScript request functions from them and typechecks every response at runtime. The front-end and back-end can no longer disagree about the shape of data.

An endpoint defined in Ruby, where data is a controller action,

get :data do
  params(
    id: Number
  )
  response(
    name: String
  )
end

becomes a function in TypeScript:

data(params: {id: number}): Promise<{name: string}>

Routes are derived from the schema, so the front-end calls a function instead of remembering HTTP verbs and paths, and Camille makes sure the correct Rails action handles it.

Installation

Add this line to your application's Gemfile:

gem 'camille'

And then execute:

bundle install
bundle exec rails g camille:install

Documentation

Full documentation is at https://onyxblade.github.io/camille/, covering:

The docs source lives in docs/; run npm install && npm run dev there to preview locally.

Versioning

This project uses Semantic Versioning. See CHANGELOG.md.

Development

Run tests with bundle exec rake.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/onyxblade/camille.

About

Type-safe data exchange between front-end and Rails

Topics

Resources

Stars

23 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages