@yarkivaev/simple-server
v1.0.0
Published
Generic HTTP/SSE primitives for composable REST APIs
Readme
@yarkivaev/simple-server
Generic HTTP/SSE building blocks: route, routes, JSON/SSE responses, request timeouts, pagination, virtual clock.
Repository: https://github.com/yarkivaev/simple-server
Install
npm install @yarkivaev/simple-serverPublished to registry.npmjs.org on push to main (GitHub Actions release.yml via yarkivaev/npm-workflows).
Usage
import http from 'http';
import { route, routes, jsonResponse } from '@yarkivaev/simple-server';
const api = routes([
route('GET', '/health', async (req, res) => {
jsonResponse({ ok: true }).send(res);
})
]);
http.createServer((req, res) => api.handle(req, res)).listen(3000);