Skip to content

Commit

Permalink
Logs to debug files upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Naulleau committed Dec 6, 2024
1 parent 383f890 commit 78df8a3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"format": "prettier --write \"src/**/*.ts\"",
"format:check": "prettier --check \"src/**/*.ts\"",
"start": "nest start",
"dev": "nest start --watch",
"dev": "dotenvx run -- nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/src/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
Expand All @@ -32,7 +32,7 @@
"drizzle:migrate": "drizzle-kit migrate",
"drizzle:migrate:prod": "pnpm drizzle-kit migrate --config dist/drizzle.config.js",
"cli:seed": "ts-node -r tsconfig-paths/register cli/seed.ts",
"cli:upload-nomination-files:local": "ts-node -r tsconfig-paths/register cli/import-nominations-from-local-file/run-import-nominations-from-local-file-cli.ts",
"cli:upload-nomination-files:local": "dotenvx run -- ts-node -r tsconfig-paths/register cli/import-nominations-from-local-file/run-import-nominations-from-local-file-cli.ts",
"scalingo:upload-nomination-files:staging": "dotenvx run -f .env.scalingo-upload.staging -f .env.scalingo-upload -- ./scripts/import-nominations-from-local-file-to-scalingo.sh",
"scalingo:upload-nomination-files:production": "dotenvx run -f .env.scalingo-upload.production -f .env.scalingo-upload -- ./scripts/import-nominations-from-local-file-to-scalingo.sh"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class FilesController {
@Query() query: FileUploadQueryDto,
@UploadedFile() file: Express.Multer.File,
) {
console.log('query', query);
const { bucket, path, fileId } = query;
return this.uploadFileUseCase.execute(
fileId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ export class UploadFileUseCase {

// Order matters, file isn't uploaded if saving in repository fails
await this.fileRepository.save(fileDocument)(trx);
console.log('files context - saved file');
await this.s3StorageProvider.uploadFile(
file,
fileName,
mimeType,
bucket,
filePath,
);
console.log('files context - uploaded file');
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class ReportsController implements IReportController {
@Param() { id }: ReportsEndpoints['attachFile']['Params'],
@UploadedFile() file: Express.Multer.File,
): Promise<void> {
console.log('attach file', id, file);
return this.attachReportFileUseCase.execute(
id,
file.originalname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ export class AttachReportFileUseCase {

// Order matters, file isn't attached if saving in repository fails
await this.reportAttachedFileRepository.save(attachedFile)(trx);
console.log('saved attached file');
await this.reportFileService.uploadFile(
attachedFile,
fileBuffer,
filePath,
);
console.log('uploaded file');
});
}
}
6 changes: 3 additions & 3 deletions apps/api/src/shared-kernel/adapters/primary/nestjs/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export const defaultApiConfig = {
scaleway: {
endpoint: { scheme: 'https', baseDomain: baseScalewayDomain },
region: 'fr-par',
encryptionKeyBase64: Buffer.from(crypto.randomBytes(32)).toString(
'base64',
),
encryptionKeyBase64:
process.env.SCW_ENCRYPTION_KEY ??
Buffer.from(crypto.randomBytes(32)).toString('base64'),
credentials: {
accessKeyId: process.env.SCW_ACCESS_KEY!,
secretAccessKey: process.env.SCW_SECRET_KEY!,
Expand Down

0 comments on commit 78df8a3

Please sign in to comment.