// handling post updates app.post("/post_update", function (req, res, next) { var timestamp = req.body.start; var lastSync = req.body.lastSync; sendCumulativeMessages(timestamp, lastSync, res); return next(); });
server.use((req, res, next) => { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Headers', 'X-Requested-With'); return next(); });
// start server server.listen(config.app.port, () => { console.log(`${config.app.name} Server is running on port - ${config.app.port}`); });
server.use(function packageParser (req, res, next) { if (typeof req.params.namespace !== 'undefined' && req.params.package !== 'undefined') { req.package = { namespace: req.params.namespace, name: req.params.package, id: `${req.params.namespace}/${req.params.package}` }; req.log.debug({package: req.package}, 'request package information'); } return next(); });
// Log errors server.on('uncaughtException', function(req, res, route, err) { // TODO // We should pipe our errors in graylog here console.log(req.body, res.body, route, err); return false; });
start() { server.listen(PORT, () => { logger.info(`Server started: http://localhost:${PORT}`); }); }
// Listen for incoming requests. server.post('/api/messages', (req, res) => { adapter.processActivity(req, res, async (context) => { // Route theincoming activity to the main bot turn handler. await bot.onTurn(context); }); });
// Attach our session object to every requests // Maybe we should change that later, bad performances? server.use(function(req, res, next) { req.session = _.extend(req.session, session); next(); });