Add a Ruby backend
Add Ruby routes with the @primate/ruby
module. Write handlers in Ruby; Primate
compiles them to WebAssembly and wires them like JS routes.
Manage your Primate Ruby app as you would a normal Ruby project. Make sure you
install dependencies into
vendor
via
bundle config set --local path 'vendor/bundle'
, so dass Primate can pick them
up.$ npm install @primate/ruby && bundle install primate-run
TypeScriptconfig/app.ts
import ruby from "@primate/ruby";
import config from "primate/config";
export default config({ modules: [ruby()] });
Rubyroutes/index.rb
require 'primate/route'
Route.get do |request|
'Hello from Ruby'
end
Route.post do |request|
{ ok: true }
end