Comparing version 0.0.13 to 0.0.14
@@ -20,3 +20,2 @@ /// <reference types="node" /> | ||
params: BundleParams; | ||
query: BundleQuery; | ||
getBody: IGetBody; | ||
@@ -34,6 +33,3 @@ logger: Logger; | ||
}; | ||
export declare type BundleQuery = { | ||
[k: string]: string | string[]; | ||
}; | ||
declare function createApp(options?: ConfigInput): IKequapp; | ||
export { Ex, createApp, sendFile, staticFiles }; |
@@ -25,3 +25,2 @@ "use strict"; | ||
const url = new url_1.URL(req.url || '/', `${req.headers.protocol}://${req.headers.host}`); | ||
const query = Object.fromEntries(url.searchParams); | ||
res.statusCode = 200; | ||
@@ -35,3 +34,2 @@ res.setHeader('Content-Type', 'text/plain; charset=utf-8'); | ||
params: {}, | ||
query, | ||
getBody: (0, create_get_body_1.default)(req, config.maxPayloadSize), | ||
@@ -38,0 +36,0 @@ logger: config.logger |
{ | ||
"name": "kequapp", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "Versatile, non-intrusive, tiny webapp framework", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
@@ -111,3 +111,2 @@ # Kequapp | ||
| `params` | Params extracted from the pathname. | | ||
| `query` | Params extracted from the querystring. | | ||
| `getBody` | Function to extract params from the request body. | | ||
@@ -233,2 +232,16 @@ | `logger` | Logger specified during setup. | | ||
### Querystring | ||
Querystring parameters are available from the Javascript [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) object found in [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL). | ||
```javascript | ||
app.route('/hotels', ({ url }) => { | ||
const page = url.searchParams.get('page'); | ||
const categories = url.searchParams.getAll('categories'); | ||
// page ~= 2 | ||
// categories ~= ['ac', 'hottub'] | ||
}); | ||
``` | ||
### Cookies | ||
@@ -235,0 +248,0 @@ |
67263
406
1456