@chengaoyuan/controller
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @chengaoyuan/controller

Weekly Downloads

5

Version

1.2.4

License

MIT

Unpacked Size

26.6 kB

Total Files

9

Last publish

Collaborators

  • chengaoyuan