tspace-spear 1.2.0 → 1.2.1
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/README.md +777 -705
- package/{build → dist}/lib/core/decorators/context.js +86 -0
- package/dist/lib/core/decorators/context.js.map +1 -0
- package/dist/lib/core/decorators/controller.js +43 -0
- package/dist/lib/core/decorators/controller.js.map +1 -0
- package/dist/lib/core/decorators/headers.js +44 -0
- package/dist/lib/core/decorators/headers.js.map +1 -0
- package/dist/lib/core/decorators/methods.js +102 -0
- package/dist/lib/core/decorators/methods.js.map +1 -0
- package/dist/lib/core/decorators/middleware.js +61 -0
- package/dist/lib/core/decorators/middleware.js.map +1 -0
- package/dist/lib/core/decorators/statusCode.js +40 -0
- package/dist/lib/core/decorators/statusCode.js.map +1 -0
- package/dist/lib/core/decorators/swagger.js +52 -0
- package/dist/lib/core/decorators/swagger.js.map +1 -0
- package/{build → dist}/lib/core/server/index.js +272 -205
- package/dist/lib/core/server/index.js.map +1 -0
- package/{build → dist}/lib/core/server/parser-factory.js +29 -7
- package/dist/lib/core/server/parser-factory.js.map +1 -0
- package/dist/lib/core/server/radix-router.js +65 -0
- package/dist/lib/core/server/radix-router.js.map +1 -0
- package/{build → dist}/lib/core/server/router.js +34 -0
- package/dist/lib/core/server/router.js.map +1 -0
- package/{build → dist}/lib/index.js +0 -1
- package/{build → dist}/lib/index.js.map +1 -1
- package/{build → dist}/tests/benchmark.test.js +38 -8
- package/{build → dist}/tests/benchmark.test.js.map +1 -1
- package/package.json +15 -10
- package/build/lib/core/decorators/context.d.ts +0 -5
- package/build/lib/core/decorators/context.js.map +0 -1
- package/build/lib/core/decorators/controller.d.ts +0 -1
- package/build/lib/core/decorators/controller.js +0 -10
- package/build/lib/core/decorators/controller.js.map +0 -1
- package/build/lib/core/decorators/headers.d.ts +0 -3
- package/build/lib/core/decorators/headers.js +0 -15
- package/build/lib/core/decorators/headers.js.map +0 -1
- package/build/lib/core/decorators/index.d.ts +0 -9
- package/build/lib/core/decorators/methods.d.ts +0 -5
- package/build/lib/core/decorators/methods.js +0 -25
- package/build/lib/core/decorators/methods.js.map +0 -1
- package/build/lib/core/decorators/middleware.d.ts +0 -2
- package/build/lib/core/decorators/middleware.js +0 -24
- package/build/lib/core/decorators/middleware.js.map +0 -1
- package/build/lib/core/decorators/statusCode.d.ts +0 -1
- package/build/lib/core/decorators/statusCode.js +0 -16
- package/build/lib/core/decorators/statusCode.js.map +0 -1
- package/build/lib/core/decorators/swagger.d.ts +0 -2
- package/build/lib/core/decorators/swagger.js +0 -18
- package/build/lib/core/decorators/swagger.js.map +0 -1
- package/build/lib/core/server/index.d.ts +0 -312
- package/build/lib/core/server/index.js.map +0 -1
- package/build/lib/core/server/parser-factory.d.ts +0 -24
- package/build/lib/core/server/parser-factory.js.map +0 -1
- package/build/lib/core/server/router.d.ts +0 -79
- package/build/lib/core/server/router.js.map +0 -1
- package/build/lib/core/types/index.d.ts +0 -168
- package/build/lib/index.d.ts +0 -11
- package/build/tests/benchmark.test.d.ts +0 -1
- /package/{build → dist}/lib/core/decorators/index.js +0 -0
- /package/{build → dist}/lib/core/decorators/index.js.map +0 -0
- /package/{build → dist}/lib/core/types/index.js +0 -0
- /package/{build → dist}/lib/core/types/index.js.map +0 -0
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from "http";
|
|
3
|
-
export type TContext = {
|
|
4
|
-
req: TRequest;
|
|
5
|
-
res: TResponse;
|
|
6
|
-
headers: THeaders;
|
|
7
|
-
query: TQuery;
|
|
8
|
-
params: TParams;
|
|
9
|
-
body: TBody;
|
|
10
|
-
files: TFiles;
|
|
11
|
-
cookies: TCookies;
|
|
12
|
-
};
|
|
13
|
-
export type THeaders<T = IncomingHttpHeaders> = T;
|
|
14
|
-
export type TQuery<T = Record<string, string>> = T;
|
|
15
|
-
export type TParams<T = Record<string, string>> = T;
|
|
16
|
-
export type TBody<T = Record<string, string | number | boolean | undefined | null | any[] | Record<string, string | number | boolean | undefined | null | any[]>>> = T;
|
|
17
|
-
export type TCookies<T = Record<string, any>> = T;
|
|
18
|
-
export type TFiles<T = Record<string, {
|
|
19
|
-
size: number;
|
|
20
|
-
sizes: {
|
|
21
|
-
bytes: number;
|
|
22
|
-
kb: number;
|
|
23
|
-
mb: number;
|
|
24
|
-
gb: number;
|
|
25
|
-
};
|
|
26
|
-
tempFilePath: string;
|
|
27
|
-
tempFileName: string;
|
|
28
|
-
mimetype: string;
|
|
29
|
-
extension: string;
|
|
30
|
-
name: string;
|
|
31
|
-
write: (to: string) => Promise<void>;
|
|
32
|
-
remove: () => Promise<void>;
|
|
33
|
-
}[]>> = T;
|
|
34
|
-
export type TNextFunction<T = any> = (err?: Error) => T | Promise<T>;
|
|
35
|
-
export type TRequest<T = any> = IncomingMessage & Partial<T>;
|
|
36
|
-
type THttpStatus = {
|
|
37
|
-
json: (data?: Record<string, any>) => void;
|
|
38
|
-
error: (err: any) => void;
|
|
39
|
-
ok: (data?: Record<string, any>) => void;
|
|
40
|
-
created: (data?: Record<string, any>) => void;
|
|
41
|
-
accepted: (data?: Record<string, any>) => void;
|
|
42
|
-
noContent: (message?: string) => void;
|
|
43
|
-
badRequest: (message?: string) => void;
|
|
44
|
-
unauthorized: (message?: string) => void;
|
|
45
|
-
paymentRequired: (message?: string) => void;
|
|
46
|
-
forbidden: (message?: string) => void;
|
|
47
|
-
tooManyRequests: (message?: string) => void;
|
|
48
|
-
notFound: (message?: string) => void;
|
|
49
|
-
serverError: (message: string) => void;
|
|
50
|
-
forceStatus: (code: number) => void;
|
|
51
|
-
setCookies: (cookies: Record<string, string | {
|
|
52
|
-
value: string;
|
|
53
|
-
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
54
|
-
domain?: string;
|
|
55
|
-
secure?: boolean;
|
|
56
|
-
httpOnly?: boolean;
|
|
57
|
-
expires?: Date;
|
|
58
|
-
}>) => void;
|
|
59
|
-
};
|
|
60
|
-
export type TResponse<T = any> = ServerResponse & {
|
|
61
|
-
status: (code: 200 | 201 | 202 | 203 | 204 | 300 | 301 | 302 | 303 | 304 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505) => {
|
|
62
|
-
json: (data?: Record<string, any>) => void;
|
|
63
|
-
send: (message: string) => void;
|
|
64
|
-
};
|
|
65
|
-
} & THttpStatus & Partial<T>;
|
|
66
|
-
export type TRouter = {
|
|
67
|
-
method: TMethods;
|
|
68
|
-
path: string;
|
|
69
|
-
handler: string | symbol;
|
|
70
|
-
};
|
|
71
|
-
export type IRoute = {
|
|
72
|
-
method: TMethods;
|
|
73
|
-
path: string;
|
|
74
|
-
handlers: TContext[];
|
|
75
|
-
};
|
|
76
|
-
export type TMethods = 'get' | 'post' | 'patch' | 'put' | 'delete' | 'all';
|
|
77
|
-
export type TApplication = {
|
|
78
|
-
controllers?: (new () => any)[] | {
|
|
79
|
-
folder: string;
|
|
80
|
-
name?: RegExp;
|
|
81
|
-
};
|
|
82
|
-
middlewares?: TRequestFunction[] | {
|
|
83
|
-
folder: string;
|
|
84
|
-
name?: RegExp;
|
|
85
|
-
};
|
|
86
|
-
globalPrefix?: string;
|
|
87
|
-
logger?: boolean;
|
|
88
|
-
cluster?: boolean | number;
|
|
89
|
-
};
|
|
90
|
-
export type TRequestFunction = (ctx: TContext, next: TNextFunction) => any;
|
|
91
|
-
export type TErrorFunction = (err: Error, ctx: TContext) => any;
|
|
92
|
-
type TSwaggerFormat = "string" | "number" | "integer" | "boolean" | "object" | "array" | "date" | "date-time" | "password" | "int32" | "int64" | "float" | "double" | "byte" | "binary" | "base64" | "email" | "uuid" | "uri" | "hostname" | "ipv4" | "ipv6" | "json" | "xml";
|
|
93
|
-
type TSwaggerType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "date" | "date-time" | "file";
|
|
94
|
-
export type TSwaggerDoc = {
|
|
95
|
-
path?: `/${string}`;
|
|
96
|
-
staticUrl?: `${string}`;
|
|
97
|
-
servers?: {
|
|
98
|
-
url: string;
|
|
99
|
-
description?: string;
|
|
100
|
-
}[];
|
|
101
|
-
tags?: string[];
|
|
102
|
-
info?: {
|
|
103
|
-
title?: string;
|
|
104
|
-
description?: string;
|
|
105
|
-
version?: string;
|
|
106
|
-
};
|
|
107
|
-
routes: {
|
|
108
|
-
path: string;
|
|
109
|
-
method: string;
|
|
110
|
-
params: string[];
|
|
111
|
-
}[];
|
|
112
|
-
options: (TSwagger & {
|
|
113
|
-
path: string;
|
|
114
|
-
method: string;
|
|
115
|
-
})[];
|
|
116
|
-
responses?: {
|
|
117
|
-
status: number;
|
|
118
|
-
description: string;
|
|
119
|
-
example?: Record<string, any>;
|
|
120
|
-
}[];
|
|
121
|
-
};
|
|
122
|
-
export type TSwagger = {
|
|
123
|
-
staticUrl?: string;
|
|
124
|
-
summary?: string;
|
|
125
|
-
description?: string;
|
|
126
|
-
bearerToken?: boolean;
|
|
127
|
-
tags?: string[];
|
|
128
|
-
params?: Record<string, {
|
|
129
|
-
description?: string;
|
|
130
|
-
type?: TSwaggerType;
|
|
131
|
-
example?: any;
|
|
132
|
-
}>;
|
|
133
|
-
query?: Record<string, {
|
|
134
|
-
required?: boolean;
|
|
135
|
-
description?: string;
|
|
136
|
-
type: TSwaggerType;
|
|
137
|
-
example?: any;
|
|
138
|
-
}>;
|
|
139
|
-
cookies?: {
|
|
140
|
-
names: string[];
|
|
141
|
-
required?: boolean;
|
|
142
|
-
description?: string;
|
|
143
|
-
};
|
|
144
|
-
body?: {
|
|
145
|
-
required?: boolean;
|
|
146
|
-
description?: string;
|
|
147
|
-
properties: Record<string, {
|
|
148
|
-
type: TSwaggerType;
|
|
149
|
-
example?: any;
|
|
150
|
-
}>;
|
|
151
|
-
};
|
|
152
|
-
files?: {
|
|
153
|
-
required?: boolean;
|
|
154
|
-
description?: string;
|
|
155
|
-
properties: Record<string, {
|
|
156
|
-
type: TSwaggerType;
|
|
157
|
-
format?: TSwaggerFormat;
|
|
158
|
-
items?: any;
|
|
159
|
-
example?: any;
|
|
160
|
-
}>;
|
|
161
|
-
};
|
|
162
|
-
responses?: {
|
|
163
|
-
status: number;
|
|
164
|
-
description: string;
|
|
165
|
-
example?: Record<string, any>;
|
|
166
|
-
}[];
|
|
167
|
-
};
|
|
168
|
-
export {};
|
package/build/lib/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The entry point.
|
|
3
|
-
*
|
|
4
|
-
* @module tspace-spear
|
|
5
|
-
*/
|
|
6
|
-
export * from './core/decorators';
|
|
7
|
-
export * from './core/types';
|
|
8
|
-
export * from './core/server/router';
|
|
9
|
-
export * from './core/server';
|
|
10
|
-
import Spear from './core/server';
|
|
11
|
-
export default Spear;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|