Skip to content

Commit

Permalink
fix(core): profile avatar upload should not return 400 error
Browse files Browse the repository at this point in the history
  • Loading branch information
charIeszhao committed Jun 3, 2024
1 parent 3917176 commit ae483a9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/routes-me/user-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ export default function userAssetsRoutes<T extends AuthedMeRouter>(...[router]:
'/user-assets',
koaGuard({
files: object({
file: uploadFileGuard,
file: uploadFileGuard.array().min(1),
}),
response: userAssetsGuard,
}),
async (ctx, next) => {
const { file } = ctx.guard.files;
const { file: bodyFiles } = ctx.guard.files;

Check warning on line 65 in packages/core/src/routes-me/user-assets.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes-me/user-assets.ts#L65

Added line #L65 was not covered by tests

const file = bodyFiles[0];
assertThat(file, 'guard.invalid_input');

Check warning on line 68 in packages/core/src/routes-me/user-assets.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes-me/user-assets.ts#L67-L68

Added lines #L67 - L68 were not covered by tests
assertThat(file.size <= maxUploadFileSize, 'guard.file_size_exceeded');
assertThat(
allowUploadMimeTypes.map(String).includes(file.mimetype),
Expand Down

0 comments on commit ae483a9

Please sign in to comment.