@routup/query v2.4.1
@routup/query
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 months ago
5 months ago
8 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago