1.3.2 • Published 2 months ago
@routup/basic v1.3.2
@routup/basic
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
Installation
npm install @routup/basic --save
Documentation
To read the docs, visit https://routup.net
Usage
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);
Options
body
Configure the body plugin.
- Type: Options |
boolean
- Default:
true
cookie
Configure the cookie plugin.
- Type: Options |
boolean
- Default:
true
query
Configure the query plugin.
- Type: Options |
boolean
- Default:
true
License
Made with 💚
Published under MIT License.
1.3.2
2 months ago
1.3.1
4 months ago
1.3.0
6 months ago
1.2.0
6 months ago
1.1.0
7 months ago
1.0.0
8 months ago
1.0.0-alpha.5
8 months ago
1.0.0-alpha.2
8 months ago
1.0.0-alpha.1
8 months ago
1.0.0-alpha.0
8 months ago