-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
53 lines (43 loc) · 1.12 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// const { json } = require('micro')
// const post = require('micro-post')
//
// module.exports = post(async (req, res) => {
// const parsed = await json(req)
// switch (parsed.sys.contentType.sys.id) {
// case 'passports':
// updatePassports(parsed)
// break
// }
// })
require('now-env')
const updatePassports = require('./api/wo/passport')
const updatePages = require('./api/wo/pages')
const micro = require('micro')
const Router = require('micro-http-router')
const landing = require('./layouts/landing')
const router = new Router()
router.route({
path: '/',
method: 'GET',
handler: (req, res) => {
return landing
}
})
router.post('/api/wo', async (req, res) => {
const parsed = await micro.json(req)
// console.log(parsed.sys.contentType.sys.id)
switch (parsed.sys.contentType.sys.id) {
case 'singlePage':
updatePages(parsed)
break
}
// case 'passports':
// updatePassports(parsed)
// break
// }
return
})
const server = micro((req, res) => router.handle(req, res))
const port = 8080
server.listen(port)
console.log(`micro is listening on port: ${port}`)