2.4.1 • Published 2 months ago

@routup/query v2.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months 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.4.1

2 months ago

2.4.0

5 months ago

2.3.2

8 months ago

2.3.1

11 months ago

1.0.2

1 year ago

2.3.0

1 year ago

2.0.0-alpha.3

1 year ago

2.2.0

1 year ago

2.0.0-alpha.0

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.0.1

1 year ago

1.0.0

2 years ago

1.0.0-alpha.0

2 years ago

0.7.4

2 years ago

0.7.3

2 years ago

0.7.2

2 years ago

0.7.1

2 years ago

0.3.0

2 years ago

0.5.0

2 years ago

0.3.2

2 years ago

0.2.3

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.7.0

2 years ago

0.2.5

2 years ago

0.6.0

2 years ago

0.2.4

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.1.0-alpha.0

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago