forked from fastify/fastify-cookie
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.d.ts
75 lines (66 loc) · 1.77 KB
/
plugin.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/// <reference types="node" />
import * as fastify from 'fastify';
import {FastifyRequest, DefaultQuery, Plugin} from 'fastify';
import {IncomingMessage, ServerResponse} from 'http';
import {Http2ServerRequest, Http2ServerResponse} from 'http2';
type HttpRequest = IncomingMessage | Http2ServerRequest;
type HttpResponse = ServerResponse | Http2ServerResponse;
declare module 'fastify' {
interface FastifyRequest<
HttpRequest,
Query = fastify.DefaultQuery,
Params = fastify.DefaultParams,
Headers = fastify.DefaultHeaders,
Body = any
> {
/**
* Request cookies
*/
cookies: {[cookieName: string]: string};
}
interface CookieSerializeOptions {
domain?: string;
encode?(val: string): string;
expires?: Date;
httpOnly?: boolean;
maxAge?: number;
path?: string;
sameSite?: boolean | 'lax' | 'strict' | 'none';
secure?: boolean;
signed?: boolean;
}
interface FastifyReply<HttpResponse> {
/**
* Set response cookie
* @param name Cookie name
* @param value Cookie value
* @param options Serialize options
*/
setCookie(
name: string,
value: string,
options?: CookieSerializeOptions
): fastify.FastifyReply<HttpResponse>;
/**
* clear response cookie
* @param name Cookie name
* @param options Serialize options
*/
clearCookie(
name: string,
options?: CookieSerializeOptions
): fastify.FastifyReply<HttpResponse>;
/**
* Unsigns the specified cookie using the secret provided.
* @param value Cookie value
*/
unsignCookie(
value: string,
): string | false;
}
}
declare function fastifyCookie(): void;
declare namespace fastifyCookie {
interface FastifyCookieOptions {}
}
export = fastifyCookie;