@expressots/adapter-express 1.8.1 → 3.0.0-beta.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 (41) hide show
  1. package/lib/CHANGELOG.md +157 -134
  2. package/lib/cjs/adapter-express/application-express.base.js +2 -12
  3. package/lib/cjs/adapter-express/application-express.js +132 -52
  4. package/lib/cjs/adapter-express/application-express.types.js +0 -20
  5. package/lib/cjs/adapter-express/express-utils/base-middleware.js +2 -2
  6. package/lib/cjs/adapter-express/express-utils/constants.js +1 -3
  7. package/lib/cjs/adapter-express/express-utils/decorators.js +48 -17
  8. package/lib/cjs/adapter-express/express-utils/http-status-middleware.js +10 -5
  9. package/lib/cjs/adapter-express/express-utils/utils.js +3 -0
  10. package/lib/cjs/adapter-express/index.js +3 -1
  11. package/lib/cjs/adapter-express/render/constants.js +40 -0
  12. package/lib/cjs/adapter-express/render/engine.js +52 -11
  13. package/lib/cjs/adapter-express/render/index.js +0 -3
  14. package/lib/cjs/di/di.interfaces.js +10 -0
  15. package/lib/cjs/types/adapter-express/application-express.base.d.ts +17 -0
  16. package/lib/cjs/types/adapter-express/application-express.d.ts +58 -23
  17. package/lib/cjs/types/adapter-express/application-express.types.d.ts +1 -41
  18. package/lib/cjs/types/adapter-express/express-utils/base-middleware.d.ts +1 -1
  19. package/lib/cjs/types/adapter-express/express-utils/constants.d.ts +1 -1
  20. package/lib/cjs/types/adapter-express/express-utils/decorators.d.ts +34 -7
  21. package/lib/cjs/types/adapter-express/express-utils/http-status-middleware.d.ts +2 -0
  22. package/lib/cjs/types/adapter-express/express-utils/interfaces.d.ts +1 -1
  23. package/lib/cjs/types/adapter-express/express-utils/inversify-express-server.d.ts +1 -1
  24. package/lib/cjs/types/adapter-express/express-utils/utils.d.ts +1 -1
  25. package/lib/cjs/types/adapter-express/index.d.ts +1 -2
  26. package/lib/cjs/types/adapter-express/render/constants.d.ts +26 -0
  27. package/lib/cjs/types/adapter-express/render/engine.d.ts +14 -22
  28. package/lib/cjs/types/adapter-express/render/index.d.ts +4 -4
  29. package/lib/cjs/types/di/di.interfaces.d.ts +289 -0
  30. package/lib/package.json +11 -16
  31. package/package.json +11 -16
  32. package/lib/cjs/adapter-express/application-express.interface.js +0 -2
  33. package/lib/cjs/adapter-express/render/ejs/ejs.config.js +0 -37
  34. package/lib/cjs/adapter-express/render/ejs/ejs.types.js +0 -3
  35. package/lib/cjs/adapter-express/render/handlebars/hbs.config.js +0 -38
  36. package/lib/cjs/adapter-express/render/pug/pug.config.js +0 -25
  37. package/lib/cjs/types/adapter-express/application-express.interface.d.ts +0 -20
  38. package/lib/cjs/types/adapter-express/render/ejs/ejs.config.d.ts +0 -21
  39. package/lib/cjs/types/adapter-express/render/ejs/ejs.types.d.ts +0 -169
  40. package/lib/cjs/types/adapter-express/render/handlebars/hbs.config.d.ts +0 -20
  41. package/lib/cjs/types/adapter-express/render/pug/pug.config.d.ts +0 -17
@@ -1,15 +1,56 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Engine = void 0;
3
+ exports.setEngineEjs = setEngineEjs;
4
+ exports.setEngineHandlebars = setEngineHandlebars;
5
+ exports.setEnginePug = setEnginePug;
6
+ const core_1 = require("@expressots/core");
7
+ const resolve_render_1 = require("./resolve-render");
8
+ const constants_1 = require("./constants");
4
9
  /**
5
- * The supported view engines.
6
- * @enum {string}
7
- * @readonly
8
- * @public
10
+ * Set Ejs as the view engine
11
+ * @param {Application} app - The express application
12
+ * @param {EjsOptions} [options=EJS_DEFAULTS] - The ejs options
9
13
  */
