-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve logs of pdf generation, to include conventionId (for debug pu…
…rposes)
- Loading branch information
Showing
14 changed files
with
77 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
8 changes: 6 additions & 2 deletions
8
back/src/domains/core/pdf-generation/adapters/InMemoryPdfGeneratorGateway.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { HtmlToPdfRequest } from "shared"; | ||
import { PdfGeneratorGateway } from "../ports/PdfGeneratorGateway"; | ||
|
||
export class InMemoryPdfGeneratorGateway implements PdfGeneratorGateway { | ||
public async make(htmlContent: string): Promise<string> { | ||
return `PDF_OF >> "${htmlContent}"`; | ||
public async make({ | ||
htmlContent, | ||
conventionId, | ||
}: HtmlToPdfRequest): Promise<string> { | ||
return `PDF_OF convention ${conventionId} >> "${htmlContent}"`; | ||
} | ||
} |
This file contains 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
This file contains 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
4 changes: 3 additions & 1 deletion
4
back/src/domains/core/pdf-generation/ports/PdfGeneratorGateway.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { HtmlToPdfRequest } from "shared"; | ||
|
||
export interface PdfGeneratorGateway { | ||
make(htmlContent: string): Promise<string>; | ||
make(params: HtmlToPdfRequest): Promise<string>; | ||
} |
15 changes: 10 additions & 5 deletions
15
back/src/domains/core/pdf-generation/use-cases/HtmlToPdf.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
import { | ||
ConventionJwtPayload, | ||
ConventionRelatedJwtPayload, | ||
HtmlToPdfRequest, | ||
errors, | ||
zStringMinLength1, | ||
htmlToPdfRequestSchema, | ||
} from "shared"; | ||
import { UseCase } from "../../UseCase"; | ||
import { PdfGeneratorGateway } from "../ports/PdfGeneratorGateway"; | ||
|
||
export class HtmlToPdf extends UseCase<string, string, ConventionJwtPayload> { | ||
protected inputSchema = zStringMinLength1; | ||
export class HtmlToPdf extends UseCase< | ||
HtmlToPdfRequest, | ||
string, | ||
ConventionJwtPayload | ||
> { | ||
protected inputSchema = htmlToPdfRequestSchema; | ||
|
||
constructor(protected pdfGeneratorGateway: PdfGeneratorGateway) { | ||
super(); | ||
} | ||
|
||
protected async _execute( | ||
htmlContent: string, | ||
params: HtmlToPdfRequest, | ||
jwtPayload?: ConventionRelatedJwtPayload, | ||
): Promise<string> { | ||
if (!jwtPayload) throw errors.user.unauthorized(); | ||
return this.pdfGeneratorGateway.make(htmlContent); | ||
return this.pdfGeneratorGateway.make(params); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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