How can apply wrap for express Router
nvcken opened this issue · comments
Hi I tried this, but does't work, could you pls help
// routers/user.js
var express = require('express');
var router = express.Router();
router.get('/users', async func1, async func2);
module.exports = router;
// server.js
let expressaa = require('./lib/wrapAsyncAwait')
let express = require('express')
let app = expressaa(express())
app.use('/', require('./routers/user'));
ah, I figured it works when wrap expressaa(express.Router())
in routers/user.js
is it correct way?
Hi @nvcken that works! On the other end, I recently found another library that does the same with a nicer hack -- I'd recommend you to check it out!