we use express 4, and 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 want to do something more:
router.get('/local_modules/*', function (req, res, next) {
var moduleDir = req.url.match(/local_modules\/(.*?)\
fs.readdir(moduleDir, function(err, files) {
files.forEach(function(f) {
res.sendFile(path.join(moduleDir, f));
})
}
}
But that does not work. How can I serve multiple files using an expression? Note: not only all the files in the directory (for example, in the example) that can probably be executed with app.use; express.static, but a specific set of files (for example, I may need to get a list of files from bower.json)
Agzam source
share