Open
Description
Either I'm missing something in the documentation (very likely), or middleware does not trigger for root paths. I've tried both GET and POST.
Example code
const lambdaApi = require('lambda-api');
const api = lambdaApi({
base: 'user',
logger: true
});
api.use((req, res, next) => {
console.log('MIDDLEWARE START');
req.myVar = 'YES, HELLO';
next();
});
//static path
api.get('/hello', async (req, res) => {
console.log('/hello', req.myVar);
res.json({hello: req.myVar});
});
//root path
api.get('/', async (req, res) => {
console.log('root', req.myVar);
res.json({hello: req.myVar});
});
exports.handler = async (event, context) => {
console.log('event:', JSON.stringify(event, undefined, 4));
console.log('context:', JSON.stringify(context, undefined, 4));
return await api.run(event, context);
};
And logs
API Gateway has ANY method for base path /user
Any pointers on what I'm doing wrong?
Metadata
Metadata
Assignees
Labels
No labels