Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

travelers

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

travelers - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

28

dist/index.d.ts
/// <reference types="koa-bodyparser" />
import * as Koa from "koa";
import { SwaggerDefalut, TravelApis } from './lib/api';
import { SwaggerDefalut, travelersApis } from './lib/api';
import { Code } from './lib/code';
import * as Router from "koa-router";
declare type TravelConfig<T> = {
declare type travelersConfig<T> = {
host?: String;

@@ -12,3 +12,3 @@ port: number;

apis: {
[key: string]: TravelApis;
[key: string]: travelersApis;
};

@@ -19,4 +19,4 @@ controllers: {

};
declare type TravelOption = {
config: TravelConfig<any>;
declare type travelersOption = {
config: travelersConfig<any>;
before?: (app: Koa<Koa.DefaultState, Koa.DefaultContext>) => void;

@@ -30,3 +30,3 @@ args: Args;

};
export declare function travel(option: TravelOption): Promise<void>;
export declare function travelers(option: travelersOption): Promise<void>;
declare type App = Koa<Koa.DefaultState, Koa.DefaultContext>;

@@ -36,3 +36,3 @@ declare type APPCtx = Koa.ParameterizedContext<Koa.DefaultState, Koa.DefaultContext>;

declare global {
namespace Travel {
namespace travelers {
interface Srvs {

@@ -45,10 +45,10 @@ [k: string]: any;

}
interface TravelCtx extends RouterCtx {
srvs: Travel.Srvs;
$config: Travel.$config;
interface travelersCtx extends RouterCtx {
srvs: travelers.Srvs;
$config: travelers.$config;
}
interface TravelApp extends App {
srvs: Travel.Srvs;
$config: Travel.$config;
interface travelersApp extends App {
srvs: travelers.Srvs;
$config: travelers.$config;
}
export { TravelApis, TravelOption, App, APPCtx, RouterCtx, TravelCtx, TravelApp, Code };
export { travelersApis, travelersOption, App, APPCtx, RouterCtx, travelersCtx, travelersApp, Code };

@@ -10,3 +10,3 @@ "use strict";

exports.Code = code_1.Code;
async function travel(option) {
async function travelers(option) {
const app = new Koa();

@@ -31,5 +31,6 @@ let { config, before, args, swaggerDefalut, after, srvs } = option;

app.listen(port, `${host}`);
console.log(chalk_1.default.bold.red(`\ntravel start host:${host} prot:${port}`));
console.log(chalk_1.default.bold.red(`travelers start host:${host} prot:${port}`));
}
exports.travel = travel;
exports.travelers = travelers;
let a;
//# sourceMappingURL=index.js.map
/// <reference types="koa-bodyparser" />
import * as Koa from "koa";
import * as joi from "joi";
import { TravelCtx } from "../index";
import { travelersCtx } from "../index";
declare type Info = {

@@ -41,3 +41,3 @@ title: string;

}
declare type TravelApis = ApiItem[];
declare type travelersApis = ApiItem[];
declare let swagger: {

@@ -60,8 +60,8 @@ paths: {};

declare type ManageApis = {
[key: string]: TravelApis;
[key: string]: travelersApis;
};
declare type ManageControllers = {
[key: string]: (ctx: TravelCtx) => Promise<any>;
[key: string]: (ctx: travelersCtx) => Promise<any>;
};
declare function apiManage(app: Koa<Koa.DefaultState, Koa.DefaultContext>, apis: ManageApis, controllers: ManageControllers, swaggerDefalut: SwaggerDefalut, config: any): Promise<void>;
export { SwaggerDefalut, apiManage, TravelApis, swagger, ManageApis, ManageControllers };
export { SwaggerDefalut, apiManage, travelersApis, swagger, ManageApis, ManageControllers };

@@ -131,3 +131,3 @@ "use strict";

app.use(serve({ rootDir: path_1.join(__dirname, '../../swagger'), gzip: true, rootPath: '/document' }));
console.log(chalk_1.default.bold.red(`\ndocument you can click: http://${host}:${port}/document`));
console.log(chalk_1.default.bold.red(`document you can click: http://${host}:${port}/document`));
router.get('/swagger', (ctx) => {

@@ -134,0 +134,0 @@ ctx.body = swagger;

{
"name": "travelers",
"version": "1.0.0",
"description": "i wanna write code like travel",
"version": "1.0.1",
"description": "I wanna write code like travelers",
"main": "dist/index.js",

@@ -15,3 +15,3 @@ "scripts": {

"type": "git",
"url": "git+https://github.com/CQzhangshuai/travel.git"
"url": "git+https://github.com/CQzhangshuai/travelers.git"
},

@@ -27,5 +27,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/CQzhangshuai/travel/issues"
"url": "https://github.com/CQzhangshuai/travelers/issues"
},
"homepage": "https://github.com/CQzhangshuai/travel#readme",
"homepage": "https://github.com/CQzhangshuai/travelers#readme",
"dependencies": {

@@ -32,0 +32,0 @@ "joi": "^14.3.1",

### travel
## travelers
#### 使用
### 使用
1. 安装
```
npm i travel
npm i travelers
```
2. 使用
import { travelers, travelersOption, travelersApis, travelersCtx } from 'travelers'
### src/apis/api.ts
```
const option: TravelOption = {
import { travelersApis } from 'travelers'
let items: travelersApis = [
{
path: '/everyDay',
method: 'get',
summary: '概要',
description: '描述',
operationId: 'controllerKey',
req: {
query: {
name: joi.string().required().regex(/^\w+$/)
},
body: joi.object({
name: joi.string()
})
},
res: {
body: joi.object({
name: joi.string()
})
}
}
]
```
### src/controllers/controller.ts
```
import { travelersCtx } from 'travelers'
export async function everyDay_list(ctx: travelersCtx) {
let { body, srvs } = ctx
const { knex } = srvs
ctx.body = {
code: 200
}
}
```
### src/index.js
```
import { travelersOption, travelers } from 'travelers'
import * as apis from './apis/index'
import * as srvs from './srvs/index'
import * as controllers from './controllers/index'
import config from './config/index'
const option: travelersOption = {
config,

@@ -25,3 +75,3 @@ before: function (app) {

}
travel(option)
travelers(option)
```

@@ -31,1 +81,2 @@

import * as Koa from "koa";
import { SwaggerDefalut, apiManage, TravelApis, swagger } from './lib/api'
import { SwaggerDefalut, apiManage, travelersApis, swagger } from './lib/api'
import * as bodyparser from 'koa-bodyparser';

@@ -11,3 +11,3 @@ import * as json from 'koa-json';

type TravelConfig<T> = {
type travelersConfig<T> = {
host?: String,

@@ -20,3 +20,3 @@ port: number,

apis: {
[key: string]: TravelApis
[key: string]: travelersApis
},

@@ -28,4 +28,4 @@ controllers: {

type TravelOption = {
config: TravelConfig<any>,
type travelersOption = {
config: travelersConfig<any>,
before?: (app: Koa<Koa.DefaultState, Koa.DefaultContext>) => void,

@@ -41,3 +41,3 @@ args: Args,

export async function travel(option: TravelOption) {
export async function travelers(option: travelersOption) {
const app = new Koa()

@@ -64,3 +64,3 @@ let { config, before, args, swaggerDefalut, after, srvs } = option

console.log(chalk.bold.red(`travel start host:${host} prot:${port}`))
console.log(chalk.bold.red(`travelers start host:${host} prot:${port}`))

@@ -77,3 +77,3 @@ }

declare global {
namespace Travel {
namespace travelers {
interface Srvs {

@@ -89,16 +89,16 @@ [k: string]: any;

interface TravelCtx extends RouterCtx {
srvs: Travel.Srvs
$config: Travel.$config
interface travelersCtx extends RouterCtx {
srvs: travelers.Srvs
$config: travelers.$config
}
interface TravelApp extends App {
srvs: Travel.Srvs
$config: Travel.$config
interface travelersApp extends App {
srvs: travelers.Srvs
$config: travelers.$config
}
let a: TravelCtx
let a: travelersCtx
export { TravelApis, TravelOption, App, APPCtx, RouterCtx, TravelCtx, TravelApp, Code }
export { travelersApis, travelersOption, App, APPCtx, RouterCtx, travelersCtx, travelersApp, Code }

@@ -8,3 +8,3 @@

import { join } from 'path';
import { TravelCtx } from "../index";
import { travelersCtx } from "../index";
import chalk from 'chalk';

@@ -72,3 +72,3 @@ import * as verify from "./verify";

type TravelApis = ApiItem[]
type travelersApis = ApiItem[]

@@ -81,7 +81,7 @@ let swagger = {

type ManageApis = {
[key: string]: TravelApis
[key: string]: travelersApis
}
type ManageControllers = {
[key: string]: (ctx: TravelCtx) => Promise<any>
[key: string]: (ctx: travelersCtx) => Promise<any>
}

@@ -100,3 +100,3 @@

Object.keys(apis).forEach(apiItem => {
const items: TravelApis = apis[apiItem]
const items: travelersApis = apis[apiItem]
items.forEach(item => {

@@ -208,2 +208,2 @@ const { path, method, summary = '默认', tags = [apiItem], description, operationId, req, res } = item

export { SwaggerDefalut, apiManage, TravelApis, swagger, ManageApis, ManageControllers }
export { SwaggerDefalut, apiManage, travelersApis, swagger, ManageApis, ManageControllers }
import { ManageApis, ManageControllers, TravelApis } from './api'
import { ManageApis, ManageControllers, travelersApis } from './api'

@@ -9,3 +9,3 @@ export function apiVerify(apis: ManageApis, controllers: ManageControllers) {

Object.keys(apis).forEach(apiItem => {
const items: TravelApis = apis[apiItem]
const items: travelersApis = apis[apiItem]
items.forEach(item => {

@@ -12,0 +12,0 @@ const { path, method, operationId } = item

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc