tofu-express
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

tofu-express

A library of decorators to define class based "controller" classes.

Controllers are specify a path and are used to generate an express Router.

InitializeExpress creates (and returns) an express app with our most commonly used middleware (morgan for logging, body-parser, and express-prom-bundle).

Default port is loaded from envvar SERVER_PORT and set to 3000 by default if no var is set. Controller classes passed in will be instantiated then transformed into routers. The router is then applied to the path specified in their decorator.

function InitializeExpress(port: number = PORT, name = 'ExpressJS', middlware = [], ...controllers: any)

Example:

@Controller('/api')
class TestController {
  constructor() {
  }
 
  @Get('/test')
  Test(req: Request) {
    return {'STATUS': 'OK'};
  }
}
 
InitializeExpress(3000, 'Test App', [], TestController);

/tofu-express/

    Package Sidebar

    Install

    npm i tofu-express

    Weekly Downloads

    14

    Version

    1.1.3

    License

    MIT

    Unpacked Size

    11.4 kB

    Total Files

    5

    Last publish

    Collaborators

    • andrewabbott