express-routes-setting
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

express-routes-setting

集中设置express路由。

安装依赖包

npm install --save express-routes-setting

使用方法:

  // 完整例子,查看 example 目录。 下面是 example 中 index.ts的示例代码:

  import * as express from "express";
  import { setExpressRouting } from "express-routes-setting";

  var app = express();

  async function index(req: express.Request, res: express.Response, next?: express.NextFunction) {
    console.log(req.method, " /");

    res.send("Hello World");
  }

  async function show(req: express.Request, res: express.Response) {
    console.log(req.method, " /show");

    res.send("ok");
  }

  setExpressRouting(app, [
    { path: "/", method: "get", func: index },
    { path: "/show", method: "get", func: show }
  ]);

  app.use("/home", require("./controller/home"));

  app.listen(3000);

Readme

Keywords

none

Package Sidebar

Install

npm i express-routes-setting

Weekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

16.3 kB

Total Files

18

Last publish

Collaborators

  • serveryang