mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
plugins - filter:server.create_routes allows you to define API routes as well now
This commit is contained in:
@@ -745,7 +745,7 @@ var path = require('path'),
|
||||
|
||||
var custom_routes = {
|
||||
'routes': [],
|
||||
'api_methods': []
|
||||
'api': []
|
||||
};
|
||||
|
||||
plugins.ready(function() {
|
||||
@@ -767,6 +767,20 @@ var path = require('path'),
|
||||
}(route));
|
||||
}
|
||||
}
|
||||
|
||||
var apiRoutes = custom_routes.api;
|
||||
for (var route in apiRoutes) {
|
||||
if (apiRoutes.hasOwnProperty(route)) {
|
||||
(function(route) {
|
||||
app[apiRoutes[route].method || 'get']('/api' + apiRoutes[route].route, function(req, res) {
|
||||
apiRoutes[route].callback(req, res, function(data) {
|
||||
res.json(data);
|
||||
});
|
||||
});
|
||||
}(route));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user