1 | # Installation
|
2 | > `npm install --save @types/cookie-parser`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for cookie-parser (https://github.com/expressjs/cookie-parser).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cookie-parser.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cookie-parser/index.d.ts)
|
10 | ````ts
|
11 | // Type definitions for cookie-parser 1.4
|
12 | // Project: https://github.com/expressjs/cookie-parser
|
13 | // Definitions by: Santi Albo <https://github.com/santialbo>
|
14 | // BendingBender <https://github.com/BendingBender>
|
15 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
16 | // TypeScript Version: 2.3
|
17 |
|
18 | import * as express from 'express';
|
19 |
|
20 | declare global {
|
21 | namespace Express {
|
22 | // Inject additional properties on express.Request
|
23 | interface Request {
|
24 | /**
|
25 | * This request's secret.
|
26 | * Optionally set by cookie-parser if secret(s) are provided. Can be used by other middleware.
|
27 | * [Declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html) can be used to add your own properties.
|
28 | */
|
29 | secret?: string;
|
30 | }
|
31 | }
|
32 | }
|
33 |
|
34 | declare function cookieParser(secret?: string | string[], options?: cookieParser.CookieParseOptions): express.RequestHandler;
|
35 |
|
36 | declare namespace cookieParser {
|
37 | interface CookieParseOptions {
|
38 | decode?(val: string): string;
|
39 | }
|
40 |
|
41 | function JSONCookie(jsonCookie: string): object | undefined;
|
42 |
|
43 | function JSONCookies<T extends { [key: string]: string }>(jsonCookies: T): { [P in keyof T]: object | undefined };
|
44 |
|
45 | function signedCookie(cookie: string, secret: string | string[]): string | false;
|
46 |
|
47 | function signedCookies<T extends { [key: string]: string }>(cookies: T, secret: string | string[]): { [P in keyof T]?: string | false};
|
48 | }
|
49 |
|
50 | export = cookieParser;
|
51 |
|
52 | ````
|
53 |
|
54 | ### Additional Details
|
55 | * Last updated: Wed, 27 Apr 2022 10:31:34 GMT
|
56 | * Dependencies: [@types/express](https://npmjs.com/package/@types/express)
|
57 | * Global values: none
|
58 |
|
59 | # Credits
|
60 | These definitions were written by [Santi Albo](https://github.com/santialbo), and [BendingBender](https://github.com/BendingBender).
|
61 |
|
\ | No newline at end of file |