JSPM

micro-urlencoded

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q27318F
  • License UNLICENSE

Parse query strings and form-urlencoded bodies for Zeit's Micro

Package Exports

  • micro-urlencoded

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (micro-urlencoded) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

query and urlencoded parsing for micro

Parse query strings and form-urlencoded bodies for Zeit's Micro.

Install

yarn add micro-urlencoded
# or
npm install --save micro-urlencoded

Usage

The first argument to micro-urlencoded may be a string, Node Buffer, an async handler function, or an IncomingMessage object (or similar enough to one for micro.buffer()).

const query = require('micro-urlencoded');

string

module.exports = async (req, res) {
  const url = 'https://example.com/whatever?query=starts&here=2';
  const queryString = require('url').parse(url);
  const queryObject = query(queryString);

};

Buffer

module.exports = async (req, res) {
  const buffer = micro.buffer(req);
  // do other things with the request body buffer...

  // if the buffer is url-encoded
  const body = query(buffer);

};

IncomingMessage

module.exports = async (req, res) {
  const {query, body} = query(req);

};

function

const handler = async (req, res) => {
  //  your handler code
};

module.exports = query(handler);

License

The Unlicense, which is to say, public domain unless a license is required in your jurisdiction, in which case please follow the LICENSE file.