spacedeck-open/middlewares/artifact_helpers.js

21 lines
433 B
JavaScript
Raw Permalink Normal View History

2017-04-07 01:29:05 +02:00
'use strict';
const db = require('../models/db');
const Sequelize = require('sequelize');
const Op = Sequelize.Op;
2017-04-07 01:29:05 +02:00
var config = require('config');
module.exports = (req, res, next) => {
var artifactId = req.params.artifact_id;
db.Artifact.findOne({where: {
2017-04-07 01:29:05 +02:00
"_id": artifactId
}}).then(artifact => {
if (artifact) {
req['artifact'] = artifact;
next();
2017-04-07 01:29:05 +02:00
} else {
res.sendStatus(404);
2017-04-07 01:29:05 +02:00
}
});
};