Skip to content

Services

Services are an important part of our framework and are designed so that they can be injected as a dependency.

App-Service-En Dark

Dependency injection

ZanobiJS is based on a design pattern known as dependency injection. Thanks to Awilix dependency container can be managed quickly, efficient and powerful.

Example service
import { Injectable } from "@zanobijs/common";
@Injectable()
export class ServiceExample {
constructor() {}
getHello() {
return "Hello ServiceExample";
}
}

In the following example, we see that dependency is resolved within the constructor of a controller.

Controller constructor example
// Inject the service into the controller
constructor(private sExample: ServiceExample) {}

Support us

ZanobiJS is an open source project licensed by MIT. It can grow thanks to the support of amazing people like you. If you want to join, read more here.