Created
July 12, 2017 09:59
-
-
Save ZiiSolutions/59ec0af5b2a7e6dcaa44240dc79b3d3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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