Complete the code to create a basic NestJS service class.
import { Injectable } from '@nestjs/common'; @Injectable() export class [1] { getHello(): string { return 'Hello World!'; } }
Complete the code to inject the service into a controller constructor.
import { Controller } from '@nestjs/common'; import { AppService } from './app.service'; @Controller() export class AppController { constructor(private readonly [1]: AppService) {} }
Fix the error in the service method to return a string.
export class AppService { getHello(): [1] { return '123'; } }
Fill both blanks to create a service method that returns a greeting with a name parameter.
export class AppService { getGreeting([1]: string): string { return `Hello, [2]!`; } }
Fill all three blanks to create a service that injects a repository and uses it in a method.
import { Injectable } from '@nestjs/common'; import { [1] } from './user.repository'; @Injectable() export class UserService { constructor(private readonly [2]: [1]) {} findAll() { return this.[2].findAllUsers(); } }
