we're using express 4 and right now I have something like this:
var express = require('express'),
router = express.Router();
router.get('/local_modules/*', function (req, res, next) {
var moduleName = req.url.match(/local_modules\/(.*?)\//).pop(1)
res.sendFile(filePath + '.js');
}
and I wanna do something more like:
router.get('/local_modules/*', function (req, res, next) {
var moduleDir = req.url.match(/local_modules\/(.*?)\//).pop(1)
fs.readdir(moduleDir, function(err, files) {
files.forEach(function(f) {
res.sendFile(path.join(moduleDir, f));
})
}
}
But that doesn't work. How can I serve multiple files with express? Note: not just all files in a directory (like in the example) - which probably can be done with app.use; express.static
, but specific set of files (e.g. I may need to get the list of files from bower.json)