npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

directus-extension-form-to-flow

v1.0.1

Published

Endpoint for transforming multipart/form-data or application/x-www-form-urlencoded to json for flow.

Readme

Directus Form To Flow Extension

A Directus endpoint extension that receives HTML form data (multipart/form-data or application/x-www-form-urlencoded) and forwards it to a Directus flow in JSON format.

📋 Description

This extension acts as a bridge between classic HTML forms and Directus flows. It automatically converts received data to JSON format and forwards it to the specified flow, facilitating the integration of external forms with your Directus instance.

✨ Features

  • Multi-format support: Handles both multipart/form-data and application/x-www-form-urlencoded forms
  • File handling: Automatically processes file uploads and encodes them in base64
  • Transparent forwarding: Preserves cookies and URL parameters
  • Error handling: Returns appropriate responses on failure
  • HTTPS compatible: Automatically detects the protocol used, even behind a proxy
  • Logging: Logs flow triggers and errors for easier debugging

📖 Usage

Endpoint

POST /formtoflow/:id

Where :id corresponds to the Directus flow ID you want to trigger.

HTML Form Example

<form action="/formtoflow/YOUR_FLOW_ID" method="POST" accept-charset="UTF-8" enctype="multipart/form-data">
    <input type="text" name="name" placeholder="Name" required>
    <input type="email" name="email" placeholder="Email" required>
    <input type="file" name="document">
    <textarea name="message" placeholder="Message"></textarea>
    <button type="submit">Submit</button>
</form>

Example Data Sent to Flow

The data received by the flow will be in JSON format:

{
    "name": "John Doe",
    "email": "[email protected]",
    "message": "Here is my message",
    "document": {
        "buffer": "[Base64 data]",
        "originalname": "document.pdf",
        "mimetype": "application/pdf"
    }
}

⚙️ How It Works

  1. Reception: The endpoint receives form data
  2. Parsing: Data is parsed according to its content type
  3. Transformation: Files are converted to base64 with their metadata
  4. Forwarding: JSON data is sent to the Directus flow, preserving cookies and URL parameters
  5. Response: The flow's response is returned to the client

🔧 Configuration

No specific configuration is required. The extension uses:

  • multer for multipart file handling
  • body-parser for URL-encoded data
  • node-fetch for requests to flows

📝 Important Notes

  • URL parameters are preserved when forwarding to the flow
  • Session cookies are transmitted for authentication
  • Errors are logged to the Directus console
  • The extension automatically detects the protocol (HTTP/HTTPS), including behind proxies

🐛 Error Handling

  • 500: Internal server error
  • Flow status: Returns the flow's status code on failure
  • Detailed logging in the console for debugging

🔒 Security

  • Session cookies are transmitted for authentication
  • No server-side validation: validation should be done in the flow
  • Use Directus permissions to control access to flows

📦 Dependencies

  • @directus/extensions-sdk
  • node-fetch
  • multer
  • body-parser

🤝 Contributing

This extension can be extended to:

  • Add server-side validation
  • Implement custom data transformations
  • Add more detailed logging
  • Support other data formats

📄 License

MIT Dan Denolf