
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@chenxxx/egg-swagger-decorator
Advanced tools
using decorator to make router definitions and automatically generate swagger doc for egg.js
using decorator to auto generate swagger json docs
yarn add @grfe/egg-swagger-decorator --registry=http://r.npm.guorou.net/
using decorator to auto generate swagger json docs
based on Swagger OpenAPI Specification 2.0
// using commonds below to start and test the example server
git clone http://git.shensz.local/FE/egg-swagger-decorator
cd egg-swagger-decorator
npm install
npm run dev
finally open:
http://localhost:7001/swagger-html
// router.js
import { Application } from 'egg';
import { wrapper } from '../lib';
export default (app: Application) => {
wrapper(app, {
// // [optional] default is /swagger-html
// swaggerHtmlEndpoint: '/sw',
// // [optional] default is /swagger-json
// swaggerJsonEndpoint: '/sj',
// // [optional] default is false. if true, will call makeSwaggerRouter(app) automatically
// makeswaggerRouter: false,
title: 'foo',
version: 'v1.0.0',
description: 'bar',
// autoMount 是否开启
// defaultRequestMounte: true
});
makeSwaggerRouter(app);
};
// controller/test.ts
import { Controller, Context } from "egg";
import {
request,
summary,
path,
tags,
responses,
middlewares,
description,
} from "@grfe/egg-swagger-decorator";
import { PathParamsVO, IGetUserResultVO, IUserListVO } from "../dto";
const testTag = tags(["test"])
export default class Test extends Controller {
@request("get", "/users")
@description("get user list")
@testTag
@middlewares(async (ctx: Context, next) => {
ctx.logger.info("mid");
await next();
})
@responses(IUserListVO)
public async getUsers() {
const { ctx } = this;
const users = [{ name: "cjfff" }];
ctx.body = { users };
}
@request("get", "/users/{id}")
@summary("get user info by id")
@testTag
@path(PathParamsVO)
@responses(IGetUserResultVO)
public async getUser() {
const { id } = this.ctx.params;
this.ctx.body = { id };
}
}
dto define
// ../dto.ts
export class PathParamsVO {
@ApiProperty({
type: "number",
description: "用户id",
example: 10086,
})
@IsNumber({ maxDecimalPlaces: 1000 }, { message: "id 必须是数字2323232" })
id: number;
}
export class IUserVO {
@ApiProperty({
type: 'string'
})
name: string;
}
export class IUserListVO {
@ApiProperty({
type: IUserVO,
isArray: true
})
users: IUserVO[]
}
export class IGetUserResultVO {
@ApiProperty({
type: 'number'
})
id: number;
}
request // @request('POST', '/users')
tags // @tags(['example'])
query // @query({limit: {type: 'number', required: true, default: 10, description: 'desc'}})
path // @path({limit: {type: 'number', required: true, default: 10, description: 'desc'}})
body // @body({groups: {type: 'array', required: true, items: { type: 'string', example: 'group1' }}})
formData // @formData({file: {type: 'file', required: true, description: 'file content'}})
middlewares
// support koa middlewares.
// eg. @middlewares([func1,func2])
summary // @summary('api summary')
description // @description('api description')
responses
// @responses({ 200: { description: 'success'}, 400: { description: 'error'}})
// responses is optional
© MIT
FAQs
using decorator to make router definitions and automatically generate swagger doc for egg.js
The npm package @chenxxx/egg-swagger-decorator receives a total of 1 weekly downloads. As such, @chenxxx/egg-swagger-decorator popularity was classified as not popular.
We found that @chenxxx/egg-swagger-decorator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.