This is a very lightweight manifestation library that is designed to make it easier to create Express.js APIs. Simply create a manifestation object, create an API server using the manifestation object and then enjoy your new manifested API server.
import { manifestation, ApiManifest } from "@duxcore/manifestation";
const teapot = manifestation.newRoute({
route: "/teapot",
method: "all",
executor: (req, res) => {
const response = manifestation.newApiResponse({
status: 418,
message: "I'm not a teapot",
successful: true
});
manifestation.sendApiResponse(res, response);
}
})
/**
* Example Manifest
*
* This manifest has two routes with no middleware.
*
* /teapot
* /v1/teapot
*/
const manifest = manifestation.newManifest({
routes: [teapot],
versions: [
{
version: 1,
routes: [teapot],
routers: [
{
route: "/demoRouter",
routes: [teapot]
}
]
}
],
routers: [
{
route: "/demoRouter",
routes: [teapot]
}
]
})
manifestation.createServer(manifest, {}).listen(2020, () => { console.log("started") });