Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
router-decorators
Advanced tools
ES7 decorators that simplify Koa route creation
npm install router-decorators --save
app.js
const Koa = require('koa');
const Router = require('router-decorators').router;
const app = new Koa();
const router = new Router({
app,
apiDirPath: `${__dirname}/controllers` // controllers
});
app.use(router.routes());
app.use(router.allowedMethods());
...
app.listen(8080);
/controllers/user.js
const Koa = require('koa');
const {
Controller,
Get,
Post,
Middleware,
Required
} = require('router-decorators');
@Controller('/user')
class UserController {
static async middlewareLog(ctx, next) {
console.log('This is middleware');
await next();
}
@Post('/login')
@Required({
body: {
userEmail: 'string',
password: 'string',
}
})
static async login(ctx) {
ctx.body = true;
}
@Get('/:userId')
@Required({ params: 'userId' })params
@Middleware(UserController.middlewareLog)
static async getUserInfo(ctx) {
ctx.body = { userName: 'kico' };
}
}
export default UserController;
同时也支持ts文件
FAQs
ES7 decorators that simplify Koa route creation
The npm package router-decorators receives a total of 0 weekly downloads. As such, router-decorators popularity was classified as not popular.
We found that router-decorators 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.