blob: b614697143910f1ddb9badc5fb0abeaa199d80b0 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/**
* Example service to show how these things should be set up.
*
* Services should be added to index.js in the proper area,
* with any configuration parameters that you want passed in:
*
* services: {
* example: {
* lib: require("./lib/okexample"),
* stuff: "things",
* }
* },
*
* The service will be mounted on /_services/example
*
* This binds to route '*' but you can specify e.g. "/thing",
* and it will be mounted on /_services/example/thing
*/
function OKExample (options) {
if (!(this instanceof OKExample)) return new OKExample(options)
options = options || {}
if (!options.express)
throw new Error('Express not provided to OKDumpfm');
if (!options.config)
throw new Error('Configuration not provided to OKDumpfm');
var express = options.express
var router = express.Router()
var config = options.config
router.get('*', function (req, res) {
res.send(config.stuff)
})
router.post('*', function (req, res) {
throw new Error('OKExample POST requests not implemented')
})
this._router = router
}
OKExample.prototype.middleware = function () {
return this._router
}
module.exports = OKExample
|