2.1.7 • Published 5 years ago

travelers v2.1.7

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

travelers

使用

  1. 安装
npm i travelers
  1. 使用

src/apis/api.ts

import * as joi from "joi";
import { travelersApis } from "travelers";
let items: travelersApis = [
    {
        path: "/everyDay",
        method: "get",
        summary: "获取游戏每日活动列表",
        description: "获取游戏每日活动列表",
        operationId: "everyDay_list",
        req: {
            query: {
                name: joi.string().required().regex(/^\w+$/)
            }
        },
        res: {
            body: joi.object({
                name: joi.string()
            })
        }
    }
];
export default items;

src/apis/index.ts

import api from "./api";

export { api };

src/controllers/controller.ts

import { Req, Res } from "travelers";
export async function operationId(req: Req, res: Res) {
    let { body, srvs } = req;
    const { knex, codes } = srvs;
    codes.ok.resJson(res);
}

src/controllers/index.ts

import * as controller from "./controller";
const controllers = {
    ...controller
};
export default controllers;

src/index.ts

import { travelers, TravelersOption, Req, Res, NextFunction, Config } from "travelers";
import * as apis from "./apis/index";
import * as srvs from "./srvs/index";
import controllers from "./controllers/index";
import config from "./config/index";
import * as security from "./security";
const option: TravelersOption = {
    config,
    before: function (app) {

    },
    srvs,
    security,
    apis,
    controllers,
    after: function (app, srvs) {
        app.use((req: Req, res: Res) => {
            const { codes } = req.srvs;
            return codes.notfind.resJson(res);
        });
    }
};
travelers(option).then(data => {
    // console.log(JSON.stringify(data, null, 4));
});
2.1.7

5 years ago

2.1.6

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.5

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago