mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +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 = {
|
var custom_routes = {
|
||||||
'routes': [],
|
'routes': [],
|
||||||
'api_methods': []
|
'api': []
|
||||||
};
|
};
|
||||||
|
|
||||||
plugins.ready(function() {
|
plugins.ready(function() {
|
||||||
@@ -767,6 +767,20 @@ var path = require('path'),
|
|||||||
}(route));
|
}(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