Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const { fs, Path } = require('filer');
const { route, disableIndexes, directoryIndex } = require('./config');
const sh = new fs.Shell();
// https://tools.ietf.org/html/rfc2183
function formatContentDisposition(path, stats) {
const filename = Path.basename(path);
const modified = stats.mtime.toUTCString();
return `attachment; filename="${filename}"; modification-date="${modified}"; size=${stats.size};`;
}
const serve = function(path, formatter, download) {
return new Promise((resolve) => {
function buildResponse(responseData) {
return new Response(responseData.body, responseData.config);
}
function serveError(path, err) {
if(err.code === 'ENOENT') {