Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// use Joi to validate file data format
const addSumSchema = Joi.object().keys({
a: Joi.number().required(),
b: Joi.number().required(),
operator: Joi.string().required(),
equals: Joi.number().required()
});
await Joi.validate(data, addSumSchema);
return h.response(data);
} catch (err) {
return Boom.badRequest(err.message);
}
} else {
return Boom.unsupportedMediaType();
}
} else {
return Boom.badRequest('File is required');
}
};
async method(request, h) {
const header = request.headers["content-type"];
if (header !== "application/json") {
return Boom.unsupportedMediaType();
}
return h.continue;
},
});