Create Restful API for a image storage service that allow:
- Users can register to the system. They need to verify their account before using it (via email).
- Users can only use the system if they have an active account
- Users can upload images with png,jpg,jpeg format. The maximum size is 5MB
- User's images won't be public unless they created a shared link and share with other people.
- User's images can be used on other websites
- A user has maximum 100 images.
- A system will delete unused image(unused more than 1 year) automatically every weekends.
Infrastructure requirements:
- Local : Local Docker
- Staging: Run on VM with Docker
- Production: Host everything on AWS
Overview layers
- solutions
- deployment -> deployment scripts, dockerfiles, k8s, ...
- src
- src/application -> applications: file-storage-api, web, queues, ...
- src/domain -> Tables mapping
- src/business -> Business logic
- src/share -> Share/Common projects
- src/persistence -> TypeORM Core
- src/tool -> tools: migration data
- test -> test configuration
domain layer
application layer
business layer
persistence layer
config layer
- Install
npm install- Watch
npm run start:api:dev- Debug
3.1. Debug main app (file storage api)
F5 -> Select Debug API
3.2. Debug remote
Example: Start app in debug mode - debugger port 9229
npm run start:api:debugF5 -> Select Debug remote API
generate migration script
npm run typeorm:migration:generate ./src/persistence/database/migrations/migration-script-namecreate migration script
npm run typeorm:migration:create ./src/persistence/database/migrations/migration-script-nameshow migration
npm run typeorm migration:show
npm run typeorm migration:run
npm run typeorm migration:revertLet's assume that we already have the below high level design diagrams
Response & Response
Create Example
List Example
Update Example
Delete Example
Dataset List