Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 656 Bytes

File metadata and controls

32 lines (22 loc) · 656 Bytes

Service

1 What Does a Service Do?

Service is a class decorated with @Service, and can be injected into any other classes like Controller, Middleware.

2 Term

Service uses dependency injection, for the details: wiki

3 Usage

@Service()
class UserService {
  // any logic
}

@RestController('/users')
class UserController {
  @Inject()
  private userService: UserService;

  @Get('')
  public indexAction() {
    this.userService.listUsers();
  }
}

The example UserService decorated with @Service, and then it is used in UserController.