Skip to content

Instantly share code, notes, and snippets.

@ZiiSolutions
Created July 12, 2017 09:59
Show Gist options
  • Save ZiiSolutions/59ec0af5b2a7e6dcaa44240dc79b3d3c to your computer and use it in GitHub Desktop.
Save ZiiSolutions/59ec0af5b2a7e6dcaa44240dc79b3d3c to your computer and use it in GitHub Desktop.
'use strict';
const optional = require('optional');
const ingestService = require('../services/ingest/image-metadata-ingest-service');
const HTTP_ACCEPTED = 202;
const HTTP_BAD_REQUEST = 400;
/**
* Notify Controller
*
* @param router
*/
module.exports = function (router) {
// TODO(somebody): add `validate({ body: schema })` as second parameter to post when supported
router.post('/', (req, res) => {
ingestService.post(req.body.entity.uri)
.then((response) => {
res.sendStatus(HTTP_ACCEPTED);
req.log.info(response, 'Notification processing completed successfully');
})
.catch((err) => {
res.sendStatus(HTTP_BAD_REQUEST);
req.log.error(err, 'Notification processing failed');
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment