2018-04-29 22:00:41 +02:00
|
|
|
const logger = require('winston');
|
|
|
|
|
|
|
|
const serveFile = ({ filePath, fileType }, res) => {
|
2018-07-08 00:03:21 +02:00
|
|
|
if (!fileType) {
|
|
|
|
logger.error(`no fileType provided for ${filePath}`);
|
|
|
|
}
|
2018-04-29 22:00:41 +02:00
|
|
|
const sendFileOptions = {
|
|
|
|
headers: {
|
|
|
|
'X-Content-Type-Options': 'nosniff',
|
2018-07-08 00:03:21 +02:00
|
|
|
'Content-Type' : fileType,
|
2018-04-29 22:00:41 +02:00
|
|
|
},
|
|
|
|
};
|
2018-07-08 00:03:21 +02:00
|
|
|
logger.debug(`fileOptions for ${filePath}:`, sendFileOptions);
|
2018-05-07 20:03:30 +02:00
|
|
|
res.status(200).sendFile(filePath, sendFileOptions);
|
2018-04-29 22:00:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = serveFile;
|