How to use the filer.fs.Shell function in filer

To help you get started, we’ve selected a few filer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github humphd / nohost / src / webserver.js View on Github external
'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') {