@expressots/adapter-express 1.8.2 → 3.0.0-beta.2
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 +168 -139
- package/lib/cjs/adapter-express/application-express.base.js +2 -12
- package/lib/cjs/adapter-express/application-express.js +132 -52
- package/lib/cjs/adapter-express/application-express.types.js +0 -20
- package/lib/cjs/adapter-express/express-utils/base-middleware.js +2 -2
- package/lib/cjs/adapter-express/express-utils/constants.js +1 -3
- package/lib/cjs/adapter-express/express-utils/decorators.js +26 -12
- package/lib/cjs/adapter-express/express-utils/http-status-middleware.js +10 -5
- package/lib/cjs/adapter-express/express-utils/utils.js +3 -0
- package/lib/cjs/adapter-express/index.js +4 -1
- package/lib/cjs/adapter-express/micro-api/application-express-micro-container.js +51 -0
- package/lib/cjs/adapter-express/micro-api/application-express-micro-route.js +101 -0
- package/lib/cjs/adapter-express/micro-api/application-express-micro.js +177 -0
- package/lib/cjs/adapter-express/micro-api/index.js +5 -0
- package/lib/cjs/adapter-express/render/constants.js +40 -0
- package/lib/cjs/adapter-express/render/engine.js +52 -11
- package/lib/cjs/adapter-express/render/index.js +0 -3
- package/lib/cjs/di/di.interfaces.js +10 -0
- package/lib/cjs/types/adapter-express/application-express.base.d.ts +17 -0
- package/lib/cjs/types/adapter-express/application-express.d.ts +58 -23
- package/lib/cjs/types/adapter-express/application-express.types.d.ts +1 -41
- package/lib/cjs/types/adapter-express/express-utils/base-middleware.d.ts +1 -1
- package/lib/cjs/types/adapter-express/express-utils/constants.d.ts +1 -1
- package/lib/cjs/types/adapter-express/express-utils/decorators.d.ts +18 -4
- package/lib/cjs/types/adapter-express/express-utils/http-status-middleware.d.ts +2 -0
- package/lib/cjs/types/adapter-express/express-utils/interfaces.d.ts +1 -1
- package/lib/cjs/types/adapter-express/express-utils/inversify-express-server.d.ts +1 -1
- package/lib/cjs/types/adapter-express/express-utils/utils.d.ts +1 -1
- package/lib/cjs/types/adapter-express/index.d.ts +2 -2
- package/lib/cjs/types/adapter-express/micro-api/application-express-micro-container.d.ts +47 -0
- package/lib/cjs/types/adapter-express/micro-api/application-express-micro-route.d.ts +93 -0
- package/lib/cjs/types/adapter-express/micro-api/application-express-micro.d.ts +79 -0
- package/lib/cjs/types/adapter-express/micro-api/index.d.ts +1 -0
- package/lib/cjs/types/adapter-express/render/constants.d.ts +26 -0
- package/lib/cjs/types/adapter-express/render/engine.d.ts +14 -22
- package/lib/cjs/types/adapter-express/render/index.d.ts +4 -4
- package/lib/cjs/types/di/di.interfaces.d.ts +289 -0
- package/lib/package.json +11 -16
- package/package.json +11 -16
- package/lib/cjs/adapter-express/application-express.interface.js +0 -2
- package/lib/cjs/adapter-express/render/ejs/ejs.config.js +0 -37
- package/lib/cjs/adapter-express/render/ejs/ejs.types.js +0 -3
- package/lib/cjs/adapter-express/render/handlebars/hbs.config.js +0 -38
- package/lib/cjs/adapter-express/render/pug/pug.config.js +0 -25
- package/lib/cjs/types/adapter-express/application-express.interface.d.ts +0 -20
- package/lib/cjs/types/adapter-express/render/ejs/ejs.config.d.ts +0 -21
- package/lib/cjs/types/adapter-express/render/ejs/ejs.types.d.ts +0 -169
- package/lib/cjs/types/adapter-express/render/handlebars/hbs.config.d.ts +0 -20
- package/lib/cjs/types/adapter-express/render/pug/pug.config.d.ts +0 -17
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
export declare enum FactoryType {
|
|
2
|
+
DynamicValue = "toDynamicValue",
|
|
3
|
+
Factory = "toFactory",
|
|
4
|
+
Provider = "toProvider"
|
|
5
|
+
}
|
|
6
|
+
declare namespace interfaces {
|
|
7
|
+
export type DynamicValue<T> = (context: interfaces.Context) => T | Promise<T>;
|
|
8
|
+
export type ContainerResolution<T> = T | Promise<T> | Array<T | Promise<T>>;
|
|
9
|
+
type AsyncCallback<TCallback> = TCallback extends (...args: infer TArgs) => infer TResult ? (...args: TArgs) => Promise<TResult> : never;
|
|
10
|
+
export type BindingScope = "Singleton" | "Transient" | "Request";
|
|
11
|
+
export type BindingType = "ConstantValue" | "Constructor" | "DynamicValue" | "Factory" | "Function" | "Instance" | "Invalid" | "Provider";
|
|
12
|
+
export type TargetType = "ConstructorArgument" | "ClassProperty" | "Variable";
|
|
13
|
+
export interface BindingScopeEnum {
|
|
14
|
+
Request: interfaces.BindingScope;
|
|
15
|
+
Singleton: interfaces.BindingScope;
|
|
16
|
+
Transient: interfaces.BindingScope;
|
|
17
|
+
}
|
|
18
|
+
export interface BindingTypeEnum {
|
|
19
|
+
ConstantValue: interfaces.BindingType;
|
|
20
|
+
Constructor: interfaces.BindingType;
|
|
21
|
+
DynamicValue: interfaces.BindingType;
|
|
22
|
+
Factory: interfaces.BindingType;
|
|
23
|
+
Function: interfaces.BindingType;
|
|
24
|
+
Instance: interfaces.BindingType;
|
|
25
|
+
Invalid: interfaces.BindingType;
|
|
26
|
+
Provider: interfaces.BindingType;
|
|
27
|
+
}
|
|
28
|
+
export interface TargetTypeEnum {
|
|
29
|
+
ConstructorArgument: interfaces.TargetType;
|
|
30
|
+
ClassProperty: interfaces.TargetType;
|
|
31
|
+
Variable: interfaces.TargetType;
|
|
32
|
+
}
|
|
33
|
+
export type Newable<T> = new (...args: Array<unknown>) => T;
|
|
34
|
+
export type Instance<T> = T & Record<string, () => void>;
|
|
35
|
+
export interface Abstract<T> {
|
|
36
|
+
prototype: T;
|
|
37
|
+
}
|
|
38
|
+
export type ServiceIdentifier<T = unknown> = string | symbol | Newable<T> | Abstract<T>;
|
|
39
|
+
export interface Clonable<T> {
|
|
40
|
+
clone(): T;
|
|
41
|
+
}
|
|
42
|
+
export type BindingActivation<T = unknown> = (context: interfaces.Context, injectable: T) => T | Promise<T>;
|
|
43
|
+
export type BindingDeactivation<T = unknown> = (injectable: T) => void | Promise<void>;
|
|
44
|
+
export interface Binding<TActivated = unknown> extends Clonable<Binding<TActivated>> {
|
|
45
|
+
id: number;
|
|
46
|
+
moduleId: ContainerModuleBase["id"];
|
|
47
|
+
activated: boolean;
|
|
48
|
+
serviceIdentifier: ServiceIdentifier<TActivated>;
|
|
49
|
+
constraint: ConstraintFunction;
|
|
50
|
+
dynamicValue: DynamicValue<TActivated> | null;
|
|
51
|
+
scope: BindingScope;
|
|
52
|
+
type: BindingType;
|
|
53
|
+
implementationType: Newable<TActivated> | TActivated | null;
|
|
54
|
+
factory: FactoryCreator<unknown> | null;
|
|
55
|
+
provider: ProviderCreator<unknown> | null;
|
|
56
|
+
onActivation: BindingActivation<TActivated> | null;
|
|
57
|
+
onDeactivation: BindingDeactivation<TActivated> | null;
|
|
58
|
+
cache: null | TActivated | Promise<TActivated>;
|
|
59
|
+
}
|
|
60
|
+
export type SimpleFactory<T, U extends Array<unknown> = Array<unknown>> = (...args: U) => T;
|
|
61
|
+
export type MultiFactory<T, U extends Array<unknown> = Array<unknown>, V extends Array<unknown> = Array<unknown>> = (...args: U) => SimpleFactory<T, V>;
|
|
62
|
+
export type Factory<T, U extends Array<unknown> = Array<unknown>, V extends Array<unknown> = Array<unknown>> = SimpleFactory<T, U> | MultiFactory<T, U, V>;
|
|
63
|
+
export type FactoryCreator<T, U extends Array<unknown> = Array<unknown>, V extends Array<unknown> = Array<unknown>> = (context: Context) => Factory<T, U, V>;
|
|
64
|
+
export type AutoNamedFactory<T> = SimpleFactory<T, [string]>;
|
|
65
|
+
export type AutoFactory<T> = SimpleFactory<T, []>;
|
|
66
|
+
export type FactoryTypeFunction<T = unknown> = (context: interfaces.Context) => T | Promise<T>;
|
|
67
|
+
export interface FactoryDetails {
|
|
68
|
+
factoryType: FactoryType;
|
|
69
|
+
factory: FactoryTypeFunction | null;
|
|
70
|
+
}
|
|
71
|
+
export type Provider<T> = (...args: Array<unknown>) => ((...args: Array<unknown>) => Promise<T>) | Promise<T>;
|
|
72
|
+
export type ProviderCreator<T> = (context: Context) => Provider<T>;
|
|
73
|
+
export interface NextArgs<T = unknown> {
|
|
74
|
+
avoidConstraints: boolean;
|
|
75
|
+
contextInterceptor: (contexts: Context) => Context;
|
|
76
|
+
isMultiInject: boolean;
|
|
77
|
+
targetType: TargetType;
|
|
78
|
+
serviceIdentifier: interfaces.ServiceIdentifier<T>;
|
|
79
|
+
key?: string | number | symbol | undefined;
|
|
80
|
+
value?: unknown;
|
|
81
|
+
}
|
|
82
|
+
export type Next = (args: NextArgs) => unknown | Array<unknown>;
|
|
83
|
+
export type Middleware = (next: Next) => Next;
|
|
84
|
+
export type ContextInterceptor = (context: interfaces.Context) => interfaces.Context;
|
|
85
|
+
export interface Context {
|
|
86
|
+
id: number;
|
|
87
|
+
container: Container;
|
|
88
|
+
plan: Plan;
|
|
89
|
+
currentRequest: Request;
|
|
90
|
+
addPlan(plan: Plan): void;
|
|
91
|
+
setCurrentRequest(request: Request): void;
|
|
92
|
+
}
|
|
93
|
+
export type MetadataOrMetadataArray = Metadata | Array<Metadata>;
|
|
94
|
+
export interface Metadata<TValue = unknown> {
|
|
95
|
+
key: string | number | symbol;
|
|
96
|
+
value: TValue;
|
|
97
|
+
}
|
|
98
|
+
export interface Plan {
|
|
99
|
+
parentContext: Context;
|
|
100
|
+
rootRequest: Request;
|
|
101
|
+
}
|
|
102
|
+
export interface QueryableString {
|
|
103
|
+
startsWith(searchString: string): boolean;
|
|
104
|
+
endsWith(searchString: string): boolean;
|
|
105
|
+
contains(searchString: string): boolean;
|
|
106
|
+
equals(compareString: string): boolean;
|
|
107
|
+
value(): string;
|
|
108
|
+
}
|
|
109
|
+
export type ResolveRequestHandler = (request: interfaces.Request) => unknown;
|
|
110
|
+
export type RequestScope = Map<unknown, unknown>;
|
|
111
|
+
export interface Request {
|
|
112
|
+
id: number;
|
|
113
|
+
serviceIdentifier: ServiceIdentifier;
|
|
114
|
+
parentContext: Context;
|
|
115
|
+
parentRequest: Request | null;
|
|
116
|
+
childRequests: Array<Request>;
|
|
117
|
+
target: Target;
|
|
118
|
+
bindings: Array<Binding<unknown>>;
|
|
119
|
+
requestScope: RequestScope | null;
|
|
120
|
+
addChildRequest(serviceIdentifier: ServiceIdentifier, bindings: Binding<unknown> | Array<Binding<unknown>>, target: Target): Request;
|
|
121
|
+
}
|
|
122
|
+
export interface Target {
|
|
123
|
+
id: number;
|
|
124
|
+
serviceIdentifier: ServiceIdentifier;
|
|
125
|
+
type: TargetType;
|
|
126
|
+
name: QueryableString;
|
|
127
|
+
identifier: string | symbol;
|
|
128
|
+
metadata: Array<Metadata>;
|
|
129
|
+
getNamedTag(): interfaces.Metadata<string> | null;
|
|
130
|
+
getCustomTags(): Array<interfaces.Metadata> | null;
|
|
131
|
+
hasTag(key: string | number | symbol): boolean;
|
|
132
|
+
isArray(): boolean;
|
|
133
|
+
matchesArray(name: interfaces.ServiceIdentifier): boolean;
|
|
134
|
+
isNamed(): boolean;
|
|
135
|
+
isTagged(): boolean;
|
|
136
|
+
isOptional(): boolean;
|
|
137
|
+
matchesNamedTag(name: string): boolean;
|
|
138
|
+
matchesTag(key: string | number | symbol): (value: unknown) => boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface ContainerOptions {
|
|
141
|
+
autoBindInjectable?: boolean;
|
|
142
|
+
defaultScope?: BindingScope | undefined;
|
|
143
|
+
skipBaseClassChecks?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface Container {
|
|
146
|
+
id: number;
|
|
147
|
+
parent: Container | null;
|
|
148
|
+
options: ContainerOptions;
|
|
149
|
+
bind<T>(serviceIdentifier: ServiceIdentifier<T>): BindingToSyntax<T>;
|
|
150
|
+
rebind<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>): interfaces.BindingToSyntax<T>;
|
|
151
|
+
rebindAsync<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>): Promise<interfaces.BindingToSyntax<T>>;
|
|
152
|
+
unbind(serviceIdentifier: ServiceIdentifier): void;
|
|
153
|
+
unbindAsync(serviceIdentifier: interfaces.ServiceIdentifier): Promise<void>;
|
|
154
|
+
unbindAll(): void;
|
|
155
|
+
unbindAllAsync(): Promise<void>;
|
|
156
|
+
isBound(serviceIdentifier: ServiceIdentifier): boolean;
|
|
157
|
+
isCurrentBound<T>(serviceIdentifier: ServiceIdentifier<T>): boolean;
|
|
158
|
+
isBoundNamed(serviceIdentifier: ServiceIdentifier, named: string | number | symbol): boolean;
|
|
159
|
+
isBoundTagged(serviceIdentifier: ServiceIdentifier, key: string | number | symbol, value: unknown): boolean;
|
|
160
|
+
get<T>(serviceIdentifier: ServiceIdentifier<T>): T;
|
|
161
|
+
getNamed<T>(serviceIdentifier: ServiceIdentifier<T>, named: string | number | symbol): T;
|
|
162
|
+
getTagged<T>(serviceIdentifier: ServiceIdentifier<T>, key: string | number | symbol, value: unknown): T;
|
|
163
|
+
getAll<T>(serviceIdentifier: ServiceIdentifier<T>): Array<T>;
|
|
164
|
+
getAllTagged<T>(serviceIdentifier: ServiceIdentifier<T>, key: string | number | symbol, value: unknown): Array<T>;
|
|
165
|
+
getAllNamed<T>(serviceIdentifier: ServiceIdentifier<T>, named: string | number | symbol): Array<T>;
|
|
166
|
+
getAsync<T>(serviceIdentifier: ServiceIdentifier<T>): Promise<T>;
|
|
167
|
+
getNamedAsync<T>(serviceIdentifier: ServiceIdentifier<T>, named: string | number | symbol): Promise<T>;
|
|
168
|
+
getTaggedAsync<T>(serviceIdentifier: ServiceIdentifier<T>, key: string | number | symbol, value: unknown): Promise<T>;
|
|
169
|
+
getAllAsync<T>(serviceIdentifier: ServiceIdentifier<T>): Promise<Array<T>>;
|
|
170
|
+
getAllTaggedAsync<T>(serviceIdentifier: ServiceIdentifier<T>, key: string | number | symbol, value: unknown): Promise<Array<T>>;
|
|
171
|
+
getAllNamedAsync<T>(serviceIdentifier: ServiceIdentifier<T>, named: string | number | symbol): Promise<Array<T>>;
|
|
172
|
+
onActivation<T>(serviceIdentifier: ServiceIdentifier<T>, onActivation: BindingActivation<T>): void;
|
|
173
|
+
onDeactivation<T>(serviceIdentifier: ServiceIdentifier<T>, onDeactivation: BindingDeactivation<T>): void;
|
|
174
|
+
resolve<T>(constructorFunction: interfaces.Newable<T>): T;
|
|
175
|
+
load(...modules: Array<ContainerModule>): void;
|
|
176
|
+
loadAsync(...modules: Array<AsyncContainerModule>): Promise<void>;
|
|
177
|
+
unload(...modules: Array<ContainerModuleBase>): void;
|
|
178
|
+
unloadAsync(...modules: Array<ContainerModuleBase>): Promise<void>;
|
|
179
|
+
applyCustomMetadataReader(metadataReader: MetadataReader): void;
|
|
180
|
+
applyMiddleware(...middleware: Array<Middleware>): void;
|
|
181
|
+
snapshot(): void;
|
|
182
|
+
restore(): void;
|
|
183
|
+
createChild(): Container;
|
|
184
|
+
}
|
|
185
|
+
export type Bind = <T = unknown>(serviceIdentifier: ServiceIdentifier<T>) => BindingToSyntax<T>;
|
|
186
|
+
export type Rebind = <T = unknown>(serviceIdentifier: ServiceIdentifier<T>) => BindingToSyntax<T>;
|
|
187
|
+
export type Unbind = <T = unknown>(serviceIdentifier: ServiceIdentifier<T>) => void;
|
|
188
|
+
export type UnbindAsync = <T = unknown>(serviceIdentifier: ServiceIdentifier<T>) => Promise<void>;
|
|
189
|
+
export type IsBound = <T = unknown>(serviceIdentifier: ServiceIdentifier<T>) => boolean;
|
|
190
|
+
export interface ContainerModuleBase {
|
|
191
|
+
id: number;
|
|
192
|
+
}
|
|
193
|
+
export interface ContainerModule extends ContainerModuleBase {
|
|
194
|
+
registry: ContainerModuleCallBack;
|
|
195
|
+
}
|
|
196
|
+
export interface AsyncContainerModule extends ContainerModuleBase {
|
|
197
|
+
registry: AsyncContainerModuleCallBack;
|
|
198
|
+
}
|
|
199
|
+
export interface ModuleActivationHandlers {
|
|
200
|
+
onActivations: Lookup<BindingActivation<unknown>>;
|
|
201
|
+
onDeactivations: Lookup<BindingDeactivation<unknown>>;
|
|
202
|
+
}
|
|
203
|
+
export interface ModuleActivationStore extends Clonable<ModuleActivationStore> {
|
|
204
|
+
addDeactivation(moduleId: ContainerModuleBase["id"], serviceIdentifier: ServiceIdentifier<unknown>, onDeactivation: interfaces.BindingDeactivation<unknown>): void;
|
|
205
|
+
addActivation(moduleId: ContainerModuleBase["id"], serviceIdentifier: ServiceIdentifier<unknown>, onActivation: interfaces.BindingActivation<unknown>): void;
|
|
206
|
+
remove(moduleId: ContainerModuleBase["id"]): ModuleActivationHandlers;
|
|
207
|
+
}
|
|
208
|
+
export type ContainerModuleCallBack = (bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind, unbindAsync: interfaces.UnbindAsync, onActivation: interfaces.Container["onActivation"], onDeactivation: interfaces.Container["onDeactivation"]) => void;
|
|
209
|
+
export type AsyncContainerModuleCallBack = AsyncCallback<ContainerModuleCallBack>;
|
|
210
|
+
export interface ContainerSnapshot {
|
|
211
|
+
bindings: Lookup<Binding<unknown>>;
|
|
212
|
+
activations: Lookup<BindingActivation<unknown>>;
|
|
213
|
+
deactivations: Lookup<BindingDeactivation<unknown>>;
|
|
214
|
+
middleware: Next | null;
|
|
215
|
+
moduleActivationStore: interfaces.ModuleActivationStore;
|
|
216
|
+
}
|
|
217
|
+
export interface Lookup<T> extends Clonable<Lookup<T>> {
|
|
218
|
+
[x: string]: any;
|
|
219
|
+
add(serviceIdentifier: ServiceIdentifier, value: T): void;
|
|
220
|
+
getMap(): Map<interfaces.ServiceIdentifier, Array<T>>;
|
|
221
|
+
get(serviceIdentifier: ServiceIdentifier): Array<T>;
|
|
222
|
+
remove(serviceIdentifier: interfaces.ServiceIdentifier): void;
|
|
223
|
+
removeByCondition(condition: (item: T) => boolean): Array<T>;
|
|
224
|
+
removeIntersection(lookup: interfaces.Lookup<T>): void;
|
|
225
|
+
hasKey(serviceIdentifier: ServiceIdentifier): boolean;
|
|
226
|
+
clone(): Lookup<T>;
|
|
227
|
+
traverse(func: (key: interfaces.ServiceIdentifier, value: Array<T>) => void): void;
|
|
228
|
+
}
|
|
229
|
+
export interface BindingOnSyntax<T> {
|
|
230
|
+
onActivation(fn: (context: Context, injectable: T) => T | Promise<T>): BindingWhenSyntax<T>;
|
|
231
|
+
onDeactivation(fn: (injectable: T) => void | Promise<void>): BindingWhenSyntax<T>;
|
|
232
|
+
}
|
|
233
|
+
export interface BindingWhenSyntax<T> {
|
|
234
|
+
when(constraint: (request: Request) => boolean): BindingOnSyntax<T>;
|
|
235
|
+
whenTargetNamed(name: string | number | symbol): BindingOnSyntax<T>;
|
|
236
|
+
whenTargetIsDefault(): BindingOnSyntax<T>;
|
|
237
|
+
whenTargetTagged(tag: string | number | symbol, value: unknown): BindingOnSyntax<T>;
|
|
238
|
+
whenInjectedInto(parent: NewableFunction | string): BindingOnSyntax<T>;
|
|
239
|
+
whenParentNamed(name: string | number | symbol): BindingOnSyntax<T>;
|
|
240
|
+
whenParentTagged(tag: string | number | symbol, value: unknown): BindingOnSyntax<T>;
|
|
241
|
+
whenAnyAncestorIs(ancestor: NewableFunction | string): BindingOnSyntax<T>;
|
|
242
|
+
whenNoAncestorIs(ancestor: NewableFunction | string): BindingOnSyntax<T>;
|
|
243
|
+
whenAnyAncestorNamed(name: string | number | symbol): BindingOnSyntax<T>;
|
|
244
|
+
whenAnyAncestorTagged(tag: string | number | symbol, value: unknown): BindingOnSyntax<T>;
|
|
245
|
+
whenNoAncestorNamed(name: string | number | symbol): BindingOnSyntax<T>;
|
|
246
|
+
whenNoAncestorTagged(tag: string | number | symbol, value: unknown): BindingOnSyntax<T>;
|
|
247
|
+
whenAnyAncestorMatches(constraint: (request: Request) => boolean): BindingOnSyntax<T>;
|
|
248
|
+
whenNoAncestorMatches(constraint: (request: Request) => boolean): BindingOnSyntax<T>;
|
|
249
|
+
}
|
|
250
|
+
export interface BindingWhenOnSyntax<T> extends BindingWhenSyntax<T>, BindingOnSyntax<T> {
|
|
251
|
+
}
|
|
252
|
+
export interface BindingInSyntax<T> {
|
|
253
|
+
inSingletonScope(): BindingWhenOnSyntax<T>;
|
|
254
|
+
inTransientScope(): BindingWhenOnSyntax<T>;
|
|
255
|
+
inRequestScope(): BindingWhenOnSyntax<T>;
|
|
256
|
+
}
|
|
257
|
+
export interface BindingInWhenOnSyntax<T> extends BindingInSyntax<T>, BindingWhenOnSyntax<T> {
|
|
258
|
+
}
|
|
259
|
+
export interface BindingToSyntax<T> {
|
|
260
|
+
to(constructor: Newable<T>): BindingInWhenOnSyntax<T>;
|
|
261
|
+
toSelf(): BindingInWhenOnSyntax<T>;
|
|
262
|
+
toConstantValue(value: T): BindingWhenOnSyntax<T>;
|
|
263
|
+
toDynamicValue(func: DynamicValue<T>): BindingInWhenOnSyntax<T>;
|
|
264
|
+
toConstructor<T2>(constructor: Newable<T2>): BindingWhenOnSyntax<T>;
|
|
265
|
+
toFactory<T2, T3 extends Array<unknown> = Array<unknown>, T4 extends Array<unknown> = Array<unknown>>(factory: FactoryCreator<T2, T3, T4>): BindingWhenOnSyntax<T>;
|
|
266
|
+
toFunction(func: T): BindingWhenOnSyntax<T>;
|
|
267
|
+
toAutoFactory<T2>(serviceIdentifier: ServiceIdentifier<T2>): BindingWhenOnSyntax<T>;
|
|
268
|
+
toAutoNamedFactory<T2>(serviceIdentifier: ServiceIdentifier<T2>): BindingWhenOnSyntax<T>;
|
|
269
|
+
toProvider<T2>(provider: ProviderCreator<T2>): BindingWhenOnSyntax<T>;
|
|
270
|
+
toService(service: ServiceIdentifier<T>): void;
|
|
271
|
+
}
|
|
272
|
+
export interface ConstraintFunction {
|
|
273
|
+
metaData?: Metadata;
|
|
274
|
+
(request: Request | null): boolean;
|
|
275
|
+
}
|
|
276
|
+
export interface MetadataReader {
|
|
277
|
+
getConstructorMetadata(constructorFunc: NewableFunction): ConstructorMetadata;
|
|
278
|
+
getPropertiesMetadata(constructorFunc: NewableFunction): MetadataMap;
|
|
279
|
+
}
|
|
280
|
+
export interface MetadataMap {
|
|
281
|
+
[propertyNameOrArgumentIndex: string | symbol]: Array<Metadata>;
|
|
282
|
+
}
|
|
283
|
+
export interface ConstructorMetadata {
|
|
284
|
+
compilerGeneratedMetadata: Array<NewableFunction> | undefined;
|
|
285
|
+
userGeneratedMetadata: MetadataMap;
|
|
286
|
+
}
|
|
287
|
+
export {};
|
|
288
|
+
}
|
|
289
|
+
export { interfaces };
|
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/adapter-express",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.2",
|
|
4
4
|
"description": "Expressots - modern, fast, lightweight nodejs web framework (@adapter-express)",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -46,9 +46,6 @@
|
|
|
46
46
|
"framework",
|
|
47
47
|
"server-side"
|
|
48
48
|
],
|
|
49
|
-
"engines": {
|
|
50
|
-
"node": ">=18.18.0"
|
|
51
|
-
},
|
|
52
49
|
"scripts": {
|
|
53
50
|
"prepare": "husky",
|
|
54
51
|
"clean": "node scripts/rm.js lib",
|
|
@@ -58,39 +55,37 @@
|
|
|
58
55
|
"release": "release-it",
|
|
59
56
|
"prepublish": "npm run build && npm pack",
|
|
60
57
|
"publish": "npm publish --tag latest",
|
|
61
|
-
"test": "
|
|
62
|
-
"test:watch": "
|
|
63
|
-
"coverage": "
|
|
58
|
+
"test": "jest",
|
|
59
|
+
"test:watch": "jest --watch",
|
|
60
|
+
"coverage": "jest --coverage",
|
|
64
61
|
"format": "prettier --write \"src/**/*.ts\" --cache",
|
|
65
62
|
"lint": "eslint \"src/**/*.ts\"",
|
|
66
63
|
"lint:fix": "eslint \"src/**/*.ts\" --fix"
|
|
67
64
|
},
|
|
68
65
|
"dependencies": {
|
|
69
|
-
"
|
|
70
|
-
"inversify": "6.0.2",
|
|
71
|
-
"inversify-binding-decorators": "4.0.0",
|
|
66
|
+
"express": "4.21.1",
|
|
72
67
|
"reflect-metadata": "0.2.2"
|
|
73
68
|
},
|
|
74
69
|
"devDependencies": {
|
|
75
70
|
"@codecov/vite-plugin": "^0.0.1-beta.6",
|
|
76
71
|
"@commitlint/cli": "19.2.1",
|
|
77
72
|
"@commitlint/config-conventional": "19.2.2",
|
|
78
|
-
"@expressots/core": "
|
|
73
|
+
"@expressots/core": "^3.0.0-beta.1",
|
|
74
|
+
"@expressots/shared": "0.2.0",
|
|
79
75
|
"@release-it/conventional-changelog": "8.0.1",
|
|
80
76
|
"@types/express": "4.17.21",
|
|
77
|
+
"@types/jest": "^29.5.14",
|
|
81
78
|
"@types/node": "20.14.10",
|
|
82
79
|
"@typescript-eslint/eslint-plugin": "7.16.1",
|
|
83
80
|
"@typescript-eslint/parser": "7.16.1",
|
|
84
|
-
"@vitest/coverage-v8": "2.0.3",
|
|
85
81
|
"eslint": "8.57.0",
|
|
86
82
|
"eslint-config-prettier": "9.1.0",
|
|
87
83
|
"husky": "9.1.1",
|
|
84
|
+
"jest": "29.7.0",
|
|
88
85
|
"prettier": "3.3.3",
|
|
89
86
|
"release-it": "17.6.0",
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"vite-tsconfig-paths": "4.3.2",
|
|
93
|
-
"vitest": "2.0.3"
|
|
87
|
+
"ts-jest": "29.2.5",
|
|
88
|
+
"typescript": "5.5.3"
|
|
94
89
|
},
|
|
95
90
|
"release-it": {
|
|
96
91
|
"git": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/adapter-express",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.2",
|
|
4
4
|
"description": "Expressots - modern, fast, lightweight nodejs web framework (@adapter-express)",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -46,9 +46,6 @@
|
|
|
46
46
|
"framework",
|
|
47
47
|
"server-side"
|
|
48
48
|
],
|
|
49
|
-
"engines": {
|
|
50
|
-
"node": ">=18.18.0"
|
|
51
|
-
},
|
|
52
49
|
"scripts": {
|
|
53
50
|
"prepare": "husky",
|
|
54
51
|
"clean": "node scripts/rm.js lib",
|
|
@@ -58,39 +55,37 @@
|
|
|
58
55
|
"release": "release-it",
|
|
59
56
|
"prepublish": "npm run build && npm pack",
|
|
60
57
|
"publish": "npm publish --tag latest",
|
|
61
|
-
"test": "
|
|
62
|
-
"test:watch": "
|
|
63
|
-
"coverage": "
|
|
58
|
+
"test": "jest",
|
|
59
|
+
"test:watch": "jest --watch",
|
|
60
|
+
"coverage": "jest --coverage",
|
|
64
61
|
"format": "prettier --write \"src/**/*.ts\" --cache",
|
|
65
62
|
"lint": "eslint \"src/**/*.ts\"",
|
|
66
63
|
"lint:fix": "eslint \"src/**/*.ts\" --fix"
|
|
67
64
|
},
|
|
68
65
|
"dependencies": {
|
|
69
|
-
"
|
|
70
|
-
"inversify": "6.0.2",
|
|
71
|
-
"inversify-binding-decorators": "4.0.0",
|
|
66
|
+
"express": "4.21.1",
|
|
72
67
|
"reflect-metadata": "0.2.2"
|
|
73
68
|
},
|
|
74
69
|
"devDependencies": {
|
|
75
70
|
"@codecov/vite-plugin": "^0.0.1-beta.6",
|
|
76
71
|
"@commitlint/cli": "19.2.1",
|
|
77
72
|
"@commitlint/config-conventional": "19.2.2",
|
|
78
|
-
"@expressots/core": "
|
|
73
|
+
"@expressots/core": "^3.0.0-beta.1",
|
|
74
|
+
"@expressots/shared": "0.2.0",
|
|
79
75
|
"@release-it/conventional-changelog": "8.0.1",
|
|
80
76
|
"@types/express": "4.17.21",
|
|
77
|
+
"@types/jest": "^29.5.14",
|
|
81
78
|
"@types/node": "20.14.10",
|
|
82
79
|
"@typescript-eslint/eslint-plugin": "7.16.1",
|
|
83
80
|
"@typescript-eslint/parser": "7.16.1",
|
|
84
|
-
"@vitest/coverage-v8": "2.0.3",
|
|
85
81
|
"eslint": "8.57.0",
|
|
86
82
|
"eslint-config-prettier": "9.1.0",
|
|
87
83
|
"husky": "9.1.1",
|
|
84
|
+
"jest": "29.7.0",
|
|
88
85
|
"prettier": "3.3.3",
|
|
89
86
|
"release-it": "17.6.0",
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"vite-tsconfig-paths": "4.3.2",
|
|
93
|
-
"vitest": "2.0.3"
|
|
87
|
+
"ts-jest": "29.2.5",
|
|
88
|
+
"typescript": "5.5.3"
|
|
94
89
|
},
|
|
95
90
|
"release-it": {
|
|
96
91
|
"git": {
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setEngineEjs = setEngineEjs;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const resolve_render_1 = require("../resolve-render");
|
|
6
|
-
/**
|
|
7
|
-
* Ejs defaults
|
|
8
|
-
* @type {EjsOptions}
|
|
9
|
-
* @constant
|
|
10
|
-
* @default
|
|
11
|
-
*/
|
|
12
|
-
const EJS_DEFAULTS = {
|
|
13
|
-
viewsDir: (0, path_1.join)(process.cwd(), "views"),
|
|
14
|
-
viewEngine: "ejs",
|
|
15
|
-
serverOptions: {},
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Set Ejs as the view engine
|
|
19
|
-
* @param {Application} app - The express application
|
|
20
|
-
* @param {EjsOptions} [options=EJS_DEFAULTS] - The ejs options
|
|
21
|
-
*/
|
|
22
|
-
async function setEngineEjs(app, options = EJS_DEFAULTS) {
|
|
23
|
-
(0, resolve_render_1.packageResolver)("ejs");
|
|
24
|
-
app.set("view engine", options.viewEngine || EJS_DEFAULTS.viewEngine);
|
|
25
|
-
app.set("views", options.viewsDir || EJS_DEFAULTS.viewsDir);
|
|
26
|
-
if (Array.isArray(options.viewsDir)) {
|
|
27
|
-
options.viewsDir.forEach((dir) => {
|
|
28
|
-
app.set("views", dir);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
if (options.serverOptions) {
|
|
32
|
-
app.locals = {
|
|
33
|
-
...app.locals,
|
|
34
|
-
...options.serverOptions,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setEngineHandlebars = setEngineHandlebars;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const core_1 = require("@expressots/core");
|
|
6
|
-
const resolve_render_1 = require("../resolve-render");
|
|
7
|
-
/**
|
|
8
|
-
* Handlebars defaults
|
|
9
|
-
* @type {HandlebarsOptions}
|
|
10
|
-
* @constant
|
|
11
|
-
* @default
|
|
12
|
-
*/
|
|
13
|
-
const HANDLEBARS_DEFAULTS = {
|
|
14
|
-
viewEngine: "hbs",
|
|
15
|
-
viewsDir: (0, path_1.join)(process.cwd(), "views"),
|
|
16
|
-
partialsDir: (0, path_1.join)(process.cwd(), "views/partials"),
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Default partials directory
|
|
20
|
-
*/
|
|
21
|
-
const DEFAULT_PARTIALS_DIR = (0, path_1.join)(process.cwd(), "views/partials");
|
|
22
|
-
/**
|
|
23
|
-
* Set Handlebars as the view engine
|
|
24
|
-
* @param {express.Application} app - The express application
|
|
25
|
-
* @param {HandlebarsOptions} [options=HANDLEBARS_DEFAULTS] - The handlebars options
|
|
26
|
-
*/
|
|
27
|
-
async function setEngineHandlebars(app, options = HANDLEBARS_DEFAULTS) {
|
|
28
|
-
const logger = new core_1.Logger();
|
|
29
|
-
try {
|
|
30
|
-
const hbs = (0, resolve_render_1.packageResolver)("hbs");
|
|
31
|
-
hbs.registerPartials(options.partialsDir || DEFAULT_PARTIALS_DIR);
|
|
32
|
-
app.set("view engine", options.viewEngine || HANDLEBARS_DEFAULTS.viewEngine);
|
|
33
|
-
app.set("views", options.viewsDir || HANDLEBARS_DEFAULTS.viewsDir);
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
logger.error(error.message, "handlebars-config");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setEnginePug = setEnginePug;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const resolve_render_1 = require("../resolve-render");
|
|
6
|
-
/**
|
|
7
|
-
* Pug defaults
|
|
8
|
-
* @type {PugOptions}
|
|
9
|
-
* @constant
|
|
10
|
-
* @default
|
|
11
|
-
*/
|
|
12
|
-
const PUG_DEFAULTS = {
|
|
13
|
-
viewEngine: "pug",
|
|
14
|
-
viewsDir: (0, path_1.join)(process.cwd(), "views"),
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Set Pug as the view engine
|
|
18
|
-
* @param {express.Application} app - The express application
|
|
19
|
-
* @param {PugOptions} [options=PUG_DEFAULTS] - The pug options
|
|
20
|
-
*/
|
|
21
|
-
async function setEnginePug(app, options = PUG_DEFAULTS) {
|
|
22
|
-
(0, resolve_render_1.packageResolver)("pug");
|
|
23
|
-
app.set("view engine", options.viewEngine || PUG_DEFAULTS.viewEngine);
|
|
24
|
-
app.set("views", options.viewsDir || PUG_DEFAULTS.viewsDir);
|
|
25
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { IApplicationMessageToConsole } from "@expressots/core";
|
|
2
|
-
import express from "express";
|
|
3
|
-
import { ServerEnvironment } from "./application-express.types";
|
|
4
|
-
/**
|
|
5
|
-
* Public Interface for the WebServer application.
|
|
6
|
-
*/
|
|
7
|
-
export interface IWebServerPublic {
|
|
8
|
-
/**
|
|
9
|
-
* Start listening on the given port and environment.
|
|
10
|
-
* @param port - The port number to listen on.
|
|
11
|
-
* @param environment - The server environment.
|
|
12
|
-
* @param consoleMessage - Optional message to display in the console.
|
|
13
|
-
*/
|
|
14
|
-
listen(port: number, environment: ServerEnvironment, consoleMessage?: IApplicationMessageToConsole): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Get the underlying HTTP server. (default: Express.js)
|
|
17
|
-
* @returns The underlying HTTP server after initialization.
|
|
18
|
-
*/
|
|
19
|
-
getHttpServer(): Promise<express.Application>;
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Application } from "express";
|
|
2
|
-
import { Options } from "./ejs.types";
|
|
3
|
-
/**
|
|
4
|
-
* Ejs options
|
|
5
|
-
* @typedef {Object} EjsOptions
|
|
6
|
-
* @property {string | Array<string>} viewsDir - The path to the views folder
|
|
7
|
-
* @property {string} viewEngine - The view engine
|
|
8
|
-
* @property {ejs.Options} [serverOptions] - The server options
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
export type EjsOptions = {
|
|
12
|
-
viewsDir?: string | Array<string>;
|
|
13
|
-
viewEngine?: string;
|
|
14
|
-
serverOptions?: Options;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Set Ejs as the view engine
|
|
18
|
-
* @param {Application} app - The express application
|
|
19
|
-
* @param {EjsOptions} [options=EJS_DEFAULTS] - The ejs options
|
|
20
|
-
*/
|
|
21
|
-
export declare function setEngineEjs(app: Application, options?: EjsOptions): Promise<void>;
|