npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lamnhan/seminjecto

v1.0.6

Published

Simple dependency injection for Typescript modules.

Downloads

1

Readme

@lamnhan/seminjecto

Simple dependency injection for Typescript modules.

License Code Style: Google Support me on Patreon PayPal Ask me anything

Introduction

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
    );
  }
}

Benefits

  • One approaching for any project
  • Clean project structure
  • No need for extra IOC libraries
  • Easy to test (using @lamnhan/testea)
  • Easy to generate documentation (using @lamnhan/ayedocs)

Installation

Install as glocal CLI app.

npm install -g @lamnhan/seminjecto

Skeletons

These skeletons can be use to faster setup a project. You can either clone them manually or using the command semidi new <name>:

Convention

This standalization is applied to any project unders Seminjecto convention.

Helpers

VSCode

The file settings.json unders .vscode folder provides configuration for excluding certain content in VSCode (and other configs you may need):

See .vscode/settings.json

GIT

Files are ignored by GIT:

See .gitignore

Linter/prettier

Linter and prettier using @google/gts:

  • The .eslintrc.json: the Eslint config file
  • The .prettierrc.js: the Prettier config file
  • Lint by: npm run lint

Documentation

Automatic document generation using @lamnhan/ayedocs:

  • The file .ayedocsrc.js provides configuration
  • Output will be found in the docs folder
  • Generate docs by: npm run docs

Testing

Testing using @lamnhan/testea:

  • Generate spec files by: testea generate
  • All specs files are under test folder
  • Run test by: npm run test

Continuous integration

See .travis.yml

Vendor code

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.

Special deployment

Libraries for Node projects are deployed with the src/ folder that contains all the content.

Special project will be deployed from the .deploy/ folder:

  • Refer using a script (... deploy) to generate .deploy/, then deploy, then remove .deploy/.
  • Pass --dry-run to the script to generate .deploy/ only.

Project types

Seminjecto supports these types of Node project, where source code is hosted under src folder.

Library

A library is a project that can using in other projects.

A library is organized into a pair of file and folder:

  • The public-api.ts file: where you export anything you want other project to access
  • The lib folder: the lirary home, contains index.ts (class Lib) and groups of source code by type (services, ...)

See package.json for properties and scripts.

CLI

A CLI project is an extended of library, a pair of file and folder added:

  • The bin.ts file: the cli logic
  • The cli 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.

Express

A ExpressJS project is an extended of library, a pair of file and folder added:

  • The www.ts file: the app logic
  • The app folder: the app home, contains index.ts (class App) and groups of source code by type (routes, ...)

Sheetbase

A Sheetbase project is an extended of library, a pair of file and folder added:

  • The www.ts file: the app logic
  • The app folder: the app home, contains index.ts (class App) and groups of source code by type (routes, ...)

Workspace

A Workspace project is an extended of library, a pair of file and folder added:

  • The hook.ts file: the addon logic
  • The addon folder: the addon home, contains index.ts (class Addon) and groups of source code by type (sidebars, modals, ...)

Simple dependency injection for Typescript modules.

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 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 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 destination

Options:

  • -n, --nested: Nested under a folder.
  • -t, --typing: Save typing file.

Display help.

Usage:

semidi help

Any other command is not suppoted.

Usage:

semidi <cmd>

License

@lamnhan/seminjecto is released under the MIT license.


⚡️ This document is generated automatically using @lamnhan/ayedocs.