Socket
Socket
Sign inDemoInstall

travelers

Package Overview
Dependencies
91
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

travelers

I wanna write code like travelers


Version published
Maintainers
1
Weekly downloads
1

Weekly downloads

Readme

Source

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));
});

Keywords

FAQs

Last updated on 11 Dec 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc