@101-ways/core-express
Express server accelerator package. It uses the Service Registry pattern to create a single object with APIs.
Features
- starts server on port 8000 by default
- request / response logging with tracing metadata
- asynchronous context within request flow
Usage
import { load } from '@101-ways/core-express';
load([`${__dirname}/modules`]).then((sr) => {
sr.express.app.get('/hello', (req, res) => {
res.json({ result: 'hello world' });
});
});
Basic example for creating a child package:
import { load as loadCore, type Registry } from '@101-ways/express';
export type { Registry };
export async function load<T extends Registry>(paths: string[] = [], sr?: T) {
return loadCore([`${__dirname}/modules`, ...paths], sr);
}
Service Registry API
Everything in @101-ways/core and
Environment Variables
Everything in @101-ways/core and
- PORT='8000' - HTTP server port