Sinatra inspired web development framework for node.js -- insanely fast, flexible, and simple
Hey @euoia & @dougwilson, I see that activity is picking up again on GitHub 🎉
I'm a maintainer of Serverless Framework (https://github.com/serverless/serverless). We have more than 8,000 users/month deploying Express to AWS.
We want to build first-class integration between Express and AWS, and make it extremely easy for Express users.
We have some ideas we want to share with you, would you be interested to discuss it? Should we contact anyone else?
// Limit, 3 MegaBytes
// 1 << 10 = 1024 << 10 = 1024 * 1024
const limit = 3 << 20;
// Text Body Parser
server.use(function (req, res, next) {
let ln = req.get('content-length');
if (ln && ln > limit) {
res.sendStatus(413);
return;
}
req.body = '';
let overLimit = false;
req.on('data', chunk => {
if (overLimit) return;
req.body += chunk;
if (req.body.length > limit) {
overLimit = true;
res.sendStatus(413);
return;
}
});
req.on('end', () => {
if (!overLimit) next();
});
});
app.use(express.static(__dirname + '/public'));
Now I stardted to develop on Ubuntu and only public/js folder not served by the server. Other folders is ok for example images, css etc... What can be the proble and why is it works on other systems? I am developing and debugging the project using VS Code.
Hey everyone,
I would like to access the req route path(the regex) inside a middleware handler
app.use((req, res, next) => {
console.log(req.route?.path);
next();
})
But since req.route
is undefined inside middleware handlers, I was looking for a workaround.
The only one I found involved accessing the internal app router that is private, which is a bad idea of course:
function getRoutePath(path) {
var stack = app._router.stack;
for (var i = 0; i < stack.length; i++) {
if (stack[i].route && stack[i].match(path)) {
return stack[i].route.path;
}
}
}
So what do you suggest?
Hi everyone,
I'm currently pulling my hair out trying to resolve an install problem and I don't appear to find any help with these error codes online.
I have tried uninstalling and reinstalling node and npm several times but still get the same error.
I'm using Windows 11 Pro.
PS C:\_offline\NodeJs_Tutorial\tutpoint> npm install express
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code EBUSY
npm ERR! syscall rename
npm ERR! path C:\Users\educa\AppData\Local\npm-cache\_cacache\tmp\a48e6415
npm ERR! dest C:\Users\educa\AppData\Local\npm-cache\_cacache\content-v2\sha512\0f\98\3eb786fdcfde4d0e7d392c801d220122a66d5d7f5fe56b081f53e11555eb0b3d518a42e2184ac577fd7499afde46354392ab219538eb08966873d42bb6c9
npm ERR! errno EBUSY
npm ERR! Invalid response body while trying to fetch https://registry.npmjs.org/body-parser: EBUSY: resource busy or locked, rename 'C:\Users\educa\AppData\Local\npm-cache\_cacache\tmp\a48e6415' -> 'C:\Users\educa\AppData\Local\npm-cache\_cacache\content-v2\sha512\0f\98\3eb786fdcfde4d0e7d392c801d220122a66d5d7f5fe56b081f53e11555eb0b3d518a42e2184ac577fd7499afde46354392ab219538eb08966873d42bb6c9'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\educa\AppData\Local\npm-cache\_logs\2022-06-07T04_00_20_150Z-debug-0.log
Also followed all the instructions to clear the cache, etc. but with no luck.
Does anyone have any ideas? Thanks.
path = ('^' + path + (strict ? '' : path[path.length - 1] === '/' ? '?' : '/?'))
^
TypeError: Cannot read property 'length' of undefined
see my controller; const getCampaignById = async() =>{
//console.log('get by id')
const id = parseInt(req.params.id)
const results = await pool.query(queries.getCampaignById, [id]);
console.log(results)
return results.rows
}