Skip to content

This is a lightweight manifested API manager that wraps around the Express.js library.

License

Notifications You must be signed in to change notification settings

duxcore/manifestation

Repository files navigation

Duxcore API Manifestation

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.

Example Code

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") });

About

This is a lightweight manifested API manager that wraps around the Express.js library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published