extractSaz(file.buffer, res.json.bind(res)); } catch(e) { res.status(500).send(e.stack);
_init() { this.routeUtil = RouteUtil; this.authUtil = new AuthUtil(); this.routerFactory = new RouterFactory(this.config); this.express = express(); this.listen = this.express.listen.bind(this.express); this.middlewareManager = new MiddlewareManager(this.config, this.express); }
// Fix problem wth nodejs reporting can't set headers after they are set // http://stackoverflow.com/questions/7042340/node-js-error-cant-set-headers-after-they-are-sent app.use(function (req, res, next) { var _send = res.send; var sent = false; res.send = function (data) { if (sent) return; _send.bind(res)(data); sent = true; }; next(); });
router.post('/', function(req, res) { var model = new Model(req.body); console.log(model); model.save(res.json.bind(res)); });
router.put('/:id', function(req, res) { Model.find(req.params.id).then(function(model) { model.update(req.body, res.json.bind(res)); }); });
app.get('/', (request, response) => response.send.bind(response, 'Hello World'));
/* * Paging enabled, defaults to limit 100 * page with query params * limit => Int * offset => Int */ Router.get('/', (req, res) => { const queryParams = qsEncode({ $limit : req.query.limit || 100, $offset : req.query.offset || 0 }); const campaignContributionsEndpoint = 'https://data.hawaii.gov/resource/imub-jfpr.json'; const url = `${campaignContributionsEndpoint}?${queryParams}`; fetch(url) .then( fetchJson ) .then( res.json.bind(res) ) .catch( fetchError(res) ); });
router.delete('/:id', function(req, res) { Model.find(req.params.id).then(function(model) { model.delete(res.json.bind(res)); }); });
router.get('/', function(req, res) { Model.all().then(res.json.bind(res)); });
router.get('/:id', function(req, res) { Model.find(req.params.id).then(res.json.bind(res)); });
// Fix problem wth nodejs reporting can't set headers after they are set // http://stackoverflow.com/questions/7042340/node-js-error-cant-set-headers-after-they-are-sent app.use(function (req, res, next) { var _send = res.send; var sent = false; res.send = function (data) { if (sent) return; _send.bind(res)(data); sent = true; }; next(); });
// Fix problem wth nodejs reporting can't set headers after they are set // http://stackoverflow.com/questions/7042340/node-js-error-cant-set-headers-after-they-are-sent app.use(function (req, res, next) { var _send = res.send; var sent = false; res.send = function (data) { if (sent) return; _send.bind(res)(data); sent = true; }; next(); });