Comparing version 0.5.0 to 0.5.1
@@ -32,2 +32,3 @@ "use strict"; | ||
const actions_1 = require("./router/actions"); | ||
const create_cookies_1 = __importDefault(require("./router/create-cookies")); | ||
const create_router_1 = __importDefault(require("./router/create-router")); | ||
@@ -68,2 +69,3 @@ var send_file_1 = require("./built-in/helpers/send-file"); | ||
methods, | ||
cookies: (0, create_cookies_1.default)(req, res), | ||
getBody: (0, create_get_body_1.default)(req), | ||
@@ -70,0 +72,0 @@ logger |
@@ -34,2 +34,3 @@ /// <reference types="node" /> | ||
methods: string[]; | ||
cookies: TCookies; | ||
getBody: IGetBody; | ||
@@ -41,2 +42,17 @@ logger: TLogger; | ||
}; | ||
export declare type TCookieOptions = { | ||
expires?: Date | string; | ||
maxAge?: number; | ||
domain?: string; | ||
path?: string; | ||
secure?: boolean; | ||
httpOnly?: boolean; | ||
partitioned?: boolean; | ||
sameSite?: 'Strict' | 'Lax' | 'None'; | ||
}; | ||
export declare type TCookies = { | ||
get: (key: string) => string | undefined; | ||
set: (key: string, value: string, options?: TCookieOptions) => void; | ||
remove: (key: string) => void; | ||
}; | ||
export interface IGetBody { | ||
@@ -43,0 +59,0 @@ (format: TGetBodyOptions & { |
{ | ||
"name": "kequapp", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Non-intrusive Node JavaScript web app framework", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
@@ -11,3 +11,3 @@ <img alt="kequapp" src="https://github.com/Kequc/kequapp/blob/0.2-wip/logo.png?raw=true" width="142" height="85" /> | ||
Intended to be simple, powerful, and allows us to interceed at any time. | ||
Intended to be simple, powerful, and allows us to intercede at any time. | ||
@@ -257,3 +257,3 @@ **Features** | ||
contentType: 'text/*', | ||
handler: (ex, { res }) => `${ex.statusCode} ${ex.message}` | ||
handle: (ex, { res }) => `${ex.statusCode} ${ex.message}` | ||
}); | ||
@@ -393,2 +393,17 @@ ``` | ||
#### **`cookies`** | ||
Includes helpers for `get()`, `set()`, and `remove()`. The `set()` method takes an optional third parameter with `expires`, `maxAge`, `domain`, `path`, `secure`, `httpOnly`, `partitioned`, and `sameSite`. | ||
```javascript | ||
createHandle(({ cookies }) => { | ||
// get a cookie | ||
const value: string | undefined = cookies.get('MyCookie'); | ||
// set a cookie | ||
cookies.set('MyCookie', 'NewValue', { maxAge: 10000 }); | ||
// remove a cookie | ||
cookies.remove('MyCookie'); | ||
}); | ||
``` | ||
#### **`getBody`** | ||
@@ -395,0 +410,0 @@ |
117448
67
2205
874