mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
feat(plugins): add req.rawBody for routes
Stripe webhooks endpoints requires to read the raw request body. https://docs.stripe.com/webhooks#verify-webhook-signatures-with-official-libraries
This commit is contained in:
committed by
Chocobozzz
parent
107e6e73a6
commit
1b323f4f65
@@ -9,6 +9,10 @@ async function register ({
|
||||
router.post('/form/post/mirror', (req, res) => {
|
||||
res.json(req.body)
|
||||
})
|
||||
|
||||
router.post('/form/post/mirror-raw-body', (req, res) => {
|
||||
res.json(JSON.parse(req.rawBody))
|
||||
})
|
||||
}
|
||||
|
||||
async function unregister () {
|
||||
|
||||
@@ -80,6 +80,24 @@ describe('Test plugin helpers', function () {
|
||||
}
|
||||
})
|
||||
|
||||
it('Should mirror the raw post body', async function () {
|
||||
const body = {
|
||||
torso: 'arms',
|
||||
legs: 'feet'
|
||||
}
|
||||
|
||||
for (const path of basePaths) {
|
||||
const res = await makePostBodyRequest({
|
||||
url: server.url,
|
||||
path: path + 'form/post/mirror-raw-body',
|
||||
fields: body,
|
||||
expectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
|
||||
expect(res.body).to.deep.equal(body)
|
||||
}
|
||||
})
|
||||
|
||||
it('Should remove the plugin and remove the routes', async function () {
|
||||
await server.plugins.uninstall({ npmName: 'peertube-plugin-test-five' })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user