Avatar api - #141
Merged
Merged
Conversation
3m1n3nc3
requested changes
Aug 20, 2026
3m1n3nc3
left a comment
Contributor
There was a problem hiding this comment.
CI is failing, please resolve.
Contributor
Author
|
@3m1n3nc3 ci fixed kindly review |
7 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All tasks complete. Here's a summary of the implementation:
Avatar Upload and Processing API — Implementation Summary
Files created/modified
New files (8):
src/types/avatar.types.ts— Statuses, records, DTOs, storage provider interface, configuration constantssrc/services/storage/in-memory-storage.ts— In-memory dev-fake storage provider + MIME sniffing + dimension extraction (PNG/JPEG/GIF/WebP)src/services/asset-validation.service.ts— Server-side validation: size bounds, magic-byte MIME sniffing, spoofing detection, dimension extractionsrc/services/avatar.service.ts— Orchestrates upload intent, validation, variant production, atomic promotion, replacement/retirement, and deletionsrc/controllers/avatar.controller.ts— REST endpoints with Zod validation, auth checks, error mappingsrc/routes/v1/avatar.routes.ts— Route definitions under/users/me/avatartests/asset-validation.service.test.ts— 18 tests: MIME spoofing, oversize, undersize, dimension extraction, type normalisationtests/in-memory-storage.test.ts— 22 tests: CRUD, signed URLs, credential leakage, MIME sniffing, dimension extractiontests/avatar.service.test.ts— 20 tests: intent, finalize, cross-user access, double-finalize, SHA-256, replacement, deletiontests/avatar.controller.test.ts— 20 tests: auth, validation, error mapping, success pathsModified files (4):
prisma/schema.prisma— AddedAvatarandAvatarVariantmodels with proper relationssrc/types/index.ts— Added avatar type exportssrc/routes/v1/users.routes.ts— Mounted avatar routes at/me/avatarsrc/routes/index.ts— No change needed (avatar routes are nested under users)API Endpoints
Acceptance criteria coverage
userIdon the avatar recordNote
closes #134