-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
458 additions
and
443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
packages/mern-sample-app/app-node-express/src/decorators/autowired.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { IocServiceDecoratorMetadataEntry } from "@org/app-node-express/lib/bottlejs"; | ||
import { iocRegistry } from "@org/app-node-express/lib/bottlejs"; | ||
|
||
export function autowired(_target: undefined, context: ClassFieldDecoratorContext) { | ||
const componentName = String(context.name).toLowerCase(); | ||
IocServiceDecoratorMetadataEntry.for(context).addDependency(componentName); | ||
export function autowired(name?: string) { | ||
return function (_target: undefined, context: ClassFieldDecoratorContext) { | ||
const fieldName = String(context.name); | ||
const computedName = name?.toLowerCase() ?? fieldName.toLowerCase(); | ||
IocServiceDecoratorMetadataEntry.for(context).addDependency(computedName); | ||
|
||
return function () { | ||
return iocRegistry.inject(componentName); | ||
return function () { | ||
return iocRegistry.inject(computedName); | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/mern-sample-app/app-node-express/src/decorators/inject.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { IocServiceDecoratorMetadataEntry } from "@org/app-node-express/lib/bottlejs"; | ||
import { type NoArgsClass } from "@org/lib-commons"; | ||
|
||
export function inject<T extends NoArgsClass>(name?: string) { | ||
return function (target: T, context: ClassDecoratorContext<T>) { | ||
const className = String(context.name); | ||
const computedName = name?.toLowerCase() ?? className.toLowerCase(); | ||
const iocServiceDecoratorMetadataEntry = IocServiceDecoratorMetadataEntry.for(context); | ||
iocServiceDecoratorMetadataEntry.setName(computedName); | ||
iocServiceDecoratorMetadataEntry.setClass(target); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.