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.
Files changed (62) hide show
  1. package/README.md +777 -705
  2. package/{build → dist}/lib/core/decorators/context.js +86 -0
  3. package/dist/lib/core/decorators/context.js.map +1 -0
  4. package/dist/lib/core/decorators/controller.js +43 -0
  5. package/dist/lib/core/decorators/controller.js.map +1 -0
  6. package/dist/lib/core/decorators/headers.js +44 -0
  7. package/dist/lib/core/decorators/headers.js.map +1 -0
  8. package/dist/lib/core/decorators/methods.js +102 -0
  9. package/dist/lib/core/decorators/methods.js.map +1 -0
  10. package/dist/lib/core/decorators/middleware.js +61 -0
  11. package/dist/lib/core/decorators/middleware.js.map +1 -0
  12. package/dist/lib/core/decorators/statusCode.js +40 -0
  13. package/dist/lib/core/decorators/statusCode.js.map +1 -0
  14. package/dist/lib/core/decorators/swagger.js +52 -0
  15. package/dist/lib/core/decorators/swagger.js.map +1 -0
  16. package/{build → dist}/lib/core/server/index.js +272 -205
  17. package/dist/lib/core/server/index.js.map +1 -0
  18. package/{build → dist}/lib/core/server/parser-factory.js +29 -7
  19. package/dist/lib/core/server/parser-factory.js.map +1 -0
  20. package/dist/lib/core/server/radix-router.js +65 -0
  21. package/dist/lib/core/server/radix-router.js.map +1 -0
  22. package/{build → dist}/lib/core/server/router.js +34 -0
  23. package/dist/lib/core/server/router.js.map +1 -0
  24. package/{build → dist}/lib/index.js +0 -1
  25. package/{build → dist}/lib/index.js.map +1 -1
  26. package/{build → dist}/tests/benchmark.test.js +38 -8
  27. package/{build → dist}/tests/benchmark.test.js.map +1 -1
  28. package/package.json +15 -10
  29. package/build/lib/core/decorators/context.d.ts +0 -5
  30. package/build/lib/core/decorators/context.js.map +0 -1
  31. package/build/lib/core/decorators/controller.d.ts +0 -1
  32. package/build/lib/core/decorators/controller.js +0 -10
  33. package/build/lib/core/decorators/controller.js.map +0 -1
  34. package/build/lib/core/decorators/headers.d.ts +0 -3
  35. package/build/lib/core/decorators/headers.js +0 -15
  36. package/build/lib/core/decorators/headers.js.map +0 -1
  37. package/build/lib/core/decorators/index.d.ts +0 -9
  38. package/build/lib/core/decorators/methods.d.ts +0 -5
  39. package/build/lib/core/decorators/methods.js +0 -25
  40. package/build/lib/core/decorators/methods.js.map +0 -1
  41. package/build/lib/core/decorators/middleware.d.ts +0 -2
  42. package/build/lib/core/decorators/middleware.js +0 -24
  43. package/build/lib/core/decorators/middleware.js.map +0 -1
  44. package/build/lib/core/decorators/statusCode.d.ts +0 -1
  45. package/build/lib/core/decorators/statusCode.js +0 -16
  46. package/build/lib/core/decorators/statusCode.js.map +0 -1
  47. package/build/lib/core/decorators/swagger.d.ts +0 -2
  48. package/build/lib/core/decorators/swagger.js +0 -18
  49. package/build/lib/core/decorators/swagger.js.map +0 -1
  50. package/build/lib/core/server/index.d.ts +0 -312
  51. package/build/lib/core/server/index.js.map +0 -1
  52. package/build/lib/core/server/parser-factory.d.ts +0 -24
  53. package/build/lib/core/server/parser-factory.js.map +0 -1
  54. package/build/lib/core/server/router.d.ts +0 -79
  55. package/build/lib/core/server/router.js.map +0 -1
  56. package/build/lib/core/types/index.d.ts +0 -168
  57. package/build/lib/index.d.ts +0 -11
  58. package/build/tests/benchmark.test.d.ts +0 -1
  59. /package/{build → dist}/lib/core/decorators/index.js +0 -0
  60. /package/{build → dist}/lib/core/decorators/index.js.map +0 -0
  61. /package/{build → dist}/lib/core/types/index.js +0 -0
  62. /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 {};
@@ -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