1 getCourses(): Promise<any> {
2 return new Promise(resolve => {
3 resolve(this.courses);
4 });
5 }
6
7 getCourse(courseId): Promise<any> {
8 let id = Number(courseId);
9 return new Promise(resolve => {
10 const course = this.courses.find(course => course.id === id);
11 if (!course) {
12 throw new HttpException('Course does not exist', 404)
13 }
14 resolve(course);
15 });
16 }
1import { Injectable, HttpException } from '@nestjs/common';
2import { COURSES } from './courses.mock';
3
4@Injectable()
5export class CoursesService {
6 courses = COURSES;
7}