Skip to content

Instantly share code, notes, and snippets.

@darashi
Created May 23, 2026 05:24
Show Gist options
  • Select an option

  • Save darashi/bd75be4fca18b4ed90c3685a30b247ea to your computer and use it in GitHub Desktop.

Select an option

Save darashi/bd75be4fca18b4ed90c3685a30b247ea to your computer and use it in GitHub Desktop.
Kyomu Nostr Relay
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "falcon", "~> 0.55.3"
gem "async-websocket", "~> 0.30.0"
end
require "json"
require "async/websocket/adapters/rack"
require "falcon/rackup/handler"
app = lambda do |env|
Async::WebSocket::Adapters::Rack.open(env, protocols: ["ws"]) do |connection|
while message = connection.read
payload = JSON.parse(message)
case payload[0]
when "EVENT"
connection.write JSON.dump(["OK", payload[1], true, ""])
when "REQ"
connection.write JSON.dump(["EOSE", payload[1]])
end
connection.flush
end
end or [200, {}, ["Please use a Nostr client to connect."]]
end
puts "Falcon listening on http://localhost:9292"
begin
Falcon::Rackup::Handler.run(app, Host: "localhost", Port: 9292)
rescue Interrupt
end

Comments are disabled for this gist.