Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

directus-extension-raw-body 0.0.1-ci-test-3

Install from the command line:
Learn more about npm packages
$ npm install @significa/directus-extension-raw-body@0.0.1-ci-test-3
Install via package.json:
"@significa/directus-extension-raw-body": "0.0.1-ci-test-3"

About this version

Directus raw body extension

Simple Directus extension that sets the serialized request body in the express request object.

Installation / Configuration guide

In your Directus project directory run:

npm install directus-extension-raw-body

Create an environment variable RAW_BODY_ENDPOINT_PATTERN with a Regex Expression matching the endpoints/routes where rawBody will be added to the request object.

Examples:

# Matches all endpoints for a specific extension
RAW_BODY_ENDPOINT_PATTERN='^\/sample-extension\/.*$'

# Matches all endpoints (not recommended)
RAW_BODY_ENDPOINT_PATTERN='*'

# Matches two routes /hello-world and /sample/path
RAW_BODY_ENDPOINT_PATTERN='^(\/hello-world|\/sample\/path)$'

Restart Directus for the changes to take effect.

Usage

Create a directus endpoint extension:

  • JS

    export default (router, _) => {
      router.post(
        '/sample',
        async (req, res, _next) => {
        console.log('Raw body:', req.rawBody)
    
         return res.json({
           status: 'OK',
           raw_body: req.rawBody,
         })
      }
    )
  • TS

    export default (router, _) => {
      router.post(
        '/sample',
        async (req: RequestWithRawBody, res: ServerResponse, _next) => {
        console.log('Raw body:', req.rawBody)
    
        return res.json({
          status: 'OK',
          raw_body: req.rawBody,
        })
      }
    )

Details


Assets

  • directus-extension-raw-body-0.0.1-ci-test-3.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0