@expressots/core 2.9.1 → 2.11.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.
- package/lib/CHANGELOG.md +145 -89
- package/lib/cjs/application/{app-container.js → application-container.js} +95 -94
- package/lib/cjs/application/application-factory.js +39 -74
- package/lib/cjs/application/index.js +7 -7
- package/lib/cjs/common/{color-service.provider.js → color-codes.js} +46 -47
- package/lib/cjs/common/index.js +2 -2
- package/lib/cjs/common/{package-resolver.provider.js → package-resolver.js} +35 -35
- package/lib/cjs/common/{project-config.provider.js → project-config.js} +2 -2
- package/lib/cjs/console/console.js +60 -61
- package/lib/cjs/console/index.js +5 -5
- package/lib/cjs/container-module/container-module.js +111 -111
- package/lib/cjs/container-module/index.js +6 -6
- package/lib/cjs/controller/base-controller.js +74 -75
- package/lib/cjs/controller/index.js +5 -5
- package/lib/cjs/decorator/index.js +17 -17
- package/lib/cjs/decorator/scope-binding.js +44 -44
- package/lib/cjs/error/app-error.js +26 -26
- package/lib/cjs/error/error-handler-middleware.js +28 -28
- package/lib/cjs/error/index.js +9 -9
- package/lib/cjs/error/report.js +53 -54
- package/lib/cjs/error/status-code.js +89 -89
- package/lib/cjs/index.js +26 -26
- package/lib/cjs/middleware/index.js +32 -32
- package/lib/cjs/middleware/interfaces/body-parser.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/compression.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/cookie-parser.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/cookie-session/cookie-session.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/cookie-session/keygrip.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/cors.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/express-rate-limit.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/express-session.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/helmet.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/morgan.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/multer.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/serve-favicon.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/serve-static.interface.js +2 -2
- package/lib/cjs/middleware/middleware-resolver.js +72 -72
- package/lib/cjs/middleware/middleware-service.js +480 -481
- package/lib/cjs/provider/db-in-memory/db-in-memory.provider.js +82 -82
- package/lib/cjs/provider/dto-validator/dto-validator.provider.js +53 -53
- package/lib/cjs/provider/environment/env-validator.provider.js +98 -98
- package/lib/cjs/provider/index.js +13 -13
- package/lib/cjs/provider/logger/logger.provider.js +117 -117
- package/lib/cjs/provider/provider-manager.js +49 -50
- package/lib/cjs/render/handlebars.interface.js +2 -2
- package/lib/cjs/render/index.js +2 -2
- package/lib/cjs/render/render.type.js +2 -2
- package/lib/cjs/types/application/{app-container.d.ts → application-container.d.ts} +64 -62
- package/lib/cjs/types/application/application-factory.d.ts +19 -34
- package/lib/cjs/types/application/index.d.ts +2 -2
- package/lib/cjs/types/common/{color-service.provider.d.ts → color-codes.d.ts} +29 -29
- package/lib/cjs/types/common/index.d.ts +1 -1
- package/lib/cjs/types/common/{package-resolver.provider.d.ts → package-resolver.d.ts} +8 -8
- package/lib/cjs/types/common/{project-config.provider.d.ts → project-config.d.ts} +56 -56
- package/lib/cjs/types/console/console.d.ts +27 -27
- package/lib/cjs/types/console/index.d.ts +1 -1
- package/lib/cjs/types/container-module/container-module.d.ts +28 -28
- package/lib/cjs/types/container-module/index.d.ts +1 -1
- package/lib/cjs/types/controller/base-controller.d.ts +48 -48
- package/lib/cjs/types/controller/index.d.ts +1 -1
- package/lib/cjs/types/decorator/index.d.ts +1 -1
- package/lib/cjs/types/decorator/scope-binding.d.ts +33 -33
- package/lib/cjs/types/error/app-error.d.ts +29 -29
- package/lib/cjs/types/error/error-handler-middleware.d.ts +11 -11
- package/lib/cjs/types/error/index.d.ts +3 -3
- package/lib/cjs/types/error/report.d.ts +25 -25
- package/lib/cjs/types/error/status-code.d.ts +136 -136
- package/lib/cjs/types/index.d.ts +10 -10
- package/lib/cjs/types/middleware/index.d.ts +13 -13
- package/lib/cjs/types/middleware/interfaces/body-parser.interface.d.ts +33 -33
- package/lib/cjs/types/middleware/interfaces/compression.interface.d.ts +98 -98
- package/lib/cjs/types/middleware/interfaces/cookie-parser.interface.d.ts +9 -9
- package/lib/cjs/types/middleware/interfaces/cookie-session/cookie-session.interface.d.ts +57 -57
- package/lib/cjs/types/middleware/interfaces/cookie-session/keygrip.interface.d.ts +27 -27
- package/lib/cjs/types/middleware/interfaces/cors.interface.d.ts +57 -57
- package/lib/cjs/types/middleware/interfaces/express-rate-limit.interface.d.ts +292 -292
- package/lib/cjs/types/middleware/interfaces/express-session.interface.d.ts +207 -207
- package/lib/cjs/types/middleware/interfaces/helmet.interface.d.ts +210 -210
- package/lib/cjs/types/middleware/interfaces/morgan.interface.d.ts +40 -40
- package/lib/cjs/types/middleware/interfaces/multer.interface.d.ts +255 -255
- package/lib/cjs/types/middleware/interfaces/serve-favicon.interface.d.ts +11 -11
- package/lib/cjs/types/middleware/interfaces/serve-static.interface.d.ts +70 -70
- package/lib/cjs/types/middleware/middleware-resolver.d.ts +11 -11
- package/lib/cjs/types/middleware/middleware-service.d.ts +368 -368
- package/lib/cjs/types/provider/db-in-memory/db-in-memory.provider.d.ts +43 -43
- package/lib/cjs/types/provider/dto-validator/dto-validator.provider.d.ts +11 -11
- package/lib/cjs/types/provider/environment/env-validator.provider.d.ts +35 -35
- package/lib/cjs/types/provider/index.d.ts +5 -5
- package/lib/cjs/types/provider/logger/logger.provider.d.ts +54 -54
- package/lib/cjs/types/provider/provider-manager.d.ts +16 -16
- package/lib/cjs/types/render/handlebars.interface.d.ts +46 -46
- package/lib/cjs/types/render/index.d.ts +2 -2
- package/lib/cjs/types/render/render.type.d.ts +12 -12
- package/lib/package.json +16 -17
- package/package.json +16 -17
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enum representing different string patterns.
|
|
3
|
-
*
|
|
4
|
-
* - LOWER_CASE: Represents strings in all lowercase letters. E.g. "hello"
|
|
5
|
-
* - KEBAB_CASE: Represents strings separated by hyphens. E.g. "hello-world"
|
|
6
|
-
* - PASCAL_CASE: Represents strings where the first letter of each word is capitalized. E.g. "HelloWorld"
|
|
7
|
-
* - CAMEL_CASE: Represents strings where the first letter of the first word is lowercase and the first letter of subsequent words are capitalized. E.g. "helloWorld"
|
|
8
|
-
*/
|
|
9
|
-
declare const enum Pattern {
|
|
10
|
-
LOWER_CASE = "lowercase",
|
|
11
|
-
KEBAB_CASE = "kebab-case",
|
|
12
|
-
PASCAL_CASE = "PascalCase",
|
|
13
|
-
CAMEL_CASE = "camelCase"
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Interface describing configuration specific to Prisma provider.
|
|
17
|
-
*
|
|
18
|
-
* @property {string} schemaName - The name of the Prisma schema.
|
|
19
|
-
* @property {string} schemaPath - The path to the Prisma schema file.
|
|
20
|
-
* @property {string} entitiesPath - The path to the directory containing entities.
|
|
21
|
-
* @property {string} entityNamePattern - The naming convention to use for entity names.
|
|
22
|
-
*/
|
|
23
|
-
interface IProviders {
|
|
24
|
-
prisma?: {
|
|
25
|
-
schemaName: string;
|
|
26
|
-
schemaPath: string;
|
|
27
|
-
entitiesPath: string;
|
|
28
|
-
entityNamePattern: string;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The configuration object for the Expresso CLI.
|
|
33
|
-
*
|
|
34
|
-
* @property {Pattern} scaffoldPattern - The pattern to use when scaffolding files.
|
|
35
|
-
* @property {string} sourceRoot - The root directory for the source files.
|
|
36
|
-
* @property {boolean} opinionated - Whether or not to use the opinionated configuration.
|
|
37
|
-
* @property {IProviders} providers - Specific configuration for each provider added.
|
|
38
|
-
*
|
|
39
|
-
* @see [Doc](https://doc.expresso-ts.com/)
|
|
40
|
-
*/
|
|
41
|
-
interface ExpressoConfig {
|
|
42
|
-
scaffoldPattern: Pattern;
|
|
43
|
-
sourceRoot: string;
|
|
44
|
-
opinionated: boolean;
|
|
45
|
-
providers?: IProviders;
|
|
46
|
-
scaffoldSchematics?: {
|
|
47
|
-
entity?: string;
|
|
48
|
-
controller?: string;
|
|
49
|
-
usecase?: string;
|
|
50
|
-
dto?: string;
|
|
51
|
-
module?: string;
|
|
52
|
-
provider?: string;
|
|
53
|
-
middleware?: string;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export { ExpressoConfig, Pattern };
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing different string patterns.
|
|
3
|
+
*
|
|
4
|
+
* - LOWER_CASE: Represents strings in all lowercase letters. E.g. "hello"
|
|
5
|
+
* - KEBAB_CASE: Represents strings separated by hyphens. E.g. "hello-world"
|
|
6
|
+
* - PASCAL_CASE: Represents strings where the first letter of each word is capitalized. E.g. "HelloWorld"
|
|
7
|
+
* - CAMEL_CASE: Represents strings where the first letter of the first word is lowercase and the first letter of subsequent words are capitalized. E.g. "helloWorld"
|
|
8
|
+
*/
|
|
9
|
+
declare const enum Pattern {
|
|
10
|
+
LOWER_CASE = "lowercase",
|
|
11
|
+
KEBAB_CASE = "kebab-case",
|
|
12
|
+
PASCAL_CASE = "PascalCase",
|
|
13
|
+
CAMEL_CASE = "camelCase"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Interface describing configuration specific to Prisma provider.
|
|
17
|
+
*
|
|
18
|
+
* @property {string} schemaName - The name of the Prisma schema.
|
|
19
|
+
* @property {string} schemaPath - The path to the Prisma schema file.
|
|
20
|
+
* @property {string} entitiesPath - The path to the directory containing entities.
|
|
21
|
+
* @property {string} entityNamePattern - The naming convention to use for entity names.
|
|
22
|
+
*/
|
|
23
|
+
interface IProviders {
|
|
24
|
+
prisma?: {
|
|
25
|
+
schemaName: string;
|
|
26
|
+
schemaPath: string;
|
|
27
|
+
entitiesPath: string;
|
|
28
|
+
entityNamePattern: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The configuration object for the Expresso CLI.
|
|
33
|
+
*
|
|
34
|
+
* @property {Pattern} scaffoldPattern - The pattern to use when scaffolding files.
|
|
35
|
+
* @property {string} sourceRoot - The root directory for the source files.
|
|
36
|
+
* @property {boolean} opinionated - Whether or not to use the opinionated configuration.
|
|
37
|
+
* @property {IProviders} providers - Specific configuration for each provider added.
|
|
38
|
+
*
|
|
39
|
+
* @see [Doc](https://doc.expresso-ts.com/)
|
|
40
|
+
*/
|
|
41
|
+
interface ExpressoConfig {
|
|
42
|
+
scaffoldPattern: Pattern;
|
|
43
|
+
sourceRoot: string;
|
|
44
|
+
opinionated: boolean;
|
|
45
|
+
providers?: IProviders;
|
|
46
|
+
scaffoldSchematics?: {
|
|
47
|
+
entity?: string;
|
|
48
|
+
controller?: string;
|
|
49
|
+
usecase?: string;
|
|
50
|
+
dto?: string;
|
|
51
|
+
module?: string;
|
|
52
|
+
provider?: string;
|
|
53
|
+
middleware?: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export { ExpressoConfig, Pattern };
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface representing application message details for console output.
|
|
3
|
-
*/
|
|
4
|
-
interface IApplicationMessageToConsole {
|
|
5
|
-
appName: string;
|
|
6
|
-
appVersion: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* The Console class provides methods for displaying styled messages in the console.
|
|
10
|
-
* @provide Console
|
|
11
|
-
*/
|
|
12
|
-
declare class Console {
|
|
13
|
-
/**
|
|
14
|
-
* Print a message to the console with the specified color style.
|
|
15
|
-
* @param message - The message to be printed.
|
|
16
|
-
* @param colorStyle - The color style for the message.
|
|
17
|
-
*/
|
|
18
|
-
private printColor;
|
|
19
|
-
/**
|
|
20
|
-
* Display a message in the console with details about the running server.
|
|
21
|
-
* @param port - The port number the server is running on.
|
|
22
|
-
* @param environment - The server environment.
|
|
23
|
-
* @param consoleMessage - Optional application message details for console output.
|
|
24
|
-
*/
|
|
25
|
-
messageServer(port: number, environment: string, consoleMessage?: IApplicationMessageToConsole): Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
export { Console, IApplicationMessageToConsole };
|
|
1
|
+
/**
|
|
2
|
+
* Interface representing application message details for console output.
|
|
3
|
+
*/
|
|
4
|
+
interface IApplicationMessageToConsole {
|
|
5
|
+
appName: string;
|
|
6
|
+
appVersion: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The Console class provides methods for displaying styled messages in the console.
|
|
10
|
+
* @provide Console
|
|
11
|
+
*/
|
|
12
|
+
declare class Console {
|
|
13
|
+
/**
|
|
14
|
+
* Print a message to the console with the specified color style.
|
|
15
|
+
* @param message - The message to be printed.
|
|
16
|
+
* @param colorStyle - The color style for the message.
|
|
17
|
+
*/
|
|
18
|
+
private printColor;
|
|
19
|
+
/**
|
|
20
|
+
* Display a message in the console with details about the running server.
|
|
21
|
+
* @param port - The port number the server is running on.
|
|
22
|
+
* @param environment - The server environment.
|
|
23
|
+
* @param consoleMessage - Optional application message details for console output.
|
|
24
|
+
*/
|
|
25
|
+
messageServer(port: number, environment: string, consoleMessage?: IApplicationMessageToConsole): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export { Console, IApplicationMessageToConsole };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Console, IApplicationMessageToConsole } from "./console";
|
|
1
|
+
export { Console, IApplicationMessageToConsole } from "./console";
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { ContainerModule, interfaces } from "inversify";
|
|
2
|
-
/**
|
|
3
|
-
* The scope decorator is a higher order function that can be used to decorate a class with a binding type.
|
|
4
|
-
* @param binding An instance of interfaces.BindingScope which represents the binding type.
|
|
5
|
-
* @returns A decorator function that can be used to decorate a class with a binding type.
|
|
6
|
-
*/
|
|
7
|
-
declare const scope: (binding: interfaces.BindingScope) => (target: any) => void;
|
|
8
|
-
/**
|
|
9
|
-
* The BaseModule class provides methods for creating InversifyJS container modules.
|
|
10
|
-
* @provide BaseModule
|
|
11
|
-
*/
|
|
12
|
-
declare class BaseModule {
|
|
13
|
-
/**
|
|
14
|
-
* Create a map of symbols for the provided controllers.
|
|
15
|
-
* @param controllers - An array of controller classes.
|
|
16
|
-
* @returns A map of symbols mapped to controller constructor functions.
|
|
17
|
-
*/
|
|
18
|
-
private static createSymbols;
|
|
19
|
-
/**
|
|
20
|
-
* Create an InversifyJS ContainerModule for the provided controllers.
|
|
21
|
-
* @param controllers - An array of controller classes.
|
|
22
|
-
* @param scope - An optional binding scope to be used for all controllers.
|
|
23
|
-
* @returns A ContainerModule with the controller bindings.
|
|
24
|
-
*/
|
|
25
|
-
static createContainerModule(controllers: Array<any>, scope?: interfaces.BindingScope): ContainerModule;
|
|
26
|
-
}
|
|
27
|
-
declare const CreateModule: typeof BaseModule.createContainerModule;
|
|
28
|
-
export { CreateModule, scope };
|
|
1
|
+
import { ContainerModule, interfaces } from "inversify";
|
|
2
|
+
/**
|
|
3
|
+
* The scope decorator is a higher order function that can be used to decorate a class with a binding type.
|
|
4
|
+
* @param binding An instance of interfaces.BindingScope which represents the binding type.
|
|
5
|
+
* @returns A decorator function that can be used to decorate a class with a binding type.
|
|
6
|
+
*/
|
|
7
|
+
declare const scope: (binding: interfaces.BindingScope) => (target: any) => void;
|
|
8
|
+
/**
|
|
9
|
+
* The BaseModule class provides methods for creating InversifyJS container modules.
|
|
10
|
+
* @provide BaseModule
|
|
11
|
+
*/
|
|
12
|
+
declare class BaseModule {
|
|
13
|
+
/**
|
|
14
|
+
* Create a map of symbols for the provided controllers.
|
|
15
|
+
* @param controllers - An array of controller classes.
|
|
16
|
+
* @returns A map of symbols mapped to controller constructor functions.
|
|
17
|
+
*/
|
|
18
|
+
private static createSymbols;
|
|
19
|
+
/**
|
|
20
|
+
* Create an InversifyJS ContainerModule for the provided controllers.
|
|
21
|
+
* @param controllers - An array of controller classes.
|
|
22
|
+
* @param scope - An optional binding scope to be used for all controllers.
|
|
23
|
+
* @returns A ContainerModule with the controller bindings.
|
|
24
|
+
*/
|
|
25
|
+
static createContainerModule(controllers: Array<any>, scope?: interfaces.BindingScope): ContainerModule;
|
|
26
|
+
}
|
|
27
|
+
declare const CreateModule: typeof BaseModule.createContainerModule;
|
|
28
|
+
export { CreateModule, scope };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { CreateModule, scope } from "./container-module";
|
|
1
|
+
export { CreateModule, scope } from "./container-module";
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { Response } from "express";
|
|
2
|
-
import { Controller } from "@expressots/adapter-express";
|
|
3
|
-
/**
|
|
4
|
-
* The BaseController class is an abstract base class for controllers.
|
|
5
|
-
* It provides methods for handling use case calls and sending appropriate responses.
|
|
6
|
-
* @provide BaseController
|
|
7
|
-
*/
|
|
8
|
-
declare abstract class BaseController implements Controller {
|
|
9
|
-
/**
|
|
10
|
-
* Calls an asynchronous use case and sends an appropriate response based on the result.
|
|
11
|
-
* @param useCase - A promise representing the asynchronous use case to call.
|
|
12
|
-
* @param res - The Express response object.
|
|
13
|
-
* @param successStatusCode - The HTTP status code to return upon successful execution.
|
|
14
|
-
*/
|
|
15
|
-
protected callUseCaseAsync(useCase: Promise<any>, res: Response, successStatusCode: number): Promise<any>;
|
|
16
|
-
/**
|
|
17
|
-
* Calls a use case and sends an appropriate response based on the result.
|
|
18
|
-
* @param useCase - The use case to call.
|
|
19
|
-
* @param res - The Express response object.
|
|
20
|
-
* @param successStatusCode - The HTTP status code to return upon successful execution.
|
|
21
|
-
*/
|
|
22
|
-
protected callUseCase(useCase: any, res: Response, successStatusCode: number): any;
|
|
23
|
-
/**
|
|
24
|
-
* Synchronously renders a template with the given options using the Express `Response` object's render method.
|
|
25
|
-
*
|
|
26
|
-
* @protected
|
|
27
|
-
* @method callUseRender
|
|
28
|
-
*
|
|
29
|
-
* @param {Response} res - The Express `Response` object.
|
|
30
|
-
* @param {string} template - The name of the template to render.
|
|
31
|
-
* @param {Object} [options={}] - An optional object containing data to be passed to the template.
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
protected callUseRender(res: Response, template: string, options?: object): void;
|
|
35
|
-
/**
|
|
36
|
-
* Asynchronously renders a template with the given options using the Express `Response` object's render method.
|
|
37
|
-
*
|
|
38
|
-
* @protected
|
|
39
|
-
* @method callUseRenderAsync
|
|
40
|
-
*
|
|
41
|
-
* @param {Response} res - The Express `Response` object.
|
|
42
|
-
* @param {string} template - The name of the template to render.
|
|
43
|
-
* @param {Object} [options={}] - An optional object containing data to be passed to the template.
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
protected callUseRenderAsync(res: Response, template: string, options?: object): Promise<string>;
|
|
47
|
-
}
|
|
48
|
-
export { BaseController };
|
|
1
|
+
import { Response } from "express";
|
|
2
|
+
import { Controller } from "@expressots/adapter-express";
|
|
3
|
+
/**
|
|
4
|
+
* The BaseController class is an abstract base class for controllers.
|
|
5
|
+
* It provides methods for handling use case calls and sending appropriate responses.
|
|
6
|
+
* @provide BaseController
|
|
7
|
+
*/
|
|
8
|
+
declare abstract class BaseController implements Controller {
|
|
9
|
+
/**
|
|
10
|
+
* Calls an asynchronous use case and sends an appropriate response based on the result.
|
|
11
|
+
* @param useCase - A promise representing the asynchronous use case to call.
|
|
12
|
+
* @param res - The Express response object.
|
|
13
|
+
* @param successStatusCode - The HTTP status code to return upon successful execution.
|
|
14
|
+
*/
|
|
15
|
+
protected callUseCaseAsync(useCase: Promise<any>, res: Response, successStatusCode: number): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Calls a use case and sends an appropriate response based on the result.
|
|
18
|
+
* @param useCase - The use case to call.
|
|
19
|
+
* @param res - The Express response object.
|
|
20
|
+
* @param successStatusCode - The HTTP status code to return upon successful execution.
|
|
21
|
+
*/
|
|
22
|
+
protected callUseCase(useCase: any, res: Response, successStatusCode: number): any;
|
|
23
|
+
/**
|
|
24
|
+
* Synchronously renders a template with the given options using the Express `Response` object's render method.
|
|
25
|
+
*
|
|
26
|
+
* @protected
|
|
27
|
+
* @method callUseRender
|
|
28
|
+
*
|
|
29
|
+
* @param {Response} res - The Express `Response` object.
|
|
30
|
+
* @param {string} template - The name of the template to render.
|
|
31
|
+
* @param {Object} [options={}] - An optional object containing data to be passed to the template.
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
protected callUseRender(res: Response, template: string, options?: object): void;
|
|
35
|
+
/**
|
|
36
|
+
* Asynchronously renders a template with the given options using the Express `Response` object's render method.
|
|
37
|
+
*
|
|
38
|
+
* @protected
|
|
39
|
+
* @method callUseRenderAsync
|
|
40
|
+
*
|
|
41
|
+
* @param {Response} res - The Express `Response` object.
|
|
42
|
+
* @param {string} template - The name of the template to render.
|
|
43
|
+
* @param {Object} [options={}] - An optional object containing data to be passed to the template.
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
protected callUseRenderAsync(res: Response, template: string, options?: object): Promise<string>;
|
|
47
|
+
}
|
|
48
|
+
export { BaseController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { BaseController } from "./base-controller";
|
|
1
|
+
export { BaseController } from "./base-controller";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./scope-binding";
|
|
1
|
+
export * from "./scope-binding";
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provides a singleton binding for the given identifier.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* Singleton binding ensures that the same instance of a dependency is reused within the entire container.
|
|
6
|
-
*
|
|
7
|
-
* @param identifier - The identifier (e.g., symbol, string, class) for the dependency being registered.
|
|
8
|
-
* @returns A fluent interface for further configuring the binding.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* @provideSingleton(ServiceIdentifier)
|
|
13
|
-
* class MyService {}
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
declare const provideSingleton: (identifier: any) => (target: any) => any;
|
|
17
|
-
/**
|
|
18
|
-
* Provides a transient binding for the given identifier.
|
|
19
|
-
*
|
|
20
|
-
* @remarks
|
|
21
|
-
* Transient binding ensures that a new instance of a dependency is created every time it is resolved.
|
|
22
|
-
*
|
|
23
|
-
* @param identifier - The identifier (e.g., symbol, string, class) for the dependency being registered.
|
|
24
|
-
* @returns A fluent interface for further configuring the binding.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* @provideTransient(ServiceIdentifier)
|
|
29
|
-
* class MyService {}
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
declare const provideTransient: (identifier: any) => (target: any) => any;
|
|
33
|
-
export { provideSingleton, provideTransient };
|
|
1
|
+
/**
|
|
2
|
+
* Provides a singleton binding for the given identifier.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Singleton binding ensures that the same instance of a dependency is reused within the entire container.
|
|
6
|
+
*
|
|
7
|
+
* @param identifier - The identifier (e.g., symbol, string, class) for the dependency being registered.
|
|
8
|
+
* @returns A fluent interface for further configuring the binding.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* @provideSingleton(ServiceIdentifier)
|
|
13
|
+
* class MyService {}
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare const provideSingleton: (identifier: any) => (target: any) => any;
|
|
17
|
+
/**
|
|
18
|
+
* Provides a transient binding for the given identifier.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Transient binding ensures that a new instance of a dependency is created every time it is resolved.
|
|
22
|
+
*
|
|
23
|
+
* @param identifier - The identifier (e.g., symbol, string, class) for the dependency being registered.
|
|
24
|
+
* @returns A fluent interface for further configuring the binding.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* @provideTransient(ServiceIdentifier)
|
|
29
|
+
* class MyService {}
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare const provideTransient: (identifier: any) => (target: any) => any;
|
|
33
|
+
export { provideSingleton, provideTransient };
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The AppError class extends the built-in Error class in JavaScript,
|
|
3
|
-
* providing additional properties to manage custom application errors.
|
|
4
|
-
* It captures detailed information about the error, including a status code
|
|
5
|
-
* and an optional service identifier, which can be useful for error handling
|
|
6
|
-
* and logging within the application.
|
|
7
|
-
*
|
|
8
|
-
* @extends {Error}
|
|
9
|
-
*/
|
|
10
|
-
declare class AppError extends Error {
|
|
11
|
-
/**
|
|
12
|
-
* The HTTP status code associated with the error.
|
|
13
|
-
* Commonly used to define the HTTP response status code.
|
|
14
|
-
*/
|
|
15
|
-
statusCode: number;
|
|
16
|
-
/**
|
|
17
|
-
* The service identifier associated with the error.
|
|
18
|
-
* This property can be used to trace the origin of the error in the application.
|
|
19
|
-
* It is optional and can be left undefined.
|
|
20
|
-
*/
|
|
21
|
-
service?: string;
|
|
22
|
-
/**
|
|
23
|
-
* @param {string} message - The error message to be displayed.
|
|
24
|
-
* @param {number} [statusCode=500] - The HTTP status code associated with the error (default: 500).
|
|
25
|
-
* @param {string} [service] - The service identifier associated with the error.
|
|
26
|
-
*/
|
|
27
|
-
constructor(message: string, statusCode?: number, service?: string);
|
|
28
|
-
}
|
|
29
|
-
export { AppError };
|
|
1
|
+
/**
|
|
2
|
+
* The AppError class extends the built-in Error class in JavaScript,
|
|
3
|
+
* providing additional properties to manage custom application errors.
|
|
4
|
+
* It captures detailed information about the error, including a status code
|
|
5
|
+
* and an optional service identifier, which can be useful for error handling
|
|
6
|
+
* and logging within the application.
|
|
7
|
+
*
|
|
8
|
+
* @extends {Error}
|
|
9
|
+
*/
|
|
10
|
+
declare class AppError extends Error {
|
|
11
|
+
/**
|
|
12
|
+
* The HTTP status code associated with the error.
|
|
13
|
+
* Commonly used to define the HTTP response status code.
|
|
14
|
+
*/
|
|
15
|
+
statusCode: number;
|
|
16
|
+
/**
|
|
17
|
+
* The service identifier associated with the error.
|
|
18
|
+
* This property can be used to trace the origin of the error in the application.
|
|
19
|
+
* It is optional and can be left undefined.
|
|
20
|
+
*/
|
|
21
|
+
service?: string;
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} message - The error message to be displayed.
|
|
24
|
+
* @param {number} [statusCode=500] - The HTTP status code associated with the error (default: 500).
|
|
25
|
+
* @param {string} [service] - The service identifier associated with the error.
|
|
26
|
+
*/
|
|
27
|
+
constructor(message: string, statusCode?: number, service?: string);
|
|
28
|
+
}
|
|
29
|
+
export { AppError };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from "express";
|
|
2
|
-
/**
|
|
3
|
-
* errorHandler is a custom Express error-handling middleware function.
|
|
4
|
-
* It logs the error, sets the status code, and sends a JSON response containing the status code and error message.
|
|
5
|
-
* @param error - An instance of IAppError containing error details.
|
|
6
|
-
* @param req - The Express request object.
|
|
7
|
-
* @param res - The Express response object.
|
|
8
|
-
* @param next - The Express next function for passing control to the next middleware function.
|
|
9
|
-
*/
|
|
10
|
-
declare function defaultErrorHandler(error: Error, req: Request, res: Response, next: NextFunction): void;
|
|
11
|
-
export default defaultErrorHandler;
|
|
1
|
+
import { NextFunction, Request, Response } from "express";
|
|
2
|
+
/**
|
|
3
|
+
* errorHandler is a custom Express error-handling middleware function.
|
|
4
|
+
* It logs the error, sets the status code, and sends a JSON response containing the status code and error message.
|
|
5
|
+
* @param error - An instance of IAppError containing error details.
|
|
6
|
+
* @param req - The Express request object.
|
|
7
|
+
* @param res - The Express response object.
|
|
8
|
+
* @param next - The Express next function for passing control to the next middleware function.
|
|
9
|
+
*/
|
|
10
|
+
declare function defaultErrorHandler(error: Error, req: Request, res: Response, next: NextFunction): void;
|
|
11
|
+
export default defaultErrorHandler;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { StatusCode } from "./status-code";
|
|
2
|
-
export { Report } from "./report";
|
|
3
|
-
export { AppError } from "./app-error";
|
|
1
|
+
export { StatusCode } from "./status-code";
|
|
2
|
+
export { Report } from "./report";
|
|
3
|
+
export { AppError } from "./app-error";
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { AppError } from "./app-error";
|
|
2
|
-
/**
|
|
3
|
-
* Report class is a utility class to manage and log errors within the application.
|
|
4
|
-
* It is responsible for creating a standardized error object, logging it,
|
|
5
|
-
* and then throwing the error for further handling.
|
|
6
|
-
*/
|
|
7
|
-
declare class Report {
|
|
8
|
-
static stack: string;
|
|
9
|
-
private logger;
|
|
10
|
-
constructor();
|
|
11
|
-
/**
|
|
12
|
-
* The Error method is responsible for generating a standardized error object,
|
|
13
|
-
* logging the error, and then throwing it for further handling.
|
|
14
|
-
* The error thrown is of the custom type AppError, which extends the built-in Error class.
|
|
15
|
-
*
|
|
16
|
-
* @param error - An instance of Error or a string that describes the error.
|
|
17
|
-
* @param statusCode - The HTTP status code associated with the error (default is 500).
|
|
18
|
-
* @param service - The service name associated with the error. If not specified,
|
|
19
|
-
* it defaults to the name of the calling function.
|
|
20
|
-
*
|
|
21
|
-
* @throws An object of the custom type AppError, which includes details about the error.
|
|
22
|
-
*/
|
|
23
|
-
error(error: Error | string, statusCode?: number, service?: string): AppError;
|
|
24
|
-
}
|
|
25
|
-
export { Report };
|
|
1
|
+
import { AppError } from "./app-error";
|
|
2
|
+
/**
|
|
3
|
+
* Report class is a utility class to manage and log errors within the application.
|
|
4
|
+
* It is responsible for creating a standardized error object, logging it,
|
|
5
|
+
* and then throwing the error for further handling.
|
|
6
|
+
*/
|
|
7
|
+
declare class Report {
|
|
8
|
+
static stack: string;
|
|
9
|
+
private logger;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* The Error method is responsible for generating a standardized error object,
|
|
13
|
+
* logging the error, and then throwing it for further handling.
|
|
14
|
+
* The error thrown is of the custom type AppError, which extends the built-in Error class.
|
|
15
|
+
*
|
|
16
|
+
* @param error - An instance of Error or a string that describes the error.
|
|
17
|
+
* @param statusCode - The HTTP status code associated with the error (default is 500).
|
|
18
|
+
* @param service - The service name associated with the error. If not specified,
|
|
19
|
+
* it defaults to the name of the calling function.
|
|
20
|
+
*
|
|
21
|
+
* @throws An object of the custom type AppError, which includes details about the error.
|
|
22
|
+
*/
|
|
23
|
+
error(error: Error | string, statusCode?: number, service?: string): AppError;
|
|
24
|
+
}
|
|
25
|
+
export { Report };
|