mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 15:35:47 +01:00
issue #478 - hot-swapping of plugins
This commit is contained in:
25
src/routes/plugins.js
Normal file
25
src/routes/plugins.js
Normal file
@@ -0,0 +1,25 @@
|
||||
var nconf = require('nconf'),
|
||||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
Plugins = require('../plugins'),
|
||||
|
||||
PluginRoutes = function(app) {
|
||||
// Static Assets
|
||||
app.get('/plugins/:id/*', function(req, res) {
|
||||
var relPath = req.url.replace('/plugins/' + req.params.id, '');
|
||||
if (Plugins.staticDirs[req.params.id]) {
|
||||
var fullPath = path.join(Plugins.staticDirs[req.params.id], relPath);
|
||||
fs.exists(fullPath, function(exists) {
|
||||
if (exists) {
|
||||
res.sendfile(fullPath);
|
||||
} else {
|
||||
res.redirect('/404');
|
||||
}
|
||||
})
|
||||
} else {
|
||||
res.redirect('/404');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = PluginRoutes;
|
||||
Reference in New Issue
Block a user