Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.
/ arc-http-raw-body Public archive

A plugin for https://arc.codes that makes configured endpoints include an unparsed raw request body object as base64.

License

Notifications You must be signed in to change notification settings

zibasec/arc-http-raw-body

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turns out this is not needed. https://arc.codes/primitives/http#req

You can access the raw body like this

module.exports = async http(event, context) {
  const rawBody = event.body
}

arc-http-raw-body

A plugin for @architect/architect that makes configured endpoints include an unparsed raw request body object as base64.

This is particularly useful when integrating with services that provide signed payloads that need verification. For example, Stripe Webhooks.

Installation

npm install zibasec/arc-http-raw-body

Usage

You'll first need to install macro-custom-pragma-runner

Then use this pragma in your .arc file. Example...

@app
myApp

@http
post /hook

@macros
macro-custom-pragma-runner

@_zibasec/arc-http-raw-body
post /hook

@aws
region us-east-1

The values supplied under @_zibasec/arc-http-raw-body must have a match under @http.

You can access the base64 encoded object via event.raw...

exports.handler = async (event, context) => {
  // this decodes the b64 into a buffer
  const rawBodyAsBuffer = (new Buffer(event.raw, 'base64'))
  return {}
}

What does it do, exactly?

Under the covers this will add an API Gateway Mapping Template to your function and changes its integration type in order to all for the mapping.

License

MIT

About

A plugin for https://arc.codes that makes configured endpoints include an unparsed raw request body object as base64.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published