Last active
August 3, 2022 11:14
-
-
Save myas92/3d60342223a0e6a6015578694ba4386e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@nestjs/common'; | |
import { CreateVideoDto } from './dto/create-video.dto'; | |
import { UpdateVideoDto } from './dto/update-video.dto'; | |
const allVideos = [ | |
{ | |
id: 1, | |
name: "tom-and-jerry", | |
duration: '3 mins', | |
title: 'Tom & Jerry' | |
}, | |
{ | |
id: 2, | |
name: "soul", | |
duration: '4 mins', | |
title: 'Soul' | |
}, | |
{ | |
id: 3, | |
name: "outside-the-wire", | |
duration: '2 mins', | |
title: 'Outside the wire' | |
}, | |
]; | |
@Injectable() | |
export class VideoService { | |
create(createVideoDto: CreateVideoDto) { | |
return 'This action adds a new video'; | |
} | |
findAll() { | |
return allVideos | |
} | |
findOne(id: number) { | |
const video = allVideos.find(video => video.id == id) | |
if (video) { | |
return video | |
} | |
else { | |
return `There is no video with id ${id}` | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment