cgutwin / modular-express

A modular approach to defining an express server.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

modular-express

A modular approach to defining express routes.

Install

yarn add cgutwin/modular-express

Or add from a branch:

yarn add cgutwin/modular-express#branch

Usage

import ExpressServer from "modular-express"
import bodyParser from "body-parser"
import { Request, Response } from "express"

const server: ExpressServer = new ExpressServer({
  port: 5000,
  middleware: [
    bodyParser.json()
  ],
  routes: [
    {
      head: "/",
      name: "rootPath",
      paths: [
        {
          path: "/ping",
          method: "GET",
          controller: (req: Request, res: Response) => res.send('pong')
        }
      ]
    }
  ]
})

server.listen()

License

MIT

About

A modular approach to defining an express server.

License:MIT License


Languages

Language:TypeScript 100.0%