From e14276957d196223b873419d5e80dd5c8ead945c Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 21 Sep 2017 15:49:50 +0200 Subject: endpoint --- lib/okpush/index.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'lib/okpush/index.js') 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({ -- cgit v1.2.3-70-g09d2