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
- Host: GitHub
- URL: https://github.com/ovesco/diosaur
- Owner: ovesco
- Created: 2020-05-29T08:49:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T08:44:08.000Z (over 3 years ago)
- Last Synced: 2025-03-25T06:04:52.298Z (about 1 year ago)
- Topics: deno, dependency-injection, nodejs, service-injection, typescript
- Language: TypeScript
- Homepage: https://ovesco.github.io/diosaur/
- Size: 2.78 MB
- Stars: 3
- Watchers: 0
- Forks: 3
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
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/)