Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(body => {
try {
return JSON.parse(body)
} catch (err) {
createError(400, "Invalid JSON", err)
}
})
)
gunzip(body, (err, buf) => {
if (err) {
reject(createError(400, "Invalid gzip", err))
return
}
resolve(buf.toString())
})
})
module.exports = async (req, res) => {
try {
await webpackMiddleware(appMiddleware)(req, res);
} catch (err) {
throw createError(500, stripAnsi(err.message), err);
}
};
const notFound = async (req) => {
const err = new Error(`\`${ req.url }\` not found`)
throw createError(404, 'Not found', err)
}
createError: ({ message, statusCode = 400 }) => {
const err = createError(statusCode, message);
err.handled = true;
return err;
},
};