express() .use(raw({ type: '*/*' })) .use(apigw) .use((err, req, res, next) => { // Error handling. console.error('Integration error', err); res.status(500) .set('Content-Type', 'application/json') .send(JSON.stringify({ message: 'Internal server error' })); })
// https://stripe.com/docs/webhooks server.post('/payments/stripe', bodyParser.raw({ type: '*/*' }), async (req, res) => { return handleStripeWebhook(req, res, false) } )
/** * Parses the HTTP request into useful objects. * This middleware populates {@link Request#params}, {@link Request#headers}, {@link Request#cookies}, * {@link Request#signedCookies}, {@link Request#query}, {@link Request#body}, and {@link Request#files}. * * @param {requestParser.defaultOptions} [options] * @returns {function[]} */ function requestParser (options) { // Override default options options = _.merge({}, requestParser.defaultOptions, options); return [ cookieParser(options.cookie.secret, options.cookie), bodyParser.json(options.json), bodyParser.text(options.text), bodyParser.urlencoded(options.urlencoded), bodyParser.raw(options.raw), generateMultipartFormDataMiddleware(options.multipart), multerCompatability ]; }
app.post("/", bodyParser.raw({ type: "*/*", limit: "2mb" }), function(req, res, next) { const id = uuid(); const fileName = `/tmp/file_${id}.jpg`; writeFile(fileName, req.body) .then(() => { return svgify(fileName); }) .then(svg => res.type(".svg").send(svg)) .catch(e => { console.log(e); res.sendStatus(500); }) .then(() => { fs.unlinkSync(fileName); fs.unlinkSync(fileName + ".resized"); }); });
//body parser middleware are supported (optional) app.use(bodyParser.raw({ type: function() { return true; }, limit: '5mb' }));
app.use(bodyParser.json({ limit: REQUEST_SIZE_LIMIT })); app.use(bodyParser.text({ limit: REQUEST_SIZE_LIMIT })); app.use(bodyParser.raw({ limit: REQUEST_SIZE_LIMIT })); app.use(cookieParser()); app.use(compression());
commonDefines.buildNumber); }); const rawFileParser = bodyParser.raw( {inflate: true, limit: config.get('server.limits_tempfile_upload'), type: function() {return true;}});
const appAgentJson = express.Router() const appAgentMsg = express.Router() appAgentMsg.use(bodyParser.raw({ inflate: true, limit: `${maxRequestSizeKb}kb`,
router.post('/*', bodyParser.raw({type: function() { return true;}, limit: proxyPostSizeLimit}), buildReqHandler('POST'));
server.post('/payments/stripe/connected', bodyParser.raw({ type: '*/*' }), async (req, res) => { return handleStripeWebhook(req, res, true) } )
// https://stripe.com/docs/webhooks server.post('/payments/stripe', bodyParser.raw({ type: '*/*' }), async (req, res) => { return handleStripeWebhook(req, res, false) } )
server.post('/payments/stripe/connected', bodyParser.raw({ type: '*/*' }), async (req, res) => { return handleStripeWebhook(req, res, true) } )