spacedeck-open/middlewares/artifact_helpers.js
2017-04-07 01:29:05 +02:00

22 lines
429 B
JavaScript

'use strict';
require('../models/schema');
var config = require('config');
module.exports = (req, res, next) => {
var artifactId = req.params.artifact_id;
Artifact.findOne({
"_id": artifactId
}, (err, artifact) => {
if (err) {
res.status(400).json(err);
} else {
if (artifact) {
req['artifact'] = artifact;
next();
} else {
res.sendStatus(404);
}
}
});
};