0.0.7 • Published 1 year ago

guaka v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

GUAKA

trunk

Guaka is a dependency injection tool for TypeScript. With it you can build DDD aplication.

Main features includes:

  • property based injection
  • constructor based injection
  • singleton and transient services
  • support for multiple DI containers

Installation

Note: This installation guide is for usage with TypeScript

To start using Guaka install the required packages via NPM:

npm install guaka reflect-metadata

As a last step, you need to enable emitting decorator metadata in your Typescript config. Add these two lines to your tsconfig.json file under the compilerOptions key:

"emitDecoratorMetadata": true,
"experimentalDecorators": true,

Now you are ready to use Guaka with Typescript!

Basic Usage

import { Repository, Domain } from 'guaka';

@Repository({key: 'exampleRepository'})
class ExampleRepository {
  logMessage() {
    console.log('Hello!!');
  }
}

@Domain({key: 'exampleDomain'})
class ExampleDomain {
  ExampleRepository:ExampleRepository;

  constructor(
    @inject({ key:"exampleRepository"}) ExampleRepository?: ExampleRepository,
  ) {
    this.ProductRespository = ProductRespository;
  }
}

const serviceInstance = Factory('DOMAIN', 'exampleDomain');
// we request an instance of ExampleService from Guaka

serviceInstance.ExampleRepository.logMessage()
// logs "Hello!" to the console
0.0.3

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago