An open API service indexing awesome lists of open source software.

https://github.com/ovesco/diosaur

A dependency injection library for Deno and Node
https://github.com/ovesco/diosaur

deno dependency-injection nodejs service-injection typescript

Last synced: about 1 year ago
JSON representation

A dependency injection library for Deno and Node

Awesome Lists containing this project

README

          

# Diosaur
#### A small dependency injection for Node and Deno.

Diosaur is a small dependency injection solution written in Typescript for Deno and node which aims at making you write the minimum
of code, avoiding obvious bindings and other repetitive stuff. It internally depends on `reflect-metadata` to guess
the maximum indications out of your code, but still allows you for finer definition of your services.

## Please note that you require Typescript to use this library, as it makes usage of Annotations to work.

## Example
```typescript
import 'reflect-metadata';
import { Service, Parameter, Inject, setParameter, getContainer } from 'diosaur';

@Service()
class Doggo {
constructor(@Parameter('doggoName') private name: string) {}

bark() {
return this.name.toUpperCase();
}
}

@Service()
class JonSnow {

@Inject()
private doggo: Doggo;

yell() {
return `I'm Jon with my doggo ${this.doggo.bark()} !`;
}
}

setParameter('doggoName', 'Ghost');

const container = await getContainer();
const jon = container.get(JonSnow);
console.log(jon.yell());
```

## Documentation
All documentation for the library can be found here.
[Documentation](https://ovesco.github.io/diosaur/)