![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
koa-controller-router
Advanced tools
> Router middleware extended from [koa-router](https://github.com/alexmingoia/koa-router) for [koa 1.x](https://github.com/koajs/koa/tree/v1.x)
Router middleware extended from koa-router for koa 1.x
Install using npm:
npm install koa-controller-router
Create controller
// app/controllers/ArticleController.js
class ArticleController {
*list() {
// some code
}
*show() {
// some code
}
*create() {
// some code
}
*update() {
// some code
}
*destroy() {
// some code
}
}
module.exports = ArticleController;
Create routes
Without middleware:
// index.js
const path = require('path');
const Koa = require('koa');
const Router = require('koa-controller-router');
const app = new Koa();
const router = new Router({
controllersPath: path.resolve(__dirname, 'app', 'controllers') // default value is /path/to/project/controllers/
});
router.get('/', function *() {
// some code
});
router.get('/api/v1/articles', 'ArticleController@list');
router.get('/api/v1/articles/:id', 'ArticleController@show');
router.post('/api/v1/articles', 'ArticleController@create');
router.put('/api/v1/articles/:id', 'ArticleController@update');
router.patch('/api/v1/articles/:id', 'ArticleController@update');
router.del('/api/v1/articles', 'ArticleController@destroy');
app.use(router.routes());
app.use(router.allowedMethods());
app.listen(3000);
With middleware:
const authMiddleware = function *(next) {
// auth check
yield next;
};
const isAdminMiddleware = function *(next) {
// check user role
yield next;
};
router.post('/api/v1/articles', authMiddleware, 'ArticleController@create');
router.put('/api/v1/articles/:id', authMiddleware, 'ArticleController@update');
router.patch('/api/v1/articles/:id', authMiddleware, 'ArticleController@update');
router.del('/api/v1/articles', authMiddleware, isAdminMiddleware, 'ArticleController@destroy');
MIT
FAQs
> Router middleware extended from [koa-router](https://github.com/alexmingoia/koa-router) for [koa 1.x](https://github.com/koajs/koa/tree/v1.x)
The npm package koa-controller-router receives a total of 8 weekly downloads. As such, koa-controller-router popularity was classified as not popular.
We found that koa-controller-router 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.