controller
Installation
$ npm install @chengaoyuan/controller
Usage
import * as express from "express";
import { Controller, RequestMapping, RequestPath, Request, Response } from "@chengaoyuan/controller";
const app = express();
app.use(Controller);
app.listen(1234, "0.0.0.0");
@Controller("/api")
class A {
@RequestMapping({ path: "/test", method: "POST" })
@RequestMapping({ path: "/test", method: "GET" })
@RequestMapping({ path: "/test", method: "DELETE" })
@RequestMapping({ path: "/test", method: "PUT" })
async test(a: string, b: string) {
return "OK";
}
@RequestMapping("/default_get/:path")
async default_get(@RequestPath path: string, @Request req: any, @Response res: any) {
return "OK";
}
}
Testing
$ npm test