spee.ch/server/controllers/api/claim/data/index.js

33 lines
827 B
JavaScript
Raw Normal View History

2018-04-27 09:54:36 -07:00
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
2018-09-25 20:20:59 -05:00
const getClaimData = require('server/utils/getClaimData');
const fetchClaimData = require('server/utils/fetchClaimData');
2018-12-14 11:42:37 -06:00
const chainquery = require('chainquery').default;
2018-10-24 03:43:30 -05:00
const db = require('server/models');
2018-03-28 17:35:41 -07:00
/*
route to return data for a claim
*/
const claimData = async ({ ip, originalUrl, body, params }, res) => {
try {
const resolvedClaim = await fetchClaimData(params);
if (!resolvedClaim) {
return res.status(404).json({
success: false,
message: 'No claim could be found',
});
}
res.status(200).json({
success: true,
data : await getClaimData(resolvedClaim),
2018-03-29 11:24:52 -07:00
});
2018-11-10 19:11:12 -05:00
} catch (error) {
handleErrorResponse(originalUrl, ip, error, res);
}
2018-03-28 17:35:41 -07:00
};
module.exports = claimData;