-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
37 lines (29 loc) · 940 Bytes
/
index.js
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
const assert = require('assert')
const path = require('path')
const middleware = {
koa (route, options) {
const Koa = require('koa')
const serve = require('koa-static')
const rjqApiKoa = require('rjq-api-koa')
const mount = require('koa-mount')
const rjqMount = rjqApiKoa(options)
const app = new Koa()
app.use(rjqMount)
app.use(serve(path.join(__dirname, '/build')))
return mount(route, app)
},
express (route, options) {
const express = require('express')
const rjqApiExpress = require('rjq-api-express')
const rjqMount = rjqApiExpress(options)
const app = express()
app.use(route, rjqMount)
app.use(route, express.static(path.join(__dirname, '/build')))
return app
}
}
module.exports = function (type, options) {
const route = '/rjq-ui'
assert(type, `missing the middelware type: ${Object.keys(middleware)}`)
return middleware[type](route, options)
}