Skip to content

Commit

Permalink
feat: add worktop/cookie module (#20)
Browse files Browse the repository at this point in the history
* chore: setup `cookie` entry

* feat: add `worktop/cookie` module
  • Loading branch information
lukeed committed Mar 29, 2021
1 parent a024283 commit b148f46
Show file tree
Hide file tree
Showing 8 changed files with 441 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules

/kv
/cache
/cookie
/crypto
/base64
/request
Expand Down
1 change: 1 addition & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async function bundle(input, output) {
Promise.all([
bundle('src/router.ts', pkg.exports['.']),
bundle('src/cache.ts', pkg.exports['./cache']),
bundle('src/cookie.ts', pkg.exports['./cookie']),
bundle('src/base64.ts', pkg.exports['./base64']),
bundle('src/request.ts', pkg.exports['./request']),
bundle('src/response.ts', pkg.exports['./response']),
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
".": "./router/index.mjs",
"./kv": "./kv/index.mjs",
"./cache": "./cache/index.mjs",
"./cookie": "./cookie/index.mjs",
"./crypto": "./crypto/index.mjs",
"./request": "./request/index.mjs",
"./response": "./response/index.mjs",
Expand All @@ -23,9 +24,10 @@
"./package.json": "./package.json"
},
"files": [
"base64",
"cache",
"crypto",
"base64",
"cookie",
"request",
"response",
"router",
Expand Down
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ The `worktop/response` submodule contains the [`ServerResponse`](/src/response.d
The `worktop/base64` submodule contains a few utilities related to the [Base 64 encoding](https://tools.ietf.org/html/rfc4648#section-4).

### Module: `worktop/cookie`

> [View `worktop/cookie` API documentation](/src/cookie.d.ts)
<!-- > [View `worktop/cookie` API documentation](/docs/module.cookie.md) -->
The `worktop/cookie` submodule contains `parse` and `stringify` utilities for dealing with cookie header(s).

### Module: `worktop/utils`

> [View `worktop/utils` API documentation](/src/utils.d.ts)
Expand Down
12 changes: 12 additions & 0 deletions src/cookie.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface Attributes {
maxage?: number;
expires?: Date;
samesite?: 'Lax' | 'Strict' | 'None';
secure?: boolean;
httponly?: boolean;
domain?: string;
path?: string;
}

export function parse(cookie: string): Attributes & Record<string, string>;
export function stringify(name: string, value: string, options: Omit<Attributes, 'expires'> & { expires?: Date | number | string }): string;

0 comments on commit b148f46

Please sign in to comment.