@lottojs/params-parser
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

Contributors Forks Stargazers Issues MIT License NPM


Logo

@lottojs/params-parser

NodeJS HTTP Request path and query parameters parser.

Report Bug · Request Feature

About The Project

HTTP Middleware done to parse query and path parameters from a given url, initially created to serve the @lottojs/router package but nothing excludes it to be also used by the community.

Documentation

Complete API documentation is available at lottojs.tech.

Getting Started

Installation

 npm i @lottojs/params-parser

Usage

It will depend on your scenario, basically the package exports a middleware called paramsParser. This middleware can be used receiving a path from any http handler and returns a promise awaiting to receive a request and next parameters. On the end it put's each parsed group on the right place, query parameters at req.query object and path parameters at req.params object, all ready to be used.

    import { createServer } from 'node:http';
    import { paramsParser } from '@lottojs/params-parser';

    createServer(
        async (req: IncomingMessage, res: ServerResponse) => {
                ...
                paramsParser(req.url)(req, next())
                ...
        },
    )

Contributing

All forms of contributions are more than welcome! You can contribute in the following ways:

  • Create an Issue
  • Create a Pull Request
  • Create third-party middlewares
  • Share with your friends
  • Make your application with Lotto.

For more details, see Contribution Guide.

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Package Sidebar

Install

npm i @lottojs/params-parser

Weekly Downloads

3

Version

0.2.1

License

MIT

Unpacked Size

12.2 kB

Total Files

12

Last publish

Collaborators

  • jharbs