2.3.2 • Published 29 days ago

@routup/query v2.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
29 days ago

@routup/query

npm version main codecov Known Vulnerabilities Conventional Commits

This is a plugin for reading and parsing the query string of the request url.

Table of Contents

Installation

npm install @routup/query --save

Documentation

To read the docs, visit https://routup.net

Usage

It is important to invoke the request middleware, to parse the query-string of the request url.

import { createServer } from 'node:http';
import {
    createNodeDispatcher,
    coreHandler,
    Router
} from 'routup';
import {
    query,
    useRequestQuery
} from '@routup/query';

const router = new Router();

router.use(query());

router.get('/', coreHandler((req, res) => {
    const query = useRequestQuery(req);
    console.log(query);
    // { key: ..., ... }
}));

const server = createServer(createNodeDispatcher(router));
server.listen(3000);

Helpers

setRequestQuery

This function sets the parsed request query parameters for the current request.

declare function setRequestQuery(
    req: Request,
    key: string,
    value: unknown
) : void;

declare function setRequestQuery(
    req: Request, 
    record: Record<string, any>,
    append?: boolean
) : void;

useRequestQuery

This function returns the query parameters of the request.

declare function useRequestQuery(
    req: Request
) : Record<string, any>;

declare function useRequestQuery(
    req: Request, 
    key: string
) : any;

License

Made with 💚

Published under MIT License.

2.3.2

29 days ago

2.3.1

4 months ago

1.0.2

8 months ago

2.3.0

5 months ago

2.0.0-alpha.3

7 months ago

2.2.0

5 months ago

2.0.0-alpha.0

7 months ago

2.1.0

6 months ago

2.0.0

7 months ago

1.0.1

11 months ago

1.0.0

12 months ago

1.0.0-alpha.0

12 months ago

0.7.4

12 months ago

0.7.3

1 year ago

0.7.2

1 year ago

0.7.1

1 year ago

0.3.0

1 year ago

0.5.0

1 year ago

0.3.2

1 year ago

0.2.3

1 year ago

0.4.0

1 year ago

0.3.1

1 year ago

0.7.0

1 year ago

0.2.5

1 year ago

0.6.0

1 year ago

0.2.4

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.1.0-alpha.0

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago