mirror of
https://github.com/wassname/talk.git
synced 2026-07-03 12:37:44 +08:00
Added route support
This commit is contained in:
+4
-1
@@ -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]
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user