
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@lamnhan/seminjecto
Advanced tools
Simple dependency injection for Typescript modules.
Dependency injection is a common method for structuring modules. It is native in frontend frameworks like Angular and can be used for any JS modules in the same manner using library like InversifyJS, tsyringe, ...
But you can also manually apply DI to any module using this simple method. There is a central class (Lib for library, Cli for cli app, App for app, ...) that acts as a DI container and injector.
// the service 1
export class Service1Service {}
// the service 2 is depends on the service 1
export class Service2Service {
constructor(private service1Service: Service1Service) {}
}
// the container for all services and also the injetor
export class Lib {
service1Service: Service1Service;
service2Service: Service2Service;
constructor() {
this.service1Service = new Service1Service();
this.service2Service = new Service2Service(
this.service1Service // injects the service 1
);
}
}
Install as glocal CLI app.
npm install -g @lamnhan/seminjecto
These skeletons can be use to faster setup a project. You can either clone them manually or using the command semidi new <name>:
This standalization is applied to any project unders Seminjecto convention.
The file settings.json unders .vscode folder provides configuration for excluding certain content in VSCode (and other configs you may need):
Files are ignored by GIT:
See .gitignore
Linter and prettier using @google/gts:
.eslintrc.json: the Eslint config file.prettierrc.js: the Prettier config filenpm run lintAutomatic document generation using @lamnhan/ayedocs:
.ayedocsrc.js provides configurationdocs foldernpm run docsTesting using @lamnhan/testea:
testea generatetest foldernpm run testSee .travis.yml
When you want to include code from other projects, put them into src/lib/vendors/name.vendor.ts. For example, a function from lodash.
Add // @ts-nocheck at the top of the files to disable Typescript.
Vendor files also excluded from linting.
Libraries for Node projects are deployed with the src/ folder that contains all the content.
Special project will be deployed from the .deploy/ folder:
.deploy/, then deploy, then remove .deploy/.--dry-run to the script to generate .deploy/ only.Seminjecto supports these types of Node project, where source code is hosted under src folder.
A library is a project that can using in other projects.
A library is organized into a pair of file and folder:
public-api.ts file: where you export anything you want other project to accesslib folder: the lirary home, contains index.ts (class Lib) and groups of source code by type (services, ...)See package.json for properties and scripts.
A CLI project is an extended of library, a pair of file and folder added:
bin.ts file: the cli logiccli folder: the CLI home, contains index.ts (class Cli) and groups of source code by type (commands, ...)See bin property in package.json for CLI app registration.
A ExpressJS project is an extended of library, a pair of file and folder added:
www.ts file: the app logicapp folder: the app home, contains index.ts (class App) and groups of source code by type (routes, ...)A Sheetbase project is an extended of library, a pair of file and folder added:
www.ts file: the app logicapp folder: the app home, contains index.ts (class App) and groups of source code by type (routes, ...)A Workspace project is an extended of library, a pair of file and folder added:
hook.ts file: the addon logicaddon folder: the addon home, contains index.ts (class Addon) and groups of source code by type (sidebars, modals, ...)Command overview
Simple dependency injection for Typescript modules.
semidi [ [ ' n e w < t y p e > < n a m e > [ d e s c r i p t i o n ] ' , ' s t a r t ' , ' n ' ] , ' C r e a t e a n e w p r o j e c t . ' , [ ' - s , - - s o u r c e [ v a l u e ] ' , ' C u s t o m s o u r c e : { i n n e r _ r e p o } @ { t a g } , { o r g } / { r e p o } , { o r g } / { r e p o } @ { t a g } o r u r l . ' , ] , [ ' - i , - - s k i p - i n s t a l l ' , ' D o e s n o t i n s t a l l d e p e n d e n c y p a c k a g e s . ' ] , [ ' - g , - - s k i p - g i t ' , ' D o e s n o t i n i t i a l i z e a g i t r e p o s i t o r y . ' ] , ]semidi clean|c --skip-question --list --includes [value] --excludes [value]semidi generate|create|g <type> <dest> --nested --typingsemidi helpsemidi *Command reference
[
Usage:
semidi [ [ ' n e w < t y p e > < n a m e > [ d e s c r i p t i o n ] ' , ' s t a r t ' , ' n ' ] ,
' C r e a t e a n e w p r o j e c t . ' ,
[
' - s , - - s o u r c e [ v a l u e ] ' ,
' C u s t o m s o u r c e : { i n n e r _ r e p o } @ { t a g } , { o r g } / { r e p o } , { o r g } / { r e p o } @ { t a g } o r u r l . ' ,
] ,
[ ' - i , - - s k i p - i n s t a l l ' , ' D o e s n o t i n s t a l l d e p e n d e n c y p a c k a g e s . ' ] ,
[ ' - g , - - s k i p - g i t ' , ' D o e s n o t i n i t i a l i z e a g i t r e p o s i t o r y . ' ] ,
]
Options:
: : : :[:':n:e:w: :<:t:y:p:e:>: :<:n:a:m:e:>: :[:d:e:s:c:r:i:p:t:i:o:n:]:':,: :':s:t:a:r:t:':,: :':n:':]:,: : : : : :':C:r:e:a:t:e: :a: :n:e:w: :p:r:o:j:e:c:t:.:':,: : : : : :[: : : : : : : :':-:s:,: :-:-:s:o:u:r:c:e: :[:v:a:l:u:e:]:':,: : : : : : : :':C:u:s:t:o:m: :s:o:u:r:c:e::: :{:i:n:n:e:r:_:r:e:p:o:}:@:{:t:a:g:}:,: :{:o:r:g:}:/:{:r:e:p:o:}:,: :{:o:r:g:}:/:{:r:e:p:o:}:@:{:t:a:g:}: :o:r: :u:r:l:.:':,: : : : : :]:,: : : : : :[:':-:i:,: :-:-:s:k:i:p:-:i:n:s:t:a:l:l:':,: :':D:o:e:s: :n:o:t: :i:n:s:t:a:l:l: :d:e:p:e:n:d:e:n:c:y: :p:a:c:k:a:g:e:s:.:':]:,: : : : : :[:':-:g:,: :-:-:s:k:i:p:-:g:i:t:':,: :':D:o:e:s: :n:o:t: :i:n:i:t:i:a:l:i:z:e: :a: :g:i:t: :r:e:p:o:s:i:t:o:r:y:.:':]:,: : : :]:clean
Clean typescript output files.
Usage:
semidi clean --skip-question --list --includes [value] --excludes [value]
semidi c --skip-question --list --includes [value] --excludes [value]
Options:
-y, --skip-question: Does not ask question.-l, --list: Show list of files.-i, --includes [value]: Including files, separated by |.-e, --excludes [value]: Excluding files, separated by |.generate
Generate a resource.
Usage:
semidi generate <type> <dest> --nested --typing
semidi create <type> <dest> --nested --typing
semidi g <type> <dest> --nested --typing
Parameters:
<type>: The resource type<dest>: The resource destinationOptions:
-n, --nested: Nested under a folder.-t, --typing: Save typing file.help
Display help.
Usage:
semidi help
*
Any other command is not suppoted.
Usage:
semidi <cmd>
@lamnhan/seminjecto is released under the MIT license.
⚡️ This document is generated automatically using @lamnhan/ayedocs.
FAQs
Simple dependency injection for Typescript modules.
We found that @lamnhan/seminjecto demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.