Skip to content

Commit

Permalink
added index route with stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Alino committed Aug 30, 2018
1 parent 9155c34 commit 9c7607d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
26 changes: 26 additions & 0 deletions api/controllers/IndexController.ts
Original file line number Diff line number Diff line change
@@ -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
})
})
}
}
5 changes: 5 additions & 0 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@

module.exports.routes = {

'GET /': {
controller: 'IndexController',
action: 'index'
},

// job
'GET /jobs': {
controller: 'JobController',
Expand Down

0 comments on commit 9c7607d

Please sign in to comment.