/manifestation

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

Primary LanguageTypeScriptGNU General Public License v3.0GPL-3.0

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