@duxcore/manifestation
TypeScript icon, indicating that this package has built-in type declarations

1.3.5 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @duxcore/manifestation

Weekly Downloads

6

Version

1.3.5

License

GPL-3.0

Unpacked Size

48.2 kB

Total Files

9

Last publish

Collaborators

  • holopanio
  • amitojsingh366