snort/packages/nostr/relay/index.ts
sistemd 05605bdf28
nostr package: vastly simplify the API (#412)
* vastly simplify the api

* add missing await

* add eose to emitter

* add eose to conn

* add eose to the client

* eose test

* improve test suite, add dm tests

* demonstrate that nostr-rs-relay auth options don't work

* readme files

* cleanup

* fetch relay info

* test readyState

* export fetchRelayInfo

* cleanup

* better async/await linting

* use strictEqual in tests

* additional eslint rules

* allow arbitrary extensions

* saner error handling

* update README

* implement nip-02

---------

Co-authored-by: Kieran <kieran@harkin.me>
2023-03-27 10:09:48 +01:00

27 lines
825 B
TypeScript

/**
* Allows the relay to be shut down with an HTTP request, after which
* docker-compose will restart it. This allows each test to have a clean
* slate. The drawback is that the tests can't run in parallel, so the
* test suite is very slow. A better option would be to have this relay
* server manage the relay completely: star/stop isolated relay instances
* with HTTP requests and allow multiple instances to run at the same
* time so that the tests can be parallelized.
*/
import http from "node:http"
import { spawn } from "node:child_process"
const child = spawn(process.argv[2], process.argv.slice(3), {
stdio: "inherit",
})
const server = http.createServer((_, res) => {
if (!child.kill(9)) {
console.error("killing the subprocess failed")
}
res.end()
process.exit(1)
})
server.listen(8000)