
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@jasonsoft/koa-controller
Advanced tools
Controller extension by @koa/router or koa-router middleware
Controller extension by @koa/router or koa-router middleware 🦞
npm i --save @jasonsoft/koa-controller
/**
* Example: https://github.com/jasonsoft-net/jasonsoft-koa-server
* FilePath: /jasonsoft-koa-server/app.js
* * 初始化相关服务和注入相关中间件
* Added by Jason.Song (成长的小猪) on 2021/01/31
* ? CSDN: https://blog.csdn.net/jasonsong2008
* ? GitHub: https://github.com/jasonsoft-net
*/
import Koa from 'koa';
import Router from '@koa/router';
/**
* Import the ControllerProvider from @jasonsoft/koa-controller
*/
import { ControllerProvider } from '@jasonsoft/koa-controller';
/** Instantiate the Koa object */
const app = new Koa();
/** router middleware */
const router = new Router();
/** Inject the controller directory */
ControllerProvider.initControllers({
router,
/** The default directory is './src/controllers' */
dir: './app/controllers',
/** Whether to enable the body parser, the default setting is false, not enabled */
bodyParser: true,
});
app.use(router.routes()).use(router.allowedMethods());
/** Service port */
const port = Number(process.env.PORT || 3000);
/** Listening port */
app.listen(port, () => {
console.log(
`[\x1B[36mRunning\x1B[0m] Application is running on: http://localhost:${port}`,
);
});
/**
* Example: https://github.com/jasonsoft-net/jasonsoft-koa-server
* FilePath: /jasonsoft-koa-server/app/controllers/user/users.controller.js
* Import Controller, Get, Post, Put, Delete, Patch, Options, Head, All, etc. decorators
*/
import {
Controller,
Get,
Post,
// Post,
// Put,
// Delete,
// Patch,
// Options,
// Head,
// All,
} from '@jasonsoft/koa-controller';
@Controller('users')
export default class UsersController {
constructor() {
this.users = [
{
id: 1,
username: 'jason',
},
{
id: 2,
username: 'steve',
},
];
}
/**
* GET http://localhost:3000/users
*/
@Get()
async getUsers() {
return this.users;
}
/**
* GET http://localhost:3000/users/1
*/
@Get(':id')
async getUserById(ctx) {
const { id } = ctx.params;
return this.users.find((user) => user.id === +id);
}
/**
* POST http://localhost:3000/users
*/
@Post()
async createUser(ctx) {
return { success: true, data: ctx.request.body };
}
}

FAQs
Controller extension by @koa/router or koa-router middleware
We found that @jasonsoft/koa-controller 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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.