-
Notifications
You must be signed in to change notification settings - Fork 3
feat(PM-3317): Profile download API endpoint initial implementation #20
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
Conversation
|
|
||
| module.exports = { | ||
| generatePDF | ||
| } No newline at end of file |
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.
[💡 style]
Ensure that a newline is added at the end of the file. This is a common convention that can prevent issues with certain tools and version control systems.
src/common/helper.js
Outdated
| const awsConfig = { | ||
| s3: config.AMAZON.S3_API_VERSION, | ||
| // S3 Client configuration | ||
| const s3ClientConfig = { |
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.
[❗❗ correctness]
The s3ClientConfig object is missing the s3 key which was present in the previous awsConfig. Ensure that the S3 API version is correctly configured if required by the new SDK.
src/common/helper.js
Outdated
| } | ||
| // Upload to S3 | ||
| await getS3().upload(params).promise() | ||
| const upload = new Upload({ |
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.
[performance]
The Upload class from @aws-sdk/lib-storage is used here. Ensure that this library is compatible with the current AWS SDK version and that it handles large file uploads efficiently to avoid potential memory issues.
test/unit/MemberService.test.js
Outdated
| callback(null, { Body: Buffer.from(photoContent) }) | ||
| }) | ||
| originalS3ClientSend = S3Client.prototype.send | ||
| S3Client.prototype.send = async function (command) { |
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.
[maintainability]
Overriding S3Client.prototype.send directly can lead to issues if other tests or parts of the code rely on the original behavior. Consider using a mocking library like sinon to stub this method instead, which can provide better control and restore functionality.
test/unit/MemberService.test.js
Outdated
| callback(null) | ||
| }) | ||
| // Mock Upload class's done method for upload operations | ||
| originalUpload = Upload.prototype.done |
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.
[maintainability]
Overriding Upload.prototype.done directly can lead to issues if other tests or parts of the code rely on the original behavior. Consider using a mocking library like sinon to stub this method instead, which can provide better control and restore functionality.
| }) | ||
| } else { | ||
| actions.push((req, res, next) => { | ||
| const interceptRes = {} |
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.
[maintainability]
The interceptRes object is being created and used to bypass the response methods, but this pattern can be confusing and may lead to unexpected behavior if the middleware chain changes. Consider using a more explicit approach to handle optional authentication.
| } | ||
| } else { | ||
| next(new errors.ForbiddenError('You are not authorized to perform this action')) | ||
| req.authUser.userId = String(req.authUser.userId) |
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.
[💡 correctness]
Converting req.authUser.userId to a string is done without checking if req.authUser is defined. Although this is checked earlier, it might be safer to ensure req.authUser is always defined before accessing its properties to prevent potential runtime errors.
| awsConfig.secretAccessKey = config.AMAZON.AWS_SECRET_ACCESS_KEY | ||
| } | ||
|
|
||
| AWS.config.update(awsConfig) |
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.
[❗❗ correctness]
The AWS.config.update(awsConfig) call should be placed after the awsConfig object is fully configured, including any conditional additions like access keys. Ensure that all necessary configurations are set before updating the AWS config to avoid potential misconfigurations.
What's in this PR?
Screenshot
OOM error