summaryrefslogtreecommitdiff
path: root/examples/lib/okpush/index.js
blob: 8b109184e4c2c85581fa03dc2051652f9541111f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
 */

var apn = require('apn');

function OKPush (options) {
  if (!(this instanceof OKPush)) return new OKPush(options)
  options = options || {}
  if (!options.express)
    throw new Error('Express not provided to OKPush');
  if (!options.config)
    throw new Error('Configuration not provided to OKPush');

  var express = options.express
  var router = express.Router()
  var config = options.config
  var db = options.db

  router.get('*', function (req, res) {
    res.send(config.stuff)
  })

  router.post('*', function (req, res) {
    throw new Error('OKPush POST requests not implemented')
  })

  this._router = router
}

OKExample.prototype.middleware = function () {
  return this._router
}

module.exports = OKExample