diff --git a/api/controllers/IndexController.ts b/api/controllers/IndexController.ts new file mode 100644 index 0000000..5542cb6 --- /dev/null +++ b/api/controllers/IndexController.ts @@ -0,0 +1,26 @@ +declare var Job, Asset, Task; + + +module.exports = { + 'index': (req, res) => { + let JobsCount, AssetsCount, TasksCount; + Job.count() + .then((val) => { + JobsCount = val; + return Asset.count(); + }) + .then((val) => { + AssetsCount = val; + return Task.count(); + }) + .then((val) => { + TasksCount = val; + res.json({ + serverStatus: 'online', + JobsCount, + AssetsCount, + TasksCount + }) + }) + } +} \ No newline at end of file diff --git a/config/routes.js b/config/routes.js index 490b927..dad0c2e 100644 --- a/config/routes.js +++ b/config/routes.js @@ -22,6 +22,11 @@ module.exports.routes = { + 'GET /': { + controller: 'IndexController', + action: 'index' + }, + // job 'GET /jobs': { controller: 'JobController',