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

29 lines
611 B
JavaScript
Raw Normal View History

const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
const db = require('server/models');
/*
route to return data for a claim
*/
const claimViews = async ({ ip, originalUrl, body, params }, res) => {
let claimId = params.claimId;
if (claimId === 'none') claimId = null;
try {
const viewCount = await db.Views.getGetUniqueViewsbByClaimId(claimId);
res.status(200).json({
success: true,
data : {
[claimId]: viewCount,
},
});
2018-11-11 01:11:12 +01:00
} catch (error) {
handleErrorResponse(originalUrl, ip, error, res);
}
};
module.exports = claimViews;