npm.io
1.2.4 • Published 7 years ago

@chengaoyuan/controller

Licence
MIT
Version
1.2.4
Deps
1
Size
26 kB
Vulns
0
Weekly
0

controller

npm version

install size

NPM Downloads

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

Keywords