New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@injets/decorators

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@injets/decorators

Use injets Dependency Injection with decorators

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-87.5%
Maintainers
1
Weekly downloads
 
Created
Source

@injets/decorators

A lightweight dependency injection library for Node.js and TypeScript with decorators.

Installation

npm install @injets/core @injets/decorators

Usage

import { Container, Provider, Inject, mount } from '@injets/decorators';

@Provider()
class Provider1 {
  method() {
    console.log('Provider1 method');
  }
}

@Provider()
class Provider2 {
  @Inject()
  provider1!: Provider1;

  method() {
    console.log('Provider2 method', this.provider1);
  }
}

@Module({
  providers: [Provider1, Provider2],
})
class MyApp {}

const app = mount(MyApp)

app.resolve(Provider2).method(); // Provider2 method Provider1 {}

API

Decorators

Module(options: ModuleOptions = {})

Marks a class as a module (container)

Provider(mode?: ProviderMode)

Marks a class as a provider

Inject(token?: Token)

Injects a provider into a property or constructor parameter

Options

ModuleOptions

Options for the container.

interface ContainerOptions {
  isGlobal?: boolean;
  imports?: Class[];
  providers?: Array<Class | Provider>;
  exports?: Token[];
}

Other packages

  • @injets/functional - Support for functional programming in JavaScript and TypeScript.
  • @injets/core - A lightweight dependency injection library for Node.js and TypeScript.

FAQs

Package last updated on 01 Nov 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc