This is a bundle plugin which includes the following plugins:
- body A plugin for reading and parsing the request payload.
- cookie A plugin for reading and parsing request cookies, as well serializing cookies for the response.
- query A plugin for reading and parsing the query string of the request url.
Table of Contents
npm install @routup/basic --save
To read the docs, visit https://routup.net
The modules body, cookie and query have an individual export path as shown in the following code snippet.
import { createServer } from 'node:http';
import {
createNodeDispatcher,
coreHandler,
Router
} from 'routup';
import { basic } from '@routup/basic';
import { useRequestBody } from '@routup/basic/body';
import { useRequestCookie, useRequestCookies } from '@routup/basic/cookie';
import { useRequetQuery } from '@routup/basic/query';
const router = new Router();
router.use(basic());
router.get('/', coreHandler((req, res) => {
const body = useRequestBody(req);
// { key: value, ... }
const cookies = useRequestCookies(req);
// { key: value, ... }
const cookie = useRequestCookie(req, 'key');
// value
const query = useRequetQuery(req);
// query
}));
const server = createServer(createNodeDispatcher(router));
server.listen(3000);
Configure the body plugin.
- Type: Options |
boolean
- Default:
true
Configure the cookie plugin.
- Type: Options |
boolean
- Default:
true
Configure the query plugin.
- Type: Options |
boolean
- Default:
true
Made with 💚
Published under MIT License.