add fan page notify, add twitch route, todo: twitch webhook reg

This commit is contained in:
Jay
2018-06-27 00:59:53 +08:00
parent f409e6ff61
commit 1f3057df69
15 changed files with 377 additions and 51 deletions
+22 -2
View File
@@ -1,4 +1,5 @@
const config = require('../../config')
const rawBody = require('raw-body')
const crypto = require('crypto')
const verifyLine = async (c, n) => {
@@ -10,6 +11,25 @@ const verifyLine = async (c, n) => {
return n()
}
module.exports = {
verifyLine
const getRaw = async (c, n) => {
let raw = await rawBody(c.req, {
length: c.request.length,
limit: '5mb',
encoding: c.request.charset
})
c.request.raw = raw
let txt = raw instanceof Buffer ? raw.toString() : raw
if (c.request.type === 'application/json') {
try {
c.request.body = JSON.parse(txt)
} catch (err) {
c.request.body = txt
}
}
return n()
}
module.exports = {
verifyLine,
getRaw
}