2018-04-17 23:54:10 +02:00
|
|
|
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
|
|
|
|
const db = require('../../models');
|
2018-03-29 02:35:41 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
route to see if asset is available locally
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2018-03-29 20:24:52 +02:00
|
|
|
const fileAvailability = ({ ip, originalUrl, params }, res) => {
|
|
|
|
const name = params.name;
|
|
|
|
const claimId = params.claimId;
|
|
|
|
db.File
|
|
|
|
.findOne({
|
|
|
|
where: {
|
|
|
|
name,
|
|
|
|
claimId,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(result => {
|
|
|
|
if (result) {
|
|
|
|
return res.status(200).json({success: true, data: true});
|
|
|
|
}
|
|
|
|
res.status(200).json({success: true, data: false});
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
handleErrorResponse(originalUrl, ip, error, res);
|
|
|
|
});
|
2018-03-29 02:35:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = fileAvailability;
|