You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
550 B

require "sinatra"
require "sinatra/json"
require "sequel"
NODES = {}
Sequel.connect(ENV["DATABASE_URL"] || "sqlite://meet4eat.db")
class Node < Sequel::Model
def to_json(options={})
{
id: name,
room: room
}.to_json
end
end
get '/nodes' do
json({ nodes: Node.all })
end
put '/nodes/:id' do
node = Node.where(name: params[:id]).first
node ||= Node.new(name: params[:id])
node.room = params[:room] || "default"
node.save
json("")
end
delete '/nodes/:id' do
Node.where(name: params[:id]).delete
json("")
end