1.0.15 • Published 6 years ago
kresdl-index v1.0.15
kresdl-index
Creates directory serving middleware for use with Express.
Install
npm install kresdl-index
Usage examples
Serve HTML formatted index
index
accepts a root path and returns a middleware that serves directory
listing by appending request.path to the root path.
const { index } = require('kresdl-index');
const app = require('express')();
app.use('/', index('path/to/static/files'));
Get file list from directory path
dir
accepts a path and returns a promise
which resolves to an array of filenames.
const { dir } = require('kresdl-index');
const files = await dir('directory/to/be/listed'));
...
License
MIT © Peter Hallström