cabbage-expressv2
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Cabbage-Express

Cabbage-Express is a library to quickly build controller based express applications.

Included Dependencies

Package Version
Express 4.17.3
Body-Parser 1.19.2
TypeDi 0.10.0
Reflect-Metadata 0.1.13

Example

$ npm install cabbage-express

import { CabbageApi } from 'cabbage-express'

const api = Container.get(CabbageApi)

api.configureMiddleware()
.mapControllers([
    [AuthController, new AuthController()]
])
.mapEndpoints()
.listen(process.env.PORT, () => console.log(`Listening on port ${process.env.PORT}`))
Controller
@ControllerRoute("/auth")
export default class AuthController {

    // Defines a GET request with no middleware
    @HttpGet("/login")
    async login(req: Request, res: Response) {
        ...
    }

    // Defines a POST request with the `isLoggedIn` middleware.
    @HttpPost("/change_password", isLoggedIn)
    async changePassword(req: Request, res: Response) {
        ...
    }
}
Generated endpoints

GET /auth/login POST /auth/change_password

Contributing

Anyone is welcomed to contribute to Cabbage-Express. Simply clone down the repository and submit a pull-request of your desired changes.

/cabbage-expressv2/

    Package Sidebar

    Install

    npm i cabbage-expressv2

    Weekly Downloads

    2

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    60.9 kB

    Total Files

    24

    Last publish

    Collaborators

    • tpapp