@bool-ts/core 2.2.4 → 2.3.0

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 (69) hide show
  1. package/dist/constants/index.d.ts +3 -0
  2. package/dist/constants/keys.d.ts +34 -0
  3. package/dist/constants/objects.d.ts +505 -0
  4. package/dist/decorators/arguments.d.ts +2 -3
  5. package/dist/decorators/container.d.ts +5 -1
  6. package/dist/decorators/controller.d.ts +1 -1
  7. package/dist/decorators/guard.d.ts +1 -1
  8. package/dist/decorators/inject.d.ts +1 -1
  9. package/dist/decorators/injectable.d.ts +1 -1
  10. package/dist/decorators/interceptor.d.ts +1 -1
  11. package/dist/decorators/middleware.d.ts +1 -1
  12. package/dist/decorators/module.d.ts +1 -1
  13. package/dist/decorators/webSocket.d.ts +1 -1
  14. package/dist/decorators/webSocketArguments.d.ts +1 -1
  15. package/dist/entities/application.d.ts +13 -83
  16. package/dist/entities/httpRoute.d.ts +0 -2
  17. package/dist/entities/httpRouter.d.ts +29 -3
  18. package/dist/entities/httpRouterGroup.d.ts +5 -1
  19. package/dist/entities/injector.d.ts +2 -2
  20. package/dist/http/clientError.d.ts +5 -35
  21. package/dist/http/serverError.d.ts +7 -19
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +6 -6
  24. package/dist/index.js.map +30 -28
  25. package/dist/interfaces/@types.d.ts +114 -0
  26. package/dist/interfaces/guard.d.ts +2 -1
  27. package/dist/interfaces/index.d.ts +2 -1
  28. package/dist/producers/factory.d.ts +1 -1
  29. package/dist/utils/asyncFunction.d.ts +1 -0
  30. package/dist/utils/colors.d.ts +30 -0
  31. package/dist/utils/functions.d.ts +1 -0
  32. package/dist/utils/index.d.ts +5 -0
  33. package/dist/utils/socket.d.ts +1 -0
  34. package/package.json +5 -4
  35. package/src/constants/index.ts +10 -0
  36. package/src/constants/objects.ts +291 -0
  37. package/src/decorators/arguments.ts +3 -5
  38. package/src/decorators/container.ts +40 -20
  39. package/src/decorators/controller.ts +2 -2
  40. package/src/decorators/guard.ts +2 -2
  41. package/src/decorators/http.ts +1 -1
  42. package/src/decorators/inject.ts +2 -2
  43. package/src/decorators/injectable.ts +2 -2
  44. package/src/decorators/interceptor.ts +2 -2
  45. package/src/decorators/middleware.ts +2 -2
  46. package/src/decorators/module.ts +2 -2
  47. package/src/decorators/webSocket.ts +2 -2
  48. package/src/decorators/webSocketArguments.ts +1 -1
  49. package/src/decorators/webSocketEvent.ts +1 -1
  50. package/src/entities/application.ts +1554 -1559
  51. package/src/entities/httpRoute.ts +1 -4
  52. package/src/entities/httpRouter.ts +36 -6
  53. package/src/entities/httpRouterGroup.ts +16 -5
  54. package/src/entities/injector.ts +3 -3
  55. package/src/http/clientError.ts +16 -39
  56. package/src/http/serverError.ts +17 -22
  57. package/src/index.ts +12 -2
  58. package/src/interfaces/@types.ts +171 -0
  59. package/src/interfaces/guard.ts +7 -1
  60. package/src/interfaces/index.ts +24 -1
  61. package/src/producers/factory.ts +1 -1
  62. package/src/utils/constructor.ts +1 -0
  63. package/src/utils/functions.ts +13 -0
  64. package/src/{ultils → utils}/index.ts +1 -0
  65. /package/{src/ultils/constructor.ts → dist/utils/constructor.d.ts} +0 -0
  66. /package/src/{keys/index.ts → constants/keys.ts} +0 -0
  67. /package/src/{ultils → utils}/asyncFunction.ts +0 -0
  68. /package/src/{ultils → utils}/colors.ts +0 -0
  69. /package/src/{ultils → utils}/socket.ts +0 -0
@@ -8,12 +8,9 @@ export type THttpRouteModel<T = unknown> = Readonly<{
8
8
  argumentsMetadata: TArgumentsMetadataCollection;
9
9
  }>;
