menems / koa-66 Goto Github PK
View Code? Open in Web Editor NEWRouter middleware for koa 2
License: MIT License
Router middleware for koa 2
License: MIT License
I used this in my project a lot and I would like to move to koa-66.
Here is my code
app.use((ctx, next) => {
console.info('1')
next().then(result => {
console.log('3')
console.log(result) // expect hello
})
})
app.use(apiRouter.routes())
const router = new Router()
const apiRouter = new Router()
router.get('/apps', (ctx) => {
console.log('2')
return Promise.resolve('hello')
})
apiRouter.mount('/api', router)
module.exports = apiRouter
but terminal shows
1
2
3
undefined
very important feature
Hi, it would be great if koa-66 support route.all(...)
like koa-router. Currently I hack around my code by defining a route for every method in response to all
, but that's terribly inefficient.
If routes like this are used
router.get('/appointments/validate', appointments.validate)
router.get('/appointments/:id', appointments.fetch)
the appointments.validate
middleware gets an 'id' param with the value 'validate'.
Instead of setting methods in the contructor put them in the prototype where all the other methods are.
If you use 2 routes using the same plugin such as :
.delete('/:id', { acl: ['HELPDESK'] }, (ctx) => {}
and
.put('/user/validate', { acl: ['DIRECTION'] }, (ctx) => {}
Your second route will take { acl: ['HELPDESK'] } instead of { acl: ['DIRECTION'] } as plugin.
I'm pubilshing a v1.0.0 version , now that koa has 2.0.0 tag on github/npm
There is no change since the last version, and i think this project is enought stable to have a v1.
So don't panic if you see a v1 version this is a same version than v0.8.5. it 's just a semantic update and some devdependencies update
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.