Added route support

This commit is contained in:
Wyatt Johnson
2017-04-03 15:31:51 -06:00
parent 368838df98
commit febe264320
2 changed files with 14 additions and 1 deletions
+4 -1
View File
@@ -122,7 +122,10 @@ class PluginSection {
hook(hook) {
return this.plugins
.filter(({module}) => hook in module)
.map((plugin) => ({plugin, [hook]: module[hook]}));
.map((plugin) => ({
plugin,
[hook]: plugin.module[hook]
}));
}
}
+10
View File
@@ -1,5 +1,7 @@
const express = require('express');
const path = require('path');
const plugins = require('../services/plugins');
const debug = require('debug')('talk:routes');
const router = express.Router();
@@ -22,4 +24,12 @@ if (process.env.NODE_ENV !== 'production') {
});
}
// Inject server route plugins.
plugins.get('server', 'routes').forEach(({plugin, routes}) => {
debug(`added plugin '${plugin.name}'`);
// Pass the root router to the plugin to mount it's routes.
routes(router);
});
module.exports = router;