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

This commit is contained in:
root committed 2018-06-27 00:59:53 +08:00
1 parent f409e6ff61
commit 1f3057df69
15 files changed
+376 -50

No files matched your search

+21 -1
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()
}
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
verifyLine,
getRaw
}