@jable/express-webapi
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

express-webapi

Controllers and route decorators for express

Example

@Controller('api/test')
class TController {

    // GET /api/test
    @Route(HttpMethod.GET, '/')
    index(req: express.Request, res: express.Response) {
        res.send('Hello World');
    }

    // GET /api/test/v2
    @Route(HttpMethod.GET, '/v2')
    index2(req: express.Request, res: express.Response) {
        res.send('Hello World, v2');
    }
}

@Controller()
class TController2 {

    // GET /test
    @Route(HttpMethod.GET, 'test')
    index(req: express.Request, res: express.Response) {
        res.send(req.query);
    }
}

let app = express();
app.listen(3000, () => {
    console.log("listening...");

    // Register the app. Controllers and routes will not work without this!
    WebApi.start(app);
});

Package Sidebar

Install

npm i @jable/express-webapi

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • jable