diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-09-21 15:49:50 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-09-21 15:49:50 +0200 |
| commit | e14276957d196223b873419d5e80dd5c8ead945c (patch) | |
| tree | 49bdc21590c60485b7c3ba7f3dff2e4575e3085f /lib/okpush/index.js | |
| parent | e6c2b28c9824cae592c59c4838d12ae98fb27f9e (diff) | |
endpoint
Diffstat (limited to 'lib/okpush/index.js')
| -rw-r--r-- | lib/okpush/index.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/okpush/index.js b/lib/okpush/index.js index 36588aa2..391f64f9 100644 --- a/lib/okpush/index.js +++ b/lib/okpush/index.js @@ -46,6 +46,7 @@ function OKPush (options) { var templates = {} templates['index'] = templateProvider.getTemplate('index') + templates['new'] = templateProvider.getTemplate('new') apn.init(config) db.init(config) @@ -92,8 +93,14 @@ function OKPush (options) { }) }) + router.get('/new', function (req, res) { + templates['new'].render(data).then(function(rendered) { + res.send(rendered); + }).fail(error(req, res, 500)) + }) + router.get('/list', function(req, res){ - db.getAllTokens("hub", function(err, hubz){ + db.getAllTokens('hub', function(err, hubz){ res.json(hubz) }) }) @@ -108,6 +115,20 @@ function OKPush (options) { }) }) + router.post('/custom', bodyParser.urlencoded({ extended: false }), function (req, res) { + var message = req.body.message + var url = req.body.url + var opt = { + alert: message, + payload: { 'url': url }, + } + var note = apn.buildPayload(opt, options.config.bundleId) + apn.push('hub', note) + db.addNotification(channel, function(){ + res.sendStatus(200) + }) + }) + // should work without middleware router.post('/add', bodyParser.urlencoded({ extended: false }), function (req, res) { db.addToken({ |
