Comparing version 0.0.2 to 0.0.3
var express = require('express'); | ||
var slug = require('speakingurl'); | ||
var Store = require('./store'); | ||
module.exports = function (agenda) { | ||
var router = express.Router(); | ||
var store = new Store(agenda); | ||
function definitions () { | ||
return Object.keys(agenda._definitions).map(function (d) { | ||
var id = slug(d); | ||
return { | ||
_id: id | ||
, name: d | ||
}; | ||
}); | ||
} | ||
function buildQuery (queryParams) { | ||
var query = {}; | ||
var filter = queryParams.filter; | ||
var name = queryParams.name; | ||
if (!filter || 'future' === filter) { | ||
query.nextRunAt = { $gte: new Date() }; | ||
} else if ('completed' === filter) { | ||
query.lastFinishedAt = { $exists: true }; | ||
query.type = 'normal'; | ||
} else if ('failed' === filter) { | ||
query.failedAt = { $exists: true }; | ||
} | ||
if (name) { | ||
query.name = name; | ||
} | ||
return query; | ||
} | ||
router.get('/jobs', function (req, res) { | ||
var query = buildQuery(req.query); | ||
agenda.jobs(query, function(err, jobs) { | ||
res.json({ | ||
jobs: jobs | ||
, definitions: definitions() | ||
}); | ||
}); | ||
store.data(req.query).then(res.json.bind(res)); | ||
}); | ||
router.get('/definitions', function (req, res) { | ||
res.json({ | ||
definitions: definitions() | ||
store.definitions().then(function (definitions) { | ||
res.json({ definitions: definitions }); | ||
}); | ||
@@ -53,0 +16,0 @@ }); |
{ | ||
"name": "agenda-ui", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "UI for Agenda", | ||
@@ -40,4 +40,5 @@ "main": "index.js", | ||
"express": "^4.3.2", | ||
"rsvp": "^3.0.9", | ||
"speakingurl": "^0.9.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
540739
11
4
1981
2
+ Addedrsvp@^3.0.9
+ Addedrsvp@3.6.2(transitive)