10
10
 
11
- const BASE_URL = "http://www.booljs.com";
11
+ const BASE_URL = "https://www.booljs.com";
12
12
 
13
13
  export class HttpRoute {
14
- public static rootPattern = ":([a-z0-9A-Z_-]{1,})";
15
- public static innerRootPattern = "([a-z0-9A-Z_-]{1,})";
16
-
17
14
  public readonly alias: string;
18
15
 
19
16
  #map = new Map<THttpMethods, THttpRouteModel>();
@@ -1,12 +1,34 @@
1
+ import type {
2
+ TCloseInterceptorHandlers,
3
+ TGuardHandlers,
4
+ TOpenInterceptorHandlers
5
+ } from "../interfaces";
6
+
1
7
  import HttpRoute from "./httpRoute";
2
8
 
3
9
  export class HttpRouter {
4
10
  public readonly alias: string;
5
11
 
6
- private _routes: Map<string, HttpRoute> = new Map();
12
+ #routes: Map<string, HttpRoute> = new Map();
13
+ #guardHandlers: TGuardHandlers;
14
+ #openInterceptorHandlers: TOpenInterceptorHandlers;
15
+ #closeInterceptorHandlers: TCloseInterceptorHandlers;
7
16
 
8
- constructor({ alias }: { alias: string }) {
17
+ constructor({
18
+ alias,
19
+ guardHandlers: guards = [],
20
+ openInterceptorHandlers = [],
21
+ closeInterceptorHandlers = []
22
+ }: {
23
+ alias: string;
24
+ guardHandlers?: TGuardHandlers;
25
+ openInterceptorHandlers?: TOpenInterceptorHandlers;
26
+ closeInterceptorHandlers?: TCloseInterceptorHandlers;
27
+ }) {
9
28
  this.alias = this._thinAlias(alias);
29
+ this.#guardHandlers = guards;
30
+ this.#openInterceptorHandlers = openInterceptorHandlers;
31
+ this.#closeInterceptorHandlers = closeInterceptorHandlers;
10
32
  }
11
33
 
12
34
  /**
@@ -14,13 +36,13 @@ export class HttpRouter {
14
36
  * @param alias
15
37
  * @returns
16
38
  */
17
- public route(alias: string) {
39
+ public route({ alias }: { alias: string }) {
18
40
  const thinAlias = this._thinAlias(`${this.alias}/${alias}`);
19
- const route = this._routes.get(thinAlias);
41
+ const route = this.#routes.get(thinAlias);
20
42
  const newRoute = !route ? new HttpRoute({ alias: `${this.alias}/${alias}` }) : route;
21
43
 
22
44
  if (!route) {
23
- this._routes.set(thinAlias, newRoute);
45
+ this.#routes.set(thinAlias, newRoute);
24
46
  }
25
47
 
26
48
  return newRoute;
@@ -41,7 +63,15 @@ export class HttpRouter {
41
63
  *
42
64
  */
43
65
  get routes() {
44
- return this._routes;
66
+ return this.#routes;
67
+ }
68
+
69
+ get pipes() {
70
+ return Object.freeze({
71
+ guardHandlers: [...this.#guardHandlers],
72
+ openInterceptorHandlers: [...this.#openInterceptorHandlers],
73
+ closeInterceptorHandlers: [...this.#closeInterceptorHandlers]
74
+ });
45
75
  }
46
76
  }
47
77
 
@@ -1,17 +1,22 @@
1
1
  import type { THttpMethods } from "../http";
2
+ import type {
3
+ TCloseInterceptorHandlers,
4
+ TGuardHandlers,
5
+ TOpenInterceptorHandlers
6
+ } from "../interfaces";
2
7
  import type { THttpRouteModel } from "./httpRoute";
3
8
  import type { HttpRouter } from "./httpRouter";
4
9
 
5
10
  export class HttpRouterGroup {
6
- private _routers: Map<string, HttpRouter> = new Map();
11
+ #routers: Map<string, HttpRouter> = new Map();
7
12
 
8
13
  public add(...routers: Array<HttpRouter>) {
9
14
  for (const router of routers) {
10
- if (this._routers.has(router.alias)) {
15
+ if (this.#routers.has(router.alias)) {
11
16
  continue;
12
17
  }
13
18
 
14
- this._routers.set(router.alias, router);
19
+ this.#routers.set(router.alias, router);
15
20
  }
16
21
 
17
22
  return this;
@@ -26,8 +31,11 @@ export class HttpRouterGroup {
26
31
  public find({ pathname, method }: { pathname: string; method: THttpMethods }): Readonly<{
27
32
  parameters: Record<string, string | undefined>;
28
33
  model: THttpRouteModel;
34
+ guardHandlers: TGuardHandlers;
35
+ openInterceptorHandlers: TOpenInterceptorHandlers;
36
+ closeInterceptorHandlers: TCloseInterceptorHandlers;
29
37
  }> | null {
30
- for (const router of this._routers.values()) {
38
+ for (const router of this.#routers.values()) {
31
39
  for (const route of router.routes.values()) {
32
40
  const testResult = route.test({ pathname });
33
41
 
@@ -41,7 +49,10 @@ export class HttpRouterGroup {
41
49
  continue;
42
50
  }
43
51
 
44
- return execResult;
52
+ return Object.freeze({
53
+ ...execResult,
54
+ ...router.pipes
55
+ });
45
56
  }
46
57
  }
47
58
 
@@ -7,13 +7,13 @@ import {
7
7
  interceptorKey,
8
8
  middlewareKey,
9
9
  webSocketKey
10
- } from "../keys";
10
+ } from "../constants/keys";
11
11
 
12
12
  type TDefinition<T = any> = { new (...args: any[]): T } | string | symbol;
13
13
 
14
14
  interface IInjector {
15
15
  set(key: TDefinition, value: any): void;
16
- get<T>(definition: TDefinition): T;
16
+ get<T>(definition: TDefinition): T | undefined;
17
17
  }
18
18
 
19
19
  export class Injector implements IInjector {
@@ -68,7 +68,7 @@ export class Injector implements IInjector {
68
68
 
69
69
  this._mapper.set(definition, instance);
70
70
 
71
- return instance;
71
+ return instance as T;
72
72
  }
73
73
 
74
74
  /**
@@ -1,48 +1,25 @@
1
- export const httpClientErrors = Object.freeze({
2
- 400: "BAD_REQUEST",
3
- 401: "UNAUTHORIZED",
4
- 402: "PAYMENT_REQUIRED",
5
- 403: "FORBIDDEN",
6
- 404: "NOT_FOUND",
7
- 405: "METHOD_NOT_ALLOWED",
8
- 406: "NOT_ACCEPTABLE",
9
- 407: "PROXY_AUTHENCATION_REQUIRED",
10
- 408: "REQUEST_TIMEOUT",
11
- 409: "CONFLICT",
12
- 410: "GONE",
13
- 411: "LENGTH_REQUIRED",
14
- 412: "PRECONDITION_FAILED",
15
- 413: "PAYLOAD_TOO_LARGE",
16
- 414: "URI_TOO_LONG",
17
- 415: "UNSUPPORTED_MEDIA_TYPE",
18
- 416: "RANGE_NOT_SATISFIABLE",
19
- 417: "EXPECTATION_FAILED",
20
- 418: "IM_A_TEAPOT",
21
- 421: "MISDIRECTED_REQUEST",
22
- 422: "UNPROCESSABLE_ENTITY",
23
- 423: "LOCKED",
24
- 424: "FAILED_DEPENDENCY",
25
- 425: "TOO_EARLY_",
26
- 426: "UPGRAGE_REQUIRED",
27
- 428: "PRECONDITION_REQUIRED",
28
- 429: "TOO_MANY_REQUESTS",
29
- 431: "REQUEST_HEADER_FIELDS_TOO_LARGE",
30
- 451: "UNAVAILABLE_FOR_LEGAL_REASONS"
31
- });
1
+ import type { TClientErrorStatuses } from "../constants";
32
2
 
33
- export class HttpClientError<
34
- T extends keyof typeof httpClientErrors = keyof typeof httpClientErrors,
35
- K = unknown
36
- > extends Error {
37
- public readonly httpCode: T;
38
- public readonly message: (typeof httpClientErrors)[T] | string;
3
+ import { inferStatusText } from "../utils";
4
+
5
+ export class HttpClientError<K = unknown> extends Error {
6
+ public readonly httpCode: TClientErrorStatuses;
7
+ public readonly message: string;
39
8
  public readonly data: K | undefined;
40
9
 
41
- constructor({ httpCode, data, message }: { httpCode: T; data?: K; message?: string }) {
10
+ constructor({
11
+ httpCode,
12
+ data,
13
+ message
14
+ }: {
15
+ httpCode: TClientErrorStatuses;
16
+ data?: K;
17
+ message?: string;
18
+ }) {
42
19
  super();
43
20
 
44
21
  this.httpCode = httpCode;
45
- this.message = !message?.trim() ? httpClientErrors[httpCode] : message.trim();
22
+ this.message = !message?.trim() ? inferStatusText(httpCode) : message.trim();
46
23
  this.data = data;
47
24
  }
48
25
  }
@@ -1,30 +1,25 @@
1
- export const httpServerErrors = Object.freeze({
2
- 500: "INTERNAL_SERVER_ERROR",
3
- 501: "NOT_IMPLEMENTED",
4
- 502: "BAD_GATEWAY",
5
- 503: "SERVICE_UNAVAILABLE",
6
- 504: "GATEWAY_TIMEOUT",
7
- 505: "HTTP_VERSION_NOT_SUPPORTED",
8
- 506: "VARIANT_ALSO_NEGOTIATES",
9
- 507: "INSUFFICIENT_STORAGE",
10
- 508: "LOOP_DETECTED",
11
- 510: "NOT_EXTENDED",
12
- 511: "NETWORK_AUTHENTICATION_REQUIRED"
13
- });
1
+ import type { TServerErrorStatuses } from "../constants";
14
2
 
15
- export class HttpServerError<
16
- T extends keyof typeof httpServerErrors = keyof typeof httpServerErrors,
17
- K = any
18
- > extends Error {
19
- public readonly httpCode: T;
20
- public readonly message: (typeof httpServerErrors)[T] | string;
21
- public readonly data: K | undefined;
3
+ import { inferStatusText } from "../utils";
22
4
 
23
- constructor({ httpCode, data, message }: { httpCode: T; data?: K; message?: string }) {
5
+ export class HttpServerError<T = any> extends Error {
6
+ public readonly httpCode: TServerErrorStatuses;
7
+ public readonly message: string;
8
+ public readonly data: T | undefined;
9
+
10
+ constructor({
11
+ httpCode,
12
+ data,
13
+ message
14
+ }: {
15
+ httpCode: TServerErrorStatuses;
16
+ data?: T;
17
+ message?: string;
18
+ }) {
24
19
  super();
25
20
 
26
21
  this.httpCode = httpCode;
27
- this.message = !message?.trim() ? httpServerErrors[httpCode] : message.trim();
22
+ this.message = !message?.trim() ? inferStatusText(httpCode) : message.trim();
28
23
  this.data = data;
29
24
  }
30
25
  }
package/src/index.ts CHANGED
@@ -1,10 +1,20 @@
1
1
  import "reflect-metadata";
2
2
 
3
3
  export type { THttpRouteModel } from "./entities";
4
+ export type {
5
+ IContainer,
6
+ IContext,
7
+ IController,
8
+ ICustomValidator,
9
+ IGuard,
10
+ IInterceptor,
11
+ IMiddleware,
12
+ IModule,
13
+ IWebSocket
14
+ } from "./interfaces";
4
15
 
16
+ export * from "./constants";
5
17
  export * from "./decorators";
6
18
  export * from "./entities";
7
19
  export * from "./http";
8
- export * from "./interfaces";
9
- export * as Keys from "./keys";
10
20
  export * from "./producers";
@@ -0,0 +1,171 @@
1
+ import type { BunFile } from "bun";
2
+ import type { TArgumentsMetadataCollection, TWebSocketEventHandlerMetadata } from "../decorators";
3
+ import type { HttpRouterGroup, THttpRouteModel, WebSocketRouterGroup } from "../entities";
4
+ import type { THttpMethods } from "../http";
5
+ import type { ICustomValidator } from "./customValidator";
6
+ import type { IGuard } from "./guard";
7
+ import type { IInterceptor } from "./interceptor";
8
+ import type { IMiddleware } from "./middleware";
9
+
10
+ import { parse as QsParse } from "qs";
11
+
12
+ export type THandlerMetadata<
13
+ TClass extends Object = Object,
14
+ TFuncName extends keyof TClass = keyof TClass,
15
+ TFunc = TClass[TFuncName]
16
+ > = Readonly<{
17
+ class: TClass;
18
+ func: TFunc;
19
+ funcName: TFuncName;
20
+ argumentsMetadata: TArgumentsMetadataCollection;
21
+ }>;
22
+
23
+ export type TStartMiddlewareHandlers = THandlerMetadata<
24
+ IMiddleware,
25
+ "start",
26
+ NonNullable<IMiddleware["start"]>
27
+ >[];
28
+
29
+ export type TEndMiddlewareHandlers = THandlerMetadata<
30
+ IMiddleware,
31
+ "end",
32
+ NonNullable<IMiddleware["end"]>
33
+ >[];
34
+
35
+ export type TGuardHandlers = THandlerMetadata<IGuard, "enforce", NonNullable<IGuard["enforce"]>>[];
36
+
37
+ export type TOpenInterceptorHandlers = THandlerMetadata<
38
+ IInterceptor,
39
+ "open",
40
+ NonNullable<IInterceptor["open"]>
41
+ >[];
42
+
43
+ export type TCloseInterceptorHandlers = THandlerMetadata<
44
+ IInterceptor,
45
+ "close",
46
+ NonNullable<IInterceptor["close"]>
47
+ >[];
48
+
49
+ export type TControllerHandlers = THttpRouteModel[];
50
+
51
+ export type TStartMiddlewaresPipe = {
52
+ type: "START_MIDDLEWARES";
53
+ handlers: TStartMiddlewareHandlers;
54
+ };
55
+
56
+ export type TEndMiddlewaresPipe = {
57
+ type: "END_MIDDLEWARES";
58
+ handlers: TEndMiddlewareHandlers;
59
+ };
60
+
61
+ export type TGuardsPipe = {
62
+ type: "GUARDS";
63
+ handlers: TGuardHandlers;
64
+ };
65
+
66
+ export type TOpenInterceptorsPipe = {
67
+ type: "OPEN_INTERCEPTORS";
68
+ handlers: TOpenInterceptorHandlers;
69
+ };
70
+
71
+ export type TCloseInterceptorsPipe = {
72
+ type: "CLOSE_INTERCEPTORS";
73
+ handlers: TCloseInterceptorHandlers;
74
+ };
75
+
76
+ export type TControllerPipe = {
77
+ type: "CONTROLLER";
78
+ handlers?: undefined;
79
+ };
80
+
81
+ export type TPipesEnforcerUnion =
82
+ | TStartMiddlewaresPipe
83
+ | TEndMiddlewaresPipe
84
+ | TGuardsPipe
85
+ | TOpenInterceptorsPipe
86
+ | TCloseInterceptorsPipe
87
+ | TControllerPipe;
88
+
89
+ export type TParamsType = Record<string, string>;
90
+
91
+ export type TApplicationOptions<AllowedMethods extends Array<THttpMethods> = Array<THttpMethods>> =
92
+ Required<{
93
+ port: number;
94
+ }> &
95
+ Partial<{
96
+ config: Record<string | symbol, any> | (() => Record<string | symbol, any>);
97
+ prefix: string;
98
+ debug: boolean;
99
+ log: Partial<{
100
+ methods: AllowedMethods;
101
+ }>;
102
+ queryParser: Parameters<typeof QsParse>[1];
103
+ static: Required<{
104
+ path: string;
105
+ }> &
106
+ Partial<{
107
+ headers: TParamsType;
108
+ cacheTimeInSeconds: number;
109
+ }>;
110
+ cors: Partial<{
111
+ credentials: boolean;
112
+ origins: string | Array<string>;
113
+ methods: Array<THttpMethods>;
114
+ headers: Array<string>;
115
+ }>;
116
+ pipelineStrategy: {
117
+ type: "SIMPLE";
118
+ targets: Partial<{
119
+ middlewares: "FIFO" | "FILO";
120
+ interceptors: "FIFO" | "FILO";
121
+ }>;
122
+ };
123
+ }>;
124
+
125
+ export type TStaticMap = Map<
126
+ string,
127
+ Readonly<{
128
+ expiredAt: Date;
129
+ file: BunFile;
130
+ }>
131
+ >;
132
+
133
+ export type TResolutedOptions = Readonly<{
134
+ allowLogsMethods: Array<THttpMethods>;
135
+ allowOrigins: Array<string>;
136
+ allowMethods: Array<THttpMethods>;
137
+ allowHeaders: Array<string>;
138
+ allowCredentials: boolean;
139
+ staticOption?: Required<{
140
+ path: string;
141
+ }> &
142
+ Partial<{
143
+ headers: TParamsType;
144
+ cacheTimeInSeconds: number;
145
+ }>;
146
+ pipelineStrategy: Required<{
147
+ startMiddlewares: "FIFO" | "FILO";
148
+ endMiddlewares: "FIFO" | "FILO";
149
+ openInterceptors: "FIFO" | "FILO";
150
+ closeInterceptors: "FIFO" | "FILO";
151
+ }>;
152
+ }>;
153
+
154
+ export type TWebSocketUpgradeData = {
155
+ pathname: string;
156
+ method: string;
157
+ query: Record<string, unknown>;
158
+ };
159
+
160
+ export type TPreLaunch =
161
+ | undefined
162
+ | Readonly<{
163
+ startMiddlewareHandlers: TStartMiddlewareHandlers;
164
+ endMiddlewareHandlers: TEndMiddlewareHandlers;
165
+ controllerRouterGroup: HttpRouterGroup;
166
+ webSocketHttpRouterGroup: HttpRouterGroup;
167
+ webSocketRouterGroup: WebSocketRouterGroup;
168
+ webSocketsMap: Map<string, TWebSocketEventHandlerMetadata>;
169
+ }>;
170
+
171
+ export type TValidator = undefined | ICustomValidator;
@@ -1,3 +1,9 @@
1
+ export type TGuardReturn =
2
+ | boolean
3
+ | "UNAUTHORIZATION"
4
+ | "FORBIDDEN"
5
+ | Promise<boolean | "UNAUTHORIZATION" | "FORBIDDEN">;
6
+
1
7
  export interface IGuard {
2
- enforce(...args: any[]): boolean | Promise<boolean>;
8
+ enforce(...args: any[]): TGuardReturn;
3
9
  }
@@ -1,8 +1,31 @@
1
+ export type {
2
+ TApplicationOptions,
3
+ TCloseInterceptorHandlers,
4
+ TCloseInterceptorsPipe,
5
+ TControllerHandlers,
6
+ TControllerPipe,
7
+ TEndMiddlewareHandlers,
8
+ TEndMiddlewaresPipe,
9
+ TGuardHandlers,
10
+ TGuardsPipe,
11
+ THandlerMetadata,
12
+ TOpenInterceptorHandlers,
13
+ TOpenInterceptorsPipe,
14
+ TParamsType,
15
+ TPipesEnforcerUnion,
16
+ TPreLaunch,
17
+ TResolutedOptions,
18
+ TStartMiddlewareHandlers,
19
+ TStartMiddlewaresPipe,
20
+ TStaticMap,
21
+ TValidator,
22
+ TWebSocketUpgradeData
23
+ } from "./@types";
1
24
  export type { IContainer } from "./container";
2
25
  export type { IContext, TContextOptions } from "./context";
3
26
  export type { IController } from "./controller";
4
27
  export type { ICustomValidator } from "./customValidator";
5
- export type { IGuard } from "./guard";
28
+ export type { IGuard, TGuardReturn } from "./guard";
6
29
  export type { IInterceptor } from "./interceptor";
7
30
  export type { IMiddleware } from "./middleware";
8
31
  export type { IModule } from "./module";
@@ -1,5 +1,5 @@
1
1
  import type { TArgumentsMetadataCollection } from "../decorators/arguments";
2
- import type { TConstructor } from "../ultils";
2
+ import type { TConstructor } from "../utils";
3
3
 
4
4
  import "reflect-metadata";
5
5
 
@@ -0,0 +1 @@
1
+ export type TConstructor<T, K extends any[] = any[]> = new (...args: K) => T;
@@ -0,0 +1,13 @@
1
+ import { Objects } from "../constants";
2
+
3
+ export const inferStatusText = (httpCode: number): string => {
4
+ for (const [_key, value] of Object.entries(Objects.httpStatuses)) {
5
+ if (value.status !== httpCode) {
6
+ continue;
7
+ }
8
+
9
+ return value.statusText;
10
+ }
11
+
12
+ return "Unknown error";
13
+ };
@@ -1,4 +1,5 @@
1
1
  export * from "./asyncFunction";
2
2
  export * from "./colors";
3
3
  export * from "./constructor";
4
+ export * from "./functions";
4
5
  export * from "./socket";
File without changes
File without changes
File without changes
File without changes