@syntay/fastay 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts +39 -0
- package/dist/app.js +31 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/router.js +3 -4
- package/dist/types/index.d.ts +36 -5
- package/dist/utils/cookies.d.ts +10 -0
- package/dist/utils/cookies.js +28 -0
- package/package.json +3 -1
- package/src/app.ts +92 -1
- package/src/index.ts +1 -0
- package/src/router.ts +4 -5
- package/src/types/fastay-global.d.ts +7 -0
- package/src/types/fastay.d.ts +9 -0
- package/src/types/index.ts +46 -14
- package/src/utils/cookies.ts +34 -0
- package/tsconfig.json +4 -2
package/dist/app.d.ts
CHANGED
|
@@ -75,6 +75,45 @@ export type CreateAppOptions = {
|
|
|
75
75
|
* Default: "/api"
|
|
76
76
|
*/
|
|
77
77
|
baseRoute?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Configuration to enable CORS (Cross-Origin Resource Sharing) in Fastay.
|
|
80
|
+
*/
|
|
81
|
+
enableCors?: {
|
|
82
|
+
/**
|
|
83
|
+
* If true, permite requisições de qualquer origem.
|
|
84
|
+
* Default: false
|
|
85
|
+
*/
|
|
86
|
+
allowAnyOrigin?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Lista de origens específicas permitidas para envio de cookies.
|
|
89
|
+
* Exemplo: ["http://localhost:3000", "https://meusite.com"]
|
|
90
|
+
*/
|
|
91
|
+
cookieOrigins?: string[];
|
|
92
|
+
/**
|
|
93
|
+
* Se true, habilita envio de cookies cross-origin.
|
|
94
|
+
* Default: false
|
|
95
|
+
*/
|
|
96
|
+
credentials?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Lista de métodos HTTP permitidos, separados por vírgula.
|
|
99
|
+
* Default: "GET,POST,PUT,PATCH,DELETE,OPTIONS"
|
|
100
|
+
*/
|
|
101
|
+
methods?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Lista de cabeçalhos permitidos na requisição.
|
|
104
|
+
* Default: "Content-Type, Authorization"
|
|
105
|
+
*/
|
|
106
|
+
headers?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Cabeçalhos expostos ao cliente.
|
|
109
|
+
* Exemplo: ["X-Custom-Header"]
|
|
110
|
+
*/
|
|
111
|
+
exposedHeaders?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Tempo máximo de cache para requisições prévias (preflight), em segundos.
|
|
114
|
+
*/
|
|
115
|
+
maxAge?: number;
|
|
116
|
+
};
|
|
78
117
|
/**
|
|
79
118
|
* Port on which `.listen()` will run the server.
|
|
80
119
|
* Default: 3000
|
package/dist/app.js
CHANGED
|
@@ -4,6 +4,7 @@ import { loadApiRoutes } from './router.js';
|
|
|
4
4
|
import { loadFastayMiddlewares, createMiddleware, } from './middleware.js';
|
|
5
5
|
import { logger } from './logger.js';
|
|
6
6
|
import { printBanner } from './banner.js';
|
|
7
|
+
import { RequestCookies } from './utils/cookies.js';
|
|
7
8
|
/**
|
|
8
9
|
* Bootstraps and configures a Fastay application.
|
|
9
10
|
*
|
|
@@ -91,8 +92,37 @@ export async function createApp(opts) {
|
|
|
91
92
|
const isMiddleware = await loadFastayMiddlewares(app);
|
|
92
93
|
// health check
|
|
93
94
|
app.get('/_health', (_, res) => res.json({ ok: true }));
|
|
94
|
-
app.use((
|
|
95
|
+
app.use((req, res, next) => {
|
|
95
96
|
res.setHeader('X-Powered-By', 'Syntay Engine');
|
|
97
|
+
req.cookies = new RequestCookies(req.headers.cookie);
|
|
98
|
+
const corsOpts = opts?.enableCors || {};
|
|
99
|
+
// Determina a origem
|
|
100
|
+
let origin = '*';
|
|
101
|
+
if (corsOpts.credentials && corsOpts.cookieOrigins?.length) {
|
|
102
|
+
// Se a origem estiver na lista de cookieOrigins, permite cookies
|
|
103
|
+
if (req.headers.origin &&
|
|
104
|
+
corsOpts.cookieOrigins.includes(req.headers.origin)) {
|
|
105
|
+
origin = req.headers.origin;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
origin = ''; // bloqueia cookies para outras origens
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (!corsOpts.credentials && corsOpts.allowAnyOrigin) {
|
|
112
|
+
origin = '*';
|
|
113
|
+
}
|
|
114
|
+
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
115
|
+
res.setHeader('Access-Control-Allow-Credentials', corsOpts.credentials ? 'true' : 'false');
|
|
116
|
+
res.setHeader('Access-Control-Allow-Methods', corsOpts.methods || 'GET,POST,PUT,PATCH,DELETE,OPTIONS');
|
|
117
|
+
res.setHeader('Access-Control-Allow-Headers', corsOpts.headers || 'Content-Type, Authorization');
|
|
118
|
+
if (corsOpts.exposedHeaders) {
|
|
119
|
+
res.setHeader('Access-Control-Expose-Headers', corsOpts.exposedHeaders);
|
|
120
|
+
}
|
|
121
|
+
if (corsOpts.maxAge) {
|
|
122
|
+
res.setHeader('Access-Control-Max-Age', corsOpts.maxAge.toString());
|
|
123
|
+
}
|
|
124
|
+
if (req.method === 'OPTIONS')
|
|
125
|
+
return res.sendStatus(204);
|
|
96
126
|
next();
|
|
97
127
|
});
|
|
98
128
|
// load routes
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/router.js
CHANGED
|
@@ -92,10 +92,9 @@ function wrapHandler(fn, routePath, filePath) {
|
|
|
92
92
|
res.cookie(name, data.value, data.options || {});
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return res.json(result);
|
|
95
|
+
const statusCode = typeof result.status === 'number' ? result.status : 200;
|
|
96
|
+
const body = result.body ?? result; // se não existir body, retorna o objeto inteiro
|
|
97
|
+
return res.status(statusCode).json(body);
|
|
99
98
|
}
|
|
100
99
|
// Suporte a retorno simples
|
|
101
100
|
if (typeof result === 'string')
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
import { Request as ExpressRequest, Response as ExpressResponse, NextFunction } from 'express';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
2
|
+
export interface CookieItem {
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RequestCookies {
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves a cookie by its name.
|
|
8
|
+
* @param name - The name of the cookie to retrieve.
|
|
9
|
+
* @returns An object containing the cookie's value, or undefined if not found.
|
|
10
|
+
*/
|
|
11
|
+
get(name: string): CookieItem | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Checks if a cookie with the given name exists.
|
|
14
|
+
* @param name - The name of the cookie to check.
|
|
15
|
+
* @returns True if the cookie exists, false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
has(name: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Returns all cookies as a key-value object.
|
|
20
|
+
* @returns An object where keys are cookie names and values are cookie values.
|
|
21
|
+
*/
|
|
22
|
+
all(): Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
export interface Request extends ExpressRequest {
|
|
25
|
+
/**
|
|
26
|
+
* Represents the cookies sent in a request.
|
|
27
|
+
*/
|
|
28
|
+
cookies: RequestCookies;
|
|
29
|
+
}
|
|
6
30
|
export type Response = ExpressResponse;
|
|
7
31
|
export type Next = NextFunction;
|
|
8
|
-
export {};
|
|
9
32
|
declare global {
|
|
10
33
|
type FastayResponse = {
|
|
11
34
|
status?: number;
|
|
@@ -26,3 +49,11 @@ declare global {
|
|
|
26
49
|
};
|
|
27
50
|
}
|
|
28
51
|
export type RouteHandler = (() => FastayResponse | any) | ((req: Request) => FastayResponse | any) | ((req: Request, res: Response) => FastayResponse | any);
|
|
52
|
+
export interface CookieItem {
|
|
53
|
+
value: string;
|
|
54
|
+
}
|
|
55
|
+
declare module 'express-serve-static-core' {
|
|
56
|
+
interface Request {
|
|
57
|
+
typedCookies: RequestCookies | any;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class RequestCookies {
|
|
2
|
+
private cookies;
|
|
3
|
+
constructor(cookieHeader: string | undefined);
|
|
4
|
+
get(name: string): {
|
|
5
|
+
value: string;
|
|
6
|
+
} | undefined;
|
|
7
|
+
has(name: string): boolean;
|
|
8
|
+
all(): Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export declare const cookies: typeof RequestCookies;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class RequestCookies {
|
|
2
|
+
constructor(cookieHeader) {
|
|
3
|
+
this.cookies = new Map();
|
|
4
|
+
if (!cookieHeader)
|
|
5
|
+
return;
|
|
6
|
+
cookieHeader.split(';').forEach((cookie) => {
|
|
7
|
+
const [name, ...rest] = cookie.trim().split('=');
|
|
8
|
+
if (!name)
|
|
9
|
+
return;
|
|
10
|
+
this.cookies.set(name, decodeURIComponent(rest.join('=')));
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
get(name) {
|
|
14
|
+
const value = this.cookies.get(name);
|
|
15
|
+
if (!value)
|
|
16
|
+
return undefined;
|
|
17
|
+
return { value };
|
|
18
|
+
}
|
|
19
|
+
has(name) {
|
|
20
|
+
return this.cookies.has(name);
|
|
21
|
+
}
|
|
22
|
+
all() {
|
|
23
|
+
const obj = {};
|
|
24
|
+
this.cookies.forEach((v, k) => (obj[k] = v));
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export const cookies = RequestCookies;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syntay/fastay",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Framework backend moderno baseado em Express.js, para criar APIs rapidamente",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"chokidar": "^4.0.3",
|
|
31
32
|
"express": "^5.1.0",
|
|
33
|
+
"import-fresh": "^3.3.1",
|
|
32
34
|
"pino": "^10.1.0",
|
|
33
35
|
"pino-pretty": "^13.1.2"
|
|
34
36
|
},
|
package/src/app.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { logger } from './logger.js';
|
|
|
10
10
|
import { printBanner } from './banner.js';
|
|
11
11
|
import type { ServeStaticOptions } from 'serve-static';
|
|
12
12
|
import { Next, Request, Response } from './types/index.js';
|
|
13
|
+
import { RequestCookies } from './utils/cookies.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Express configuration options applied automatically by Fastay
|
|
@@ -95,6 +96,52 @@ export type CreateAppOptions = {
|
|
|
95
96
|
*/
|
|
96
97
|
baseRoute?: string;
|
|
97
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Configuration to enable CORS (Cross-Origin Resource Sharing) in Fastay.
|
|
101
|
+
*/
|
|
102
|
+
enableCors?: {
|
|
103
|
+
/**
|
|
104
|
+
* If true, permite requisições de qualquer origem.
|
|
105
|
+
* Default: false
|
|
106
|
+
*/
|
|
107
|
+
allowAnyOrigin?: boolean;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Lista de origens específicas permitidas para envio de cookies.
|
|
111
|
+
* Exemplo: ["http://localhost:3000", "https://meusite.com"]
|
|
112
|
+
*/
|
|
113
|
+
cookieOrigins?: string[];
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Se true, habilita envio de cookies cross-origin.
|
|
117
|
+
* Default: false
|
|
118
|
+
*/
|
|
119
|
+
credentials?: boolean;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Lista de métodos HTTP permitidos, separados por vírgula.
|
|
123
|
+
* Default: "GET,POST,PUT,PATCH,DELETE,OPTIONS"
|
|
124
|
+
*/
|
|
125
|
+
methods?: string;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Lista de cabeçalhos permitidos na requisição.
|
|
129
|
+
* Default: "Content-Type, Authorization"
|
|
130
|
+
*/
|
|
131
|
+
headers?: string;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Cabeçalhos expostos ao cliente.
|
|
135
|
+
* Exemplo: ["X-Custom-Header"]
|
|
136
|
+
*/
|
|
137
|
+
exposedHeaders?: string;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Tempo máximo de cache para requisições prévias (preflight), em segundos.
|
|
141
|
+
*/
|
|
142
|
+
maxAge?: number;
|
|
143
|
+
};
|
|
144
|
+
|
|
98
145
|
/**
|
|
99
146
|
* Port on which `.listen()` will run the server.
|
|
100
147
|
* Default: 3000
|
|
@@ -214,8 +261,52 @@ export async function createApp(opts?: CreateAppOptions) {
|
|
|
214
261
|
|
|
215
262
|
// health check
|
|
216
263
|
app.get('/_health', (_, res) => res.json({ ok: true }));
|
|
217
|
-
app.use((
|
|
264
|
+
app.use((req: Request, res: Response, next: Next) => {
|
|
218
265
|
res.setHeader('X-Powered-By', 'Syntay Engine');
|
|
266
|
+
(req as any).cookies = new RequestCookies(req.headers.cookie);
|
|
267
|
+
|
|
268
|
+
const corsOpts = opts?.enableCors || {};
|
|
269
|
+
|
|
270
|
+
// Determina a origem
|
|
271
|
+
let origin = '*';
|
|
272
|
+
|
|
273
|
+
if (corsOpts.credentials && corsOpts.cookieOrigins?.length) {
|
|
274
|
+
// Se a origem estiver na lista de cookieOrigins, permite cookies
|
|
275
|
+
if (
|
|
276
|
+
req.headers.origin &&
|
|
277
|
+
corsOpts.cookieOrigins.includes(req.headers.origin)
|
|
278
|
+
) {
|
|
279
|
+
origin = req.headers.origin;
|
|
280
|
+
} else {
|
|
281
|
+
origin = ''; // bloqueia cookies para outras origens
|
|
282
|
+
}
|
|
283
|
+
} else if (!corsOpts.credentials && corsOpts.allowAnyOrigin) {
|
|
284
|
+
origin = '*';
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
288
|
+
res.setHeader(
|
|
289
|
+
'Access-Control-Allow-Credentials',
|
|
290
|
+
corsOpts.credentials ? 'true' : 'false'
|
|
291
|
+
);
|
|
292
|
+
res.setHeader(
|
|
293
|
+
'Access-Control-Allow-Methods',
|
|
294
|
+
corsOpts.methods || 'GET,POST,PUT,PATCH,DELETE,OPTIONS'
|
|
295
|
+
);
|
|
296
|
+
res.setHeader(
|
|
297
|
+
'Access-Control-Allow-Headers',
|
|
298
|
+
corsOpts.headers || 'Content-Type, Authorization'
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
if (corsOpts.exposedHeaders) {
|
|
302
|
+
res.setHeader('Access-Control-Expose-Headers', corsOpts.exposedHeaders);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (corsOpts.maxAge) {
|
|
306
|
+
res.setHeader('Access-Control-Max-Age', corsOpts.maxAge.toString());
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (req.method === 'OPTIONS') return res.sendStatus(204);
|
|
219
310
|
next();
|
|
220
311
|
});
|
|
221
312
|
|
package/src/index.ts
CHANGED
package/src/router.ts
CHANGED
|
@@ -64,7 +64,6 @@ function wrapHandler(fn: Function, routePath: string, filePath: string) {
|
|
|
64
64
|
const typedResult = result as {
|
|
65
65
|
status?: number;
|
|
66
66
|
body?: any;
|
|
67
|
-
|
|
68
67
|
cookies?: Record<string, { value: string; options?: any }>;
|
|
69
68
|
headers?: Record<string, string>;
|
|
70
69
|
redirect?: string;
|
|
@@ -124,11 +123,11 @@ function wrapHandler(fn: Function, routePath: string, filePath: string) {
|
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
126
|
+
const statusCode =
|
|
127
|
+
typeof result.status === 'number' ? result.status : 200;
|
|
130
128
|
|
|
131
|
-
|
|
129
|
+
const body = result.body ?? result; // se não existir body, retorna o objeto inteiro
|
|
130
|
+
return res.status(statusCode).json(body);
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
// Suporte a retorno simples
|
package/src/types/index.ts
CHANGED
|
@@ -4,30 +4,52 @@ import {
|
|
|
4
4
|
NextFunction,
|
|
5
5
|
} from 'express';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export interface CookieItem {
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RequestCookies {
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves a cookie by its name.
|
|
14
|
+
* @param name - The name of the cookie to retrieve.
|
|
15
|
+
* @returns An object containing the cookie's value, or undefined if not found.
|
|
16
|
+
*/
|
|
17
|
+
get(name: string): CookieItem | undefined;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Checks if a cookie with the given name exists.
|
|
21
|
+
* @param name - The name of the cookie to check.
|
|
22
|
+
* @returns True if the cookie exists, false otherwise.
|
|
23
|
+
*/
|
|
24
|
+
has(name: string): boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns all cookies as a key-value object.
|
|
28
|
+
* @returns An object where keys are cookie names and values are cookie values.
|
|
29
|
+
*/
|
|
30
|
+
all(): Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Request extends ExpressRequest {
|
|
34
|
+
/**
|
|
35
|
+
* Represents the cookies sent in a request.
|
|
36
|
+
*/
|
|
37
|
+
cookies: RequestCookies;
|
|
38
|
+
// params:
|
|
39
|
+
// query:
|
|
40
|
+
}
|
|
41
|
+
|
|
11
42
|
export type Response = ExpressResponse;
|
|
12
43
|
export type Next = NextFunction;
|
|
13
44
|
|
|
14
|
-
export {};
|
|
15
|
-
|
|
16
45
|
declare global {
|
|
17
46
|
type FastayResponse = {
|
|
18
47
|
status?: number;
|
|
19
48
|
body?: any;
|
|
20
|
-
|
|
21
49
|
cookies?: Record<string, { value: string; options?: any }>;
|
|
22
50
|
headers?: Record<string, string>;
|
|
23
51
|
redirect?: string;
|
|
24
|
-
|
|
25
|
-
file?: {
|
|
26
|
-
path: string;
|
|
27
|
-
filename?: string;
|
|
28
|
-
options?: any;
|
|
29
|
-
};
|
|
30
|
-
|
|
52
|
+
file?: { path: string; filename?: string; options?: any };
|
|
31
53
|
stream?: NodeJS.ReadableStream;
|
|
32
54
|
raw?: Buffer | string;
|
|
33
55
|
};
|
|
@@ -37,3 +59,13 @@ export type RouteHandler =
|
|
|
37
59
|
| (() => FastayResponse | any)
|
|
38
60
|
| ((req: Request) => FastayResponse | any)
|
|
39
61
|
| ((req: Request, res: Response) => FastayResponse | any);
|
|
62
|
+
|
|
63
|
+
export interface CookieItem {
|
|
64
|
+
value: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare module 'express-serve-static-core' {
|
|
68
|
+
interface Request {
|
|
69
|
+
typedCookies: RequestCookies | any;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// utils/cookies.ts
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
|
|
4
|
+
export class RequestCookies {
|
|
5
|
+
private cookies: Map<string, string> = new Map();
|
|
6
|
+
|
|
7
|
+
constructor(cookieHeader: string | undefined) {
|
|
8
|
+
if (!cookieHeader) return;
|
|
9
|
+
|
|
10
|
+
cookieHeader.split(';').forEach((cookie) => {
|
|
11
|
+
const [name, ...rest] = cookie.trim().split('=');
|
|
12
|
+
if (!name) return;
|
|
13
|
+
this.cookies.set(name, decodeURIComponent(rest.join('=')));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public get(name: string) {
|
|
18
|
+
const value = this.cookies.get(name);
|
|
19
|
+
if (!value) return undefined;
|
|
20
|
+
return { value };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public has(name: string) {
|
|
24
|
+
return this.cookies.has(name);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public all() {
|
|
28
|
+
const obj: Record<string, string> = {};
|
|
29
|
+
this.cookies.forEach((v, k) => (obj[k] = v));
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const cookies = RequestCookies;
|
package/tsconfig.json
CHANGED
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
"module": "CommonJS",
|
|
5
5
|
"rootDir": "src",
|
|
6
6
|
"outDir": "dist",
|
|
7
|
+
"baseUrl": ".",
|
|
7
8
|
"strict": true,
|
|
8
9
|
"esModuleInterop": true,
|
|
9
10
|
"forceConsistentCasingInFileNames": true,
|
|
10
11
|
"skipLibCheck": true,
|
|
11
12
|
"moduleResolution": "node",
|
|
12
13
|
"resolveJsonModule": true,
|
|
13
|
-
"allowSyntheticDefaultImports": true
|
|
14
|
+
"allowSyntheticDefaultImports": true,
|
|
15
|
+
"typeRoots": ["./node_modules/@types", "./types"]
|
|
14
16
|
},
|
|
15
|
-
"include": ["src"],
|
|
17
|
+
"include": ["src", "types"],
|
|
16
18
|
"exclude": ["node_modules", "dist"]
|
|
17
19
|
}
|