TramwayJS

Service

A class responsible for handing business logic.

Create

tramway create:service ProductService

Locations

  • Implementation: src/services
  • Dependency Injection: src/config/services/services.js

Example

export default class ProductService {
constructor(repository) {
this.repository = repository;
}
async get() {
return await this.repository.get();
}
}

Dependency Injection

import { ProductService } from '../../services';
export default {
"service.product": {
"class": ProductService,
"constructor": [
{"type": "service", "key": "repository.product"},
]
}
}