artifact_helpers.js 433 B

1234567891011121314151617181920
  1. 'use strict';
  2. const db = require('../models/db');
  3. const Sequelize = require('sequelize');
  4. const Op = Sequelize.Op;
  5. var config = require('config');
  6. module.exports = (req, res, next) => {
  7. var artifactId = req.params.artifact_id;
  8. db.Artifact.findOne({where: {
  9. "_id": artifactId
  10. }}).then(artifact => {
  11. if (artifact) {
  12. req['artifact'] = artifact;
  13. next();
  14. } else {
  15. res.sendStatus(404);
  16. }
  17. });
  18. };