Project

camille

0.0
The project is in a healthy, maintained state
Typed API schema for Rails with TypeScript codegen
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 6.1, < 8.1
 Project Readme

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.