Task: To build a simple image repository.
Created by: Jeffrey Ha (LinkedIn, Github, Devpost)
Technologies used: Node.js, Express.js, Firebase, Amazon S3, Multer, Mocha Chai
Features
- Upload images (up to 5) as either anonymous or registered user.
- Delete image
- Download image
- View specific image or all images
- Create user
- View user or all created users
Setup
- Create an .env file (template given below).
- Create a credentials file under
C:\Users\{user}\.aws\
(template given below). - Run npm install in the root directory of the folder.
To run the project, run npm start. It will create a web server under the port 5000, assuming it is available.
To run the tests for this project... (has a default 10,000 ms timeout)
- Ensure that the server is running already (run npm start) in a separate command line interface.
- In another command line interface, run npm test to execute all tests.
All API Routes
- GET /api/images/ - Retrieves all uploaded (public) images.
- POST /api/images/upload - Uploads one or more (up to 5) images to the server.
- GET /api/images/i/{IMAGE_ID}/ - Retrieves information of the image.
- DELETE /api/images/i/{IMAGE_ID} - Deletes the image from the server.
- POST /api/images/i/{IMAGE_ID}/set_public - Updates whether the image is "public" or not.
- GET /api/images/i/{IMAGE_ID}/download - Downloads the specified image, assuming it is public.
- GET /api/users/ - Retrieves all registered users.
- POST /api/users/register - Registers a new user in the database.
- GET /api/users/u/{USER_ID}/ - Retrieves information of the user (as well as their uploaded [public] images).
- POST /api/users/u/{USER_ID}/upload - Uploads one or more (up to 5) images to the server under this user's id.
.env Template
FIREBASE_API_KEY=
FIREBASE_AUTH_DOMAIN=
FIREBASE_DATABASE_URL=
FIREBASE_PROJECT_ID=
FIREBASE_STORAGE_BUCKET=
FIREBASE_MESSAGING_SENDER_ID=
FIREBASE_APP_ID=
FIREBASE_MEASUREMENT_ID=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY_ID=
AWS_BUCKET_NAME=
credentials Template
[default]
aws_access_key_id=
aws_secret_access_key=