10
- var Engine;
11
- (function (Engine) {
12
- Engine["HBS"] = "hbs";
13
- Engine["EJS"] = "ejs";
14
- Engine["PUG"] = "pug";
15
- })(Engine || (exports.Engine = Engine = {}));
14
+ async function setEngineEjs(app, options = constants_1.EJS_DEFAULTS) {
15
+ (0, resolve_render_1.packageResolver)("ejs");
16
+ app.set("view engine", options.viewEngine || constants_1.EJS_DEFAULTS.viewEngine);
17
+ app.set("views", options.viewsDir || constants_1.EJS_DEFAULTS.viewsDir);
18
+ if (Array.isArray(options.viewsDir)) {
19
+ options.viewsDir.forEach((dir) => {
20
+ app.set("views", dir);
21
+ });
22
+ }
23
+ if (options.serverOptions) {
24
+ app.locals = {
25
+ ...app.locals,
26
+ ...options.serverOptions,
27
+ };
28
+ }
29
+ }
30
+ /**
31
+ * Set Handlebars as the view engine
32
+ * @param {express.Application} app - The express application
33
+ * @param {HandlebarsOptions} [options=HANDLEBARS_DEFAULTS] - The handlebars options
34
+ */
35
+ async function setEngineHandlebars(app, options = constants_1.HANDLEBARS_DEFAULTS) {
36
+ const logger = new core_1.Logger();
37
+ try {
38
+ const hbs = (0, resolve_render_1.packageResolver)("hbs");
39
+ hbs.registerPartials(options.partialsDir || constants_1.DEFAULT_PARTIALS_DIR);
40
+ app.set("view engine", options.viewEngine || constants_1.HANDLEBARS_DEFAULTS.viewEngine);
41
+ app.set("views", options.viewsDir || constants_1.HANDLEBARS_DEFAULTS.viewsDir);
42
+ }
43
+ catch (error) {
44
+ logger.error(error.message, "handlebars-config");
45
+ }
46
+ }
47
+ /**
48
+ * Set Pug as the view engine
49
+ * @param {express.Application} app - The express application
50
+ * @param {PugOptions} [options=PUG_DEFAULTS] - The pug options
51
+ */
52
+ async function setEnginePug(app, options = constants_1.PUG_DEFAULTS) {
53
+ (0, resolve_render_1.packageResolver)("pug");
54
+ app.set("view engine", options.viewEngine || constants_1.PUG_DEFAULTS.viewEngine);
55
+ app.set("views", options.viewsDir || constants_1.PUG_DEFAULTS.viewsDir);
56
+ }
@@ -1,5 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Engine = void 0;
4
- var engine_1 = require("./engine");
5
- Object.defineProperty(exports, "Engine", { enumerable: true, get: function () { return engine_1.Engine; } });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-namespace */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FactoryType = void 0;
5
+ var FactoryType;
6
+ (function (FactoryType) {
7
+ FactoryType["DynamicValue"] = "toDynamicValue";
8
+ FactoryType["Factory"] = "toFactory";
9
+ FactoryType["Provider"] = "toProvider";
10
+ })(FactoryType || (exports.FactoryType = FactoryType = {}));
@@ -19,6 +19,17 @@
19
19
  * @abstract
20
20
  */
21
21
  export declare abstract class ApplicationBase {
22
+ /**
23
+ * Implement this method to set up global configurations for the server.
24
+ * This method is called before any other server initialization methods.
25
+ * Use this method to configure global settings that apply to the entire
26
+ * server application. Supports asynchronous setup with a Promise.
27
+ *
28
+ * @abstract
29
+ * @returns {void | Promise<void>}
30
+ * @public API
31
+ */
32
+ protected abstract globalConfiguration(): void | Promise<void>;
22
33
  /**
23
34
  * Implement this method to set up required services or configurations before
24
35
  * the server starts. This is essential for initializing dependencies or settings
@@ -26,6 +37,7 @@ export declare abstract class ApplicationBase {
26
37
  *
27
38
  * @abstract
28
39
  * @returns {void | Promise<void>}
40
+ * @public API
29
41
  */
30
42
  protected abstract configureServices(): void | Promise<void>;
31
43
  /**
@@ -35,6 +47,7 @@ export declare abstract class ApplicationBase {
35
47
  *
36
48
  * @abstract
37
49
  * @returns {void | Promise<void>}
50
+ * @public API
38
51
  */
39
52
  protected abstract postServerInitialization(): void | Promise<void>;
40
53
  /**
@@ -42,6 +55,10 @@ export declare abstract class ApplicationBase {
42
55
  * is shutting down. Ideal for closing resources, stopping tasks, or other
43
56
  * cleanup procedures to ensure a graceful server shutdown. Supports asynchronous
44
57
  * cleanup with a Promise.
58
+ *
59
+ * @abstract
60
+ * @returns {void | Promise<void>}
61
+ * @public API
45
62
  */
46
63
  protected abstract serverShutdown(): void | Promise<void>;
47
64
  }
@@ -1,9 +1,8 @@
1
- import { IApplicationMessageToConsole } from "@expressots/core";
2
1
  import express from "express";
3
- import { Container } from "inversify";
2
+ import { AppContainer, IConsoleMessage, ProviderManager, IMiddleware } from "@expressots/core";
3
+ import { RenderEngine, Env, Server } from "@expressots/shared";
4
+ import { interfaces } from "../di/di.interfaces";
4
5
  import { ApplicationBase } from "./application-express.base";
5
- import { IWebServer, ServerEnvironment } from "./application-express.types";
6
- import { Engine, EngineOptions } from "./render/engine";
7
6
  /**
8
7
  * The AppExpress class provides methods for configuring and running an Express application.
9
8
  * @class AppExpress
@@ -15,16 +14,20 @@ import { Engine, EngineOptions } from "./render/engine";
15
14
  * @method setEngine - Configures the application's view engine based on the provided configuration options.
16
15
  * @method isDevelopment - Verifies if the current environment is development.
17
16
  */
18
- declare class AppExpress extends ApplicationBase implements IWebServer {
17
+ export declare class AppExpress extends ApplicationBase implements Server.IWebServer {
19
18
  private logger;
19
+ private console;
20
20
  private app;
21
21
  private port;
22
- private environment;
23
- private container;
22
+ private environment?;
23
+ private appContainer;
24
24
  private globalPrefix;
25
+ private middlewareManager;
25
26
  private middlewares;
26
- private console;
27
+ private providerManager;
27
28
  private renderOptions;
29
+ constructor();
30
+ protected globalConfiguration(): void | Promise<void>;
28
31
  protected configureServices(): void | Promise<void>;
29
32
  protected postServerInitialization(): void | Promise<void>;
30
33
  protected serverShutdown(): void | Promise<void>;
@@ -33,10 +36,29 @@ declare class AppExpress extends ApplicationBase implements IWebServer {
33
36
  */
34
37
  private handleExit;
35
38
  /**
36
- * Configures the InversifyJS container.
37
- * @param container - The InversifyJS container.
39
+ * Initialize the InversifyJS container with the provided modules and options.
40
+ * @param appModules - An array of application modules to be loaded into the container.
41
+ * @param containerOptions - Container global configuration options.
42
+ * @option skipBaseClassChecks - Skip the base class checks for the container.
43
+ * @option autoBindInjectable - Automatically bind the injectable classes.
44
+ * @option defaultScope - The default scope to use for bindings.
45
+ *
46
+ * @returns The configured AppContainer instance.
47
+ * @public API
48
+ */
49
+ configContainer(appModules: Array<interfaces.ContainerModule>, containerOptions?: interfaces.ContainerOptions): AppContainer;
50
+ /**
51
+ * Get the ProviderManager instance.
52
+ * @returns The ProviderManager instance.
53
+ * @public API
54
+ */
55
+ get Provider(): ProviderManager;
56
+ /**
57
+ * Get the Middleware instance.
58
+ * @returns The Middleware instance.
59
+ * @public API
38
60
  */
39
- configure(container: Container): Promise<void>;
61
+ get Middleware(): IMiddleware;
40
62
  /**
41
63
  * Configures the Express application with the provided middleware entries.
42
64
  * @param app - The Express application instance.
@@ -53,18 +75,15 @@ declare class AppExpress extends ApplicationBase implements IWebServer {
53
75
  /**
54
76
  * Start listening on the given port and environment.
55
77
  * @param port - The port number to listen on.
56
- * @param environment - The server environment.
57
- * @param consoleMessage - Optional message to display in the console.
78
+ * @param appInfo - Optional message to display the app name and version.
79
+ * @public API
58
80
  */
59
- listen(port: number, environment: ServerEnvironment, consoleMessage?: IApplicationMessageToConsole): Promise<void>;
81
+ listen(port: number | string, appInfo?: IConsoleMessage): Promise<void>;
60
82
  /**
61
83
  * Sets the global route prefix for the application.
62
- *
63
- * @public
64
84
  * @method setGlobalRoutePrefix
65
- *
66
85
  * @param {string} prefix - The prefix to use for all routes.
67
- *
86
+ * @public API
68
87
  */
69
88
  setGlobalRoutePrefix(prefix: string): void;
70
89
  /**
@@ -73,25 +92,41 @@ declare class AppExpress extends ApplicationBase implements IWebServer {
73
92
  private configEngine;
74
93
  /**
75
94
  * Configures the application's view engine based on the provided configuration options.
76
- *
77
- * @public
78
95
  * @method setEngine
79
96
  * @template T - A generic type extending from RenderTemplateOptions.
80
97
  *
81
98
  * @param {Engine} engine - The view engine to set
82
99
  * @param {EngineOptions} [options] - The configuration options for the view engine
100
+ * @public API
83
101
  */
84
- setEngine<T extends EngineOptions>(engine: Engine, options?: T): Promise<void>;
102
+ setEngine<T extends RenderEngine.EngineOptions>(engine: RenderEngine.Engine, options?: T): Promise<void>;
85
103
  /**
86
104
  * Verifies if the current environment is development.
87
- *
88
105
  * @returns A boolean value indicating whether the current environment is development or not.
106
+ * @public API
89
107
  */
90
108
  protected isDevelopment(): boolean;
109
+ /**
110
+ * Load environment variables from the specified file based on the environment configuration.
111
+ * @param environment - The environment to load configuration for.
112
+ * @param options - The options to use for loading the environment configuration.
113
+ * @option env - The environment configuration options.
114
+ * @example
115
+ * ```typescript
116
+ * {
117
+ env: {
118
+ development: ".env.development",
119
+ production: ".env.production"
120
+ }
121
+ }
122
+ * ```
123
+ * @public API
124
+ */
125
+ initEnvironment(environment: Env.Environment, options?: Env.IEnvironment): void;
91
126
  /**
92
127
  * Get the underlying HTTP server. (default: Express.js)
93
128
  * @returns The underlying HTTP server after initialization.
129
+ * @public API
94
130
  */
95
131
  getHttpServer(): Promise<express.Application>;
96
132
  }
97
- export { AppExpress };
@@ -1,21 +1,4 @@
1
- import express, { Request, Response, NextFunction } from "express";
2
- import { IApplicationMessageToConsole } from "@expressots/core";
3
- import { Container } from "inversify";
4
- import { Engine, EngineOptions } from "./render/engine";
5
- /**
6
- * Interface for the WebServer application implementation.
7
- */
8
- export interface IWebServer {
9
- configure(container: Container): Promise<void>;
10
- listen(port: number, environment: ServerEnvironment, consoleMessage?: IApplicationMessageToConsole): Promise<void>;
11
- setEngine<T extends EngineOptions>(engine: Engine, options?: T): Promise<void>;
12
- }
13
- /**
14
- * Constructor type for IWebServer.
15
- */
16
- export interface IWebServerConstructor<T extends IWebServer> {
17
- new (): T;
18
- }
1
+ import express from "express";
19
2
  /**
20
3
  * ExpressHandler Type
21
4
  *
@@ -38,26 +21,3 @@ export type MiddlewareConfig = {
38
21
  path?: string;
39
22
  middlewares: Array<ExpressHandler>;
40
23
  };
41
- /**
42
- * Expresso middleware interface.
43
- */
44
- interface IExpressoMiddleware {
45
- use(req: Request, res: Response, next: NextFunction): Promise<void> | void;
46
- }
47
- /**
48
- * Abstract class for creating custom Expresso middleware.
49
- * Custom middleware classes should extend this class and implement the use method.
50
- *
51
- */
52
- export declare abstract class ExpressoMiddleware implements IExpressoMiddleware {
53
- get name(): string;
54
- abstract use(req: Request, res: Response, next: NextFunction): Promise<void> | void;
55
- }
56
- /**
57
- * Enum representing possible server environments.
58
- */
59
- export declare enum ServerEnvironment {
60
- Development = "development",
61
- Production = "production"
62
- }
63
- export {};
@@ -1,5 +1,5 @@
1
1
  import type { NextFunction, Request, Response } from "express";
2
- import { interfaces as inversifyInterfaces } from "inversify";
2
+ import { interfaces as inversifyInterfaces } from "../../di/di.interfaces";
3
3
  import type { HttpContext } from "./interfaces";
4
4
  export declare abstract class BaseMiddleware implements BaseMiddleware {
5
5
  httpContext: HttpContext;
@@ -40,5 +40,5 @@ export declare enum HTTP_VERBS_ENUM {
40
40
  trace = "TRACE"
41
41
  }
42
42
  export declare const DUPLICATED_CONTROLLER_NAME: (name: string) => string;
43
- export declare const NO_CONTROLLERS_FOUND: string;
43
+ export declare const NO_CONTROLLERS_FOUND = "No controller found! Please ensure that you have register at least one Controller.";
44
44
  export declare const DEFAULT_ROUTING_ROOT_PATH = "/";
@@ -1,67 +1,76 @@
1
1
  import "reflect-metadata";
2
2
  import { PARAMETER_TYPE, HTTP_VERBS_ENUM } from "./constants";
3
3
  import type { HandlerDecorator, Middleware } from "./interfaces";
4
- export declare const injectHttpContext: (target: import("inversify/lib/annotation/decorator_utils").DecoratorTarget<unknown>, targetKey?: string | symbol | undefined, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<unknown>) => void;
4
+ import { Request } from "express";
5
+ export declare const injectHttpContext: (target: import("@expressots/core/lib/cjs/types/di/annotation/decorator_utils").DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<unknown>) => void;
5
6
  /**
6
7
  * Controller decorator to define a new controller
7
8
  * @param path route path
8
9
  * @param middleware array of middleware to be applied to all routes in the controller
10
+ * @public API
9
11
  */
10
12
  export declare function controller(path: string, ...middleware: Array<Middleware>): (target: NewableFunction) => void;
11
13
  /**
12
14
  * Http decorator to define the status code for a route
13
15
  * @param code
14
16
  * @returns MethodDecorator
15
- * @example
16
- * ```ts
17
+ * @example ```typescript
17
18
  * @Http(200)
18
19
  * @Get("/")
19
20
  * hello() {
20
21
  * return "Hello World";
21
22
  * }
22
23
  * ```
24
+ * @public API
23
25
  */
24
26
  export declare function Http(code: number): (target: object, key: string | symbol, descriptor: TypedPropertyDescriptor<any>) => void;
25
27
  /**
26
28
  * Decorator to allow accept all HTTP methods
27
29
  * @param path route path, wildcard
28
30
  * @param middleware array of middleware to be applied to all routes defined in path logic
31
+ * @public API
29
32
  */
30
33
  export declare function All(path: string, ...middleware: Array<Middleware>): HandlerDecorator;
31
34
  /**
32
35
  * Decorator to allow GET HTTP method
33
36
  * @param path route path
34
37
  * @param middleware array of middleware to be applied to the route
38
+ * @public API
35
39
  */
36
40
  export declare function Get(path: string, ...middleware: Array<Middleware>): HandlerDecorator;
37
41
  /**
38
42
  * Decorator to allow POST HTTP method
39
43
  * @param path route path
40
44
  * @param middleware array of middleware to be applied to the route
45
+ * @public API
41
46
  */
42
47
  export declare function Post(path: string, ...middleware: Array<Middleware>): HandlerDecorator;
43
48
  /**
44
49
  * Decorator to allow PUT HTTP method
45
50
  * @param path route path
46
51
  * @param middleware array of middleware to be applied to the route
52
+ * @public API
47
53
  */
48
54
  export declare function Put(path: string, ...middleware: Array<Middleware>): HandlerDecorator;
49
55
  /**
50
56
  * Decorator to allow PATCH HTTP method
51
57
  * @param path route path
52
58
  * @param middleware array of middleware to be applied to the route
59
+ * @public API
53
60
  */
54
61
  export declare function Patch(path: string, ...middleware: Array<Middleware>): HandlerDecorator;
55
62
  /**
56
63
  * Decorator to allow HEAD HTTP method
57
64
  * @param path route path
58
65
  * @param middleware array of middleware to be applied to the route
66
+ * @public API
59
67
  */
60
68
  export declare function Head(path: string, ...middleware: Array<Middleware>): HandlerDecorator;
61
69
  /**
62
70
  * Decorator to allow DELETE HTTP method
63
71
  * @param path route path
64
72
  * @param middleware array of middleware to be applied to the route
73
+ * @public API
65
74
  */
66
75
  export declare function Delete(path: string, ...middleware: Array<Middleware>): HandlerDecorator;
67
76
  /**
@@ -69,6 +78,7 @@ export declare function Delete(path: string, ...middleware: Array<Middleware>):
69
78
  * @param method custom HTTP method
70
79
  * @param path route path
71
80
  * @param middleware array of middleware to be applied to the route
81
+ * @public API
72
82
  */
73
83
  export declare function Method(method: keyof typeof HTTP_VERBS_ENUM, path: string, ...middleware: Array<Middleware>): HandlerDecorator;
74
84
  /**
@@ -119,23 +129,33 @@ export declare const principal: () => ParameterDecorator;
119
129
  /**
120
130
  * Parameter decorator to inject the request object
121
131
  * @returns ParameterDecorator
132
+ * @param type - The type of parameter to inject
133
+ * @param parameterName - The name of the parameter to inject
134
+ * @public API
122
135
  */
123
136
  export declare function params(type: PARAMETER_TYPE, parameterName?: string): ParameterDecorator;
124
137
  /**
125
138
  * Render decorator to define the template and default data for a route
126
139
  * @param template The template to render
127
140
  * @param defaultData The default data to pass to the template
128
- * @returns
141
+ * @returns MethodDecorator
142
+ * @public API
129
143
  */
130
144
  export declare function Render(template: string, defaultData?: Record<string, unknown>): MethodDecorator;
131
145
  export declare function getRenderMetadata(target: object, propertyKey: string | symbol): {
132
146
  template?: string;
133
147
  defaultData?: Record<string, unknown>;
134
148
  };
149
+ /**
150
+ * Multer storage engine interface
151
+ */
135
152
  export interface StorageEngine {
136
- _handleFile(req: unknown, file: MulterFile, callback: (error?: Error | null, info?: Partial<MulterFile>) => void): void;
137
- _removeFile(req: unknown, file: MulterFile, callback: (error: Error | null) => void): void;
153
+ _handleFile(req: Request, file: MulterFile, callback: (error?: Error | null, info?: Partial<MulterFile>) => void): void;
154
+ _removeFile(req: Request, file: MulterFile, callback: (error: Error | null) => void): void;
138
155
  }
156
+ /**
157
+ * Multer file interface
158
+ */
139
159
  export interface MulterFile {
140
160
  fieldname: string;
141
161
  originalname: string;
@@ -147,6 +167,9 @@ export interface MulterFile {
147
167
  path?: string;
148
168
  buffer?: Buffer;
149
169
  }
170
+ /**
171
+ * Multer limits interface
172
+ */
150
173
  export interface MulterLimits {
151
174
  fieldNameSize?: number;
152
175
  fieldSize?: number;
@@ -156,6 +179,9 @@ export interface MulterLimits {
156
179
  parts?: number;
157
180
  headerPairs?: number;
158
181
  }
182
+ /**
183
+ * Multer options interface
184
+ */
159
185
  export interface MulterOptions {
160
186
  dest?: string;
161
187
  storage?: StorageEngine;
@@ -163,7 +189,7 @@ export interface MulterOptions {
163
189
  fileFilter?: FileFilter;
164
190
  }
165
191
  export type FileFilterCallback = (error: Error | null, acceptFile: boolean) => void;
166
- export type FileFilter = (req: unknown, file: MulterFile, callback: FileFilterCallback) => void;
192
+ export type FileFilter = (req: Request, file: MulterFile, callback: FileFilterCallback) => void;
167
193
  type FieldOptions = {
168
194
  fieldName: string;
169
195
  maxCount?: number;
@@ -174,6 +200,7 @@ type FieldOptions = {
174
200
  * @param multerOptions
175
201
  * @default { none: true }
176
202
  * @returns MethodDecorator
203
+ * @public API
177
204
  */
178
205
  export declare function FileUpload(options?: FieldOptions | Array<FieldOptions> | {
179
206
  none?: boolean;
@@ -6,6 +6,8 @@ import { ExpressoMiddleware } from "@expressots/core";
6
6
  * @returns express.RequestHandler
7
7
  */
8
8
  export declare class HttpStatusCodeMiddleware extends ExpressoMiddleware {
9
+ private globalPrefix;
10
+ constructor(globalPrefix?: string);
9
11
  use(req: Request, res: Response, next: NextFunction): void | Promise<void>;
10
12
  /**
11
13
  * Find the matching parameter path.
@@ -1,5 +1,5 @@
1
1
  import type { Application, NextFunction, Request, RequestHandler, Response } from "express";
2
- import { interfaces as inversifyInterfaces } from "inversify";
2
+ import { interfaces as inversifyInterfaces } from "../../di/di.interfaces";
3
3
  import { HTTP_VERBS_ENUM, PARAMETER_TYPE } from "./constants";
4
4
  import { HttpResponseMessage } from "./httpResponseMessage";
5
5
  type Prototype<T> = {
@@ -1,5 +1,5 @@
1
1
  import express, { Application, Router } from "express";
2
- import { interfaces } from "inversify";
2
+ import { interfaces } from "../../di/di.interfaces";
3
3
  import type { AuthProvider, ConfigFunction, RoutingConfig } from "./interfaces";
4
4
  export declare class InversifyExpressServer {
5
5
  private _router;
@@ -1,4 +1,4 @@
1
- import { interfaces } from "inversify";
1
+ import { interfaces } from "../../di/di.interfaces";
2
2
  import type { BaseController, ControllerMetadata, ControllerMethodMetadata, ControllerParameterMetadata, DecoratorTarget, IHttpActionResult } from "./interfaces";
3
3
  export declare function getControllersFromContainer(container: interfaces.Container, forceControllers: boolean): Array<BaseController>;
4
4
  export declare function getControllersFromMetadata(): Array<DecoratorTarget>;
@@ -1,5 +1,4 @@
1
1
  export * from "./express-utils";
2
2
  export { AppExpress } from "./application-express";
3
- export { IWebServerPublic } from "./application-express.interface";
4
- export { IWebServer, IWebServerConstructor } from "./application-express.types";
3
+ export { IWebServerPublic, IWebServer, IWebServerConstructor, Environment, IEnvironment, RenderEngine, } from "@expressots/shared";
5
4
  export * from "./render";
@@ -0,0 +1,26 @@
1
+ import { RenderEngine } from "@expressots/shared";
2
+ /**
3
+ * Ejs defaults
4
+ * @type {EjsOptions}
5
+ * @constant
6
+ * @default
7
+ */
8
+ export declare const EJS_DEFAULTS: RenderEngine.EjsOptions;
9
+ /**
10
+ * Handlebars defaults
11
+ * @type {HandlebarsOptions}
12
+ * @constant
13
+ * @default
14
+ */
15
+ export declare const HANDLEBARS_DEFAULTS: RenderEngine.HandlebarsOptions;
16
+ /**
17
+ * Default partials directory
18
+ */
19
+ export declare const DEFAULT_PARTIALS_DIR: string;
20
+ /**
21
+ * Pug defaults
22
+ * @type {PugOptions}
23
+ * @constant
24
+ * @default
25
+ */
26
+ export declare const PUG_DEFAULTS: RenderEngine.PugOptions;
@@ -1,28 +1,20 @@
1
- import { EjsOptions } from "./ejs/ejs.config";
2
- import { HandlebarsOptions } from "./handlebars/hbs.config";
1
+ import { Application } from "express";
2
+ import { RenderEngine } from "@expressots/shared";
3
3
  /**
4
- * The configuration options for the view engine.
5
- * @typedef {HandlebarsOptions | EjsOptions} EngineOptions
6
- * @private
4
+ * Set Ejs as the view engine
5
+ * @param {Application} app - The express application
6
+ * @param {EjsOptions} [options=EJS_DEFAULTS] - The ejs options
7
7
  */
8
- export type RenderOptions = {
9
- engine: Engine;
10
- options?: EngineOptions;
11
- };
8
+ export declare function setEngineEjs(app: Application, options?: RenderEngine.EjsOptions): Promise<void>;
12
9
  /**
13
- * The supported view engines.
14
- * @enum {string}
15
- * @readonly
16
- * @public
10
+ * Set Handlebars as the view engine
11
+ * @param {express.Application} app - The express application
12
+ * @param {HandlebarsOptions} [options=HANDLEBARS_DEFAULTS] - The handlebars options
17
13
  */
18
- export declare enum Engine {
19
- HBS = "hbs",
20
- EJS = "ejs",
21
- PUG = "pug"
22
- }
14
+ export declare function setEngineHandlebars(app: Application, options?: RenderEngine.HandlebarsOptions): Promise<void>;
23
15
  /**
24
- * The configuration options for the view engine.
25
- * @typedef {HandlebarsOptions | EjsOptions} EngineOptions
26
- * @public
16
+ * Set Pug as the view engine
17
+ * @param {express.Application} app - The express application
18
+ * @param {PugOptions} [options=PUG_DEFAULTS] - The pug options
27
19
  */
28
- export type EngineOptions = HandlebarsOptions | EjsOptions;
20
+ export declare function setEnginePug(app: Application, options?: RenderEngine.PugOptions): Promise<void>;
@@ -1,4 +1,4 @@
1
- export { EjsOptions as EJS } from "./ejs/ejs.config";
2
- export { HandlebarsOptions as HBS } from "./handlebars/hbs.config";
3
- export { PugOptions as PUG } from "./pug/pug.config";
4
- export { Engine } from "./engine";
1
+ import { RenderEngine } from "@expressots/shared";
2
+ export type EJS = RenderEngine.EjsOptions;
3
+ export type HBS = RenderEngine.HandlebarsOptions;
4
+ export type PUG = RenderEngine.PugOptions;