summaryrefslogtreecommitdiff
path: root/examples/lib/okpush/index.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-10-06 17:08:38 -0400
committerJules Laplace <jules@okfoc.us>2016-10-06 17:08:38 -0400
commitd2299d24a23c9d0d835631b72e4f1d1974958f94 (patch)
tree2133ec4d5701767d9fd8d51051eaea768e07629f /examples/lib/okpush/index.js
parentc8c0b465d9796b526d268ea0e641fd7ba00e44bb (diff)
js component
Diffstat (limited to 'examples/lib/okpush/index.js')
-rw-r--r--examples/lib/okpush/index.js29
1 files changed, 17 insertions, 12 deletions
diff --git a/examples/lib/okpush/index.js b/examples/lib/okpush/index.js
index 3ff8bb5..04cf33a 100644
--- a/examples/lib/okpush/index.js
+++ b/examples/lib/okpush/index.js
@@ -4,6 +4,7 @@
var path = require('path')
var passport = require('passport')
var DigestStrategy = require('passport-http').DigestStrategy;
+var bodyParser = require('body-parser')
var OKTemplate = require('../../../app/node_modules/oktemplate')
var apn = require('./apn')
var db = require('./db')
@@ -47,7 +48,8 @@ function OKPush (options) {
db.init(config)
router.use('/admin/', passport.initialize())
-
+ router.use('/public/', express.static(path.join(__dirname, './public')));
+
// monkeypatch because of this app.use(router) shit.. obnoxious
router.all('/admin/(:path*)?', function (req, res, next) {
// req.url = "/_services/push" + req.url
@@ -66,22 +68,25 @@ function OKPush (options) {
// pass in admin middleware!
router.get('/admin', function (req, res) {
db.getNotifications(function(err, notes){
- var data = {
- meta: meta,
- notifications: config.notifications,
- }
- notes.forEach(function(note){
- if (note.key in data.notifications) {
- data.notifications[ note.key ].last_push = note.last_push
+ db.getDeviceCount(function(err, count){
+ var data = {
+ meta: meta,
+ notifications: config.notifications,
+ device_count: count,
}
+ notes.forEach(function(note){
+ if (note.key in data.notifications) {
+ data.notifications[ note.key ].last_push = note.last_push
+ }
+ })
+ templates['index'].render(data).then(function(rendered) {
+ res.send(rendered);
+ }).fail(error(req, res, 500))
})
- templates['index'].render(data).then(function(rendered) {
- res.send(rendered);
- }).fail(error(req, res, 500))
})
})
- router.post('/admin/send', function (req, res) {
+ router.post('/send', bodyParser.urlencoded({ extended: false }), function (req, res) {
var key = req.body.key
var opt = options.config.notifications[key]
var note = apn.buildPayload(opt, options.config.bundleId)