1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1 1 1 1 1 1 2 2 48 36 36 24 12 | var join = require('path').join; var fs = require('fs'); var send = require('./send'); var normalize = require('./settings').normalize; module.exports = directory; function directory(path, options) { options = normalize(options); return function (req, res, next) { if (options.grep.test(req.path)) { fs.stat(join(path, req.path), function (err, stat) { if (err || !stat.isFile()) return next(); send(join(path, req.path), options, req, res, next); }); } else { return next(); } }; } |