@bayerjs/core
Core server abstract library. Start the server with Bayer.listen
or get a callback function with Bayer.callback
.
Usage
Initialize a server object
HTTP Server
import Bayer from "@bayerjs/core";
const app = new Bayer();
app.listen();
Add middleware
import { tap } from "rxjs/operators";
app.use(tap(({ req, res, extra }) => {
res.status(200, "OK").send("Hello world!");
}));
To pass data to middlewares further down, write into the extra
object:
import { map } from "rxjs/operators";
server.use(tap(({ req, extra }) => {
Object.keys(req.headers).filter(v => v.startsWith("x-")).forEach(v => {
extra[v] = req.headers[v];
});
}), 1);