mirror of
https://github.com/spacedeck/spacedeck-open.git
synced 2025-12-16 09:57:30 +01:00
initial commit.
This commit is contained in:
22
middlewares/artifact_helpers.js
Normal file
22
middlewares/artifact_helpers.js
Normal file
@@ -0,0 +1,22 @@
|
||||
'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);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user