Open kivervinicius opened 8 years ago
Hello,
tks for solution
You are welcome.
i need use this section app.use(queue({ activeLimit: 1 })); conditionally, its possible?
Can you provide a bit more details?
I need only be limited to a route, for example /GetProducts other routes need to be unlimited if I leave app.use directly will limit all right?
Middleware may be assigned to single route, so you need just following:
app.use('/GetProducts', queue({ activeLimit: 1 }) );
Oh tks, i will test.
The queue'ing does not seem to work when implementing it like this:
chain.routes.js
import expressQueueMw from 'express-queue';
import chainCtrl from './chain.controller';
const router = Router(); // eslint-disable-line new-cap
router.route('/init').get(chainCtrl.init, expressQueueMw({ activeLimit: 1 }));
export default router;
index.routes.js
import { Router } from 'express';
import expressQueueMw from 'express-queue';
import chainRoutes from './endpoints/chain/chain.route';
const router = Router(); // eslint-disable-line new-cap
// mount chaincode routes at /chain
router.use('/api/chain', chainRoutes);
export default router;
index.js (express)
import routes from './server/routes/index.routes'
...config
app.use('/', routes);
...config
Also tried router.use('/api/chain', chainRoutes, expressQueueMw({ activeLimit: 1 }));
and queue({ activeLimit: 1 })
but the requests don't queue
1) you have misprint import chainRoutes from './endpoints/chain/chain.route';
while the file named chain.routes.js
2) router.route('/init').get(chainCtrl.init, expressQueueMw({ activeLimit: 1 }));
Here chainCtrl.init
must be middleware in order to pass request further to next middleware i.e. to expressQueueMw
, while I assume that according to its name, 'controller' will not use next()
function.
Maybe you need another order:
router.route('/init').get(expressQueueMw({ activeLimit: 1 }), chainCtrl.init);
?
It looks working if I rewrite this way and call next();
inside chainCtrl.init
:
I added you example to node_modules/express-queue/
Then run it with 'DEBUG=* node index.js'
Thank you very much, you saved my day
Hello, tks for solution, i need use this section
app.use(queue({ activeLimit: 1 }));
conditionally, its possible?