From 58a3f33200919fbc6c7705ceb57e534f74147713 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 16 Dec 2013 15:40:59 -0500 Subject: [PATCH] plugins - added api routes to filter:admin.create_routes --- src/routes/admin.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/routes/admin.js b/src/routes/admin.js index cd3994f144..47331ea8aa 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -244,7 +244,7 @@ var nconf = require('nconf'), var custom_routes = { 'routes': [], - 'api_methods': [] + 'api': [] }; plugins.ready(function() { @@ -264,6 +264,19 @@ var nconf = require('nconf'), }(route)); } } + + var apiRoutes = custom_routes.api; + for (var route in apiRoutes) { + if (apiRoutes.hasOwnProperty(route)) { + (function(route) { + app[apiRoutes[route].method || 'get']('/admin/api' + apiRoutes[route].route, function(req, res) { + apiRoutes[route].callback(req, res, function(data) { + res.json(data); + }); + }); + }(route)); + } + } }); });