@lukekaalim/http-server
v13.7.0
Published
Simple utility library for defining a node server listener from a series of routes
Downloads
6
Readme
@lukekaalim/server
Library for building simple servers.
Installation
npm i @lukekaalim/server
Usage
This server will return "Hello World" on port 8080 when requesting "/greetings", and 404 on all other responses.
const { text, route, router } = require('@lukekaalim/server');
const { createServer } = require('http');
const main = () => {
const myRoute = route(
'GET',
'/greetings',
() => text.plain(200, 'Hello World!')
);
const myRouter = router([myRoute]);
const myServer = createServer(myRouter);
myServer.listen(8080);
};
main();