-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/829 pdf backend #937
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
base: main
Are you sure you want to change the base?
Feat/829 pdf backend #937
Conversation
13d5df7
to
6cd5d2e
Compare
I took a look at your PR. I know its a WIP but just a few things I noticed:
lemme know what you think |
@@ -16,6 +17,7 @@ import { RecreationResourceModule } from "@/recreation-resource/recreation-resou | |||
AuthModule, | |||
TerminusModule, | |||
RecreationResourceModule, | |||
ResourceDocsModule, |
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.
it'd be better to have this imported under RecreationResourceModule
declare const window: any; | ||
const NodeFormData = | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
typeof window === "undefined" ? require("form-data") : null; |
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.
what is this for? window
will always be undefined right?
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.
This is a technique used to test, because running vitest with form data we can instantiate while testing.
description: "Doc title", | ||
example: "Campbell river site map", | ||
}) | ||
@IsNotEmpty() |
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.
shoud we add length and regex constraints here?
@Get(":rec_resource_id/docs/:ref_id") | ||
@ApiOperation({ | ||
summary: "Get one document resource by reference ID", | ||
operationId: "getDocumentResourceById", |
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.
should we name it getDocumentByResourceId
to be consistent with the one above?
}) | ||
@ApiResponse({ | ||
status: 404, | ||
description: "Recreation Resource document not found", |
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.
nit
should be "Recreation Resource not found"
} | ||
if (file) { | ||
if (!allowedTypes.includes(file.mimetype)) { | ||
throw new HttpException("File Type not allowed", 501); |
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.
is 501 appropriate here. isnt this a user error
await uploadFile(ref_id, file); | ||
const files = await getResourcePath(ref_id); | ||
url = this.getOriginalFilePath(files); | ||
docToUpdate["url"] = url; |
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.
when you update the original, do all the other image variants keep the same url?
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.
That was actually a good insight ! I assumed that changing the file, the URL would change ... but that was not the case.
url = this.getOriginalFilePath(files); | ||
docToUpdate["url"] = url; | ||
} | ||
const result = await this.prisma.$transaction([ |
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.
transaction is not necessary here
if (resource === null) { | ||
throw new HttpException("Recreation Resource not found", 404); | ||
} | ||
const ref_id = await createResource(); |
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.
all these dam api are called one after the other. if anyone of them fails, will it emit logs that show which one has failed?
async getById( | ||
rec_resource_id: string, | ||
ref_id: string, | ||
): Promise<RecreationResourceDocDto | null> { |
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.
will this ever return null
?
Controller, services + dam API interaction to list, create, update and delete PDF resources.