JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q30196F
  • License MIT

IoC library mirroring Java Spring Framework's implementation

Package Exports

  • ecmascript-ioc
  • ecmascript-ioc/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ecmascript-ioc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ecmascript-ioc

An IoC library mirroring Java Spring Framework's implementation.

Features

  • Annotations: Use decorators like @component, @repository, @service, @controller, and @autowired.
  • Dependency Injection: Automatic dependency resolution and injection.
  • TypeScript 5.0 Decorators: Uses the new ECMAScript decorators without reflect-metadata.

Installation

npm install ecmascript-ioc

Usage guide

import { autowired, service, repository } from 'ecmascript-ioc';

@repository("UserRepository")
class UserRepository {
  public get(): string {
    return "username";
  }

  public save(username: string): void {
    console.log(`Persist user: ${username}.`);
  }
}

@service("UserService")
class UserService {
  @autowired("UserRepository")
  private repository!: UserRepository;

  public getUser(): string {
    return this.repository.get();
  }

  public createUser(username: string): void {
    this.repository.save(username);
  }
}