-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Backend] Store scraped movie data #10
Conversation
f4bcafe
to
5992df9
Compare
async create (@Body() createMovieDto: CreateMovieDto) { | ||
if (createMovieDto.movieTitles.length === 0) { | ||
throw new BadRequestException('At least one movie title is required') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delegate the validation responsibility to the DTO instead of the Controller. I left a suggestion up there that you can remove this if
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Will remove this
export class CreateMovieDto { | ||
genre: string | ||
director: string | ||
duration: number | ||
subtitles: string[] | ||
releaseDate: Date | ||
movieTitles: CreateMovieTitleDto[] | ||
} | ||
|
||
export class CreateMovieTitleDto { | ||
language: string | ||
title: string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export class CreateMovieDto { | |
genre: string | |
director: string | |
duration: number | |
subtitles: string[] | |
releaseDate: Date | |
movieTitles: CreateMovieTitleDto[] | |
} | |
export class CreateMovieTitleDto { | |
language: string | |
title: string | |
} | |
import { createZodDto } from "nestjs-zod" | |
import { z } from "nestjs-zod/z" | |
const CreateMovieSchema = z.object({ | |
genre: z.string(), | |
director: z.string(), | |
duration: z.number().int(), | |
subtitles: z.string().array().optional(), | |
releaseDate: z.date(), | |
movieTitles: z.object({ | |
language: z.string(), | |
title: z.string() | |
}).array().nonempty() | |
}) | |
export class CreateMovieDto extends createZodDto(CreateMovieSchema) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is mainly since I didn't push the pairing session we did :D will do now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realized now they come in this branch, would it be OK to merge this branch to master as is and then merge the other one with the DTO changes removing the "if" above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absolutely, no worries
466e24a
to
aa6877b
Compare
…prisma#2377 is resolved through prisma-multischema
Co-authored-by: Rodrigo Souza <alves.wm@gmail.com>
Make sure db tables are in plural and snake_case Co-authored-by: Rodrigo Souza <alves.wm@gmail.com>
…nt movies that are stored in the DB
3c3fbee
to
720cd5e
Compare
Sorry the delay 😅 |
Description
API
Motivation and Context
How Has This Been Tested?
Running locally and CI
Screenshots (if appropriate):
Types of changes
Checklist: