Image Repository
January 13, 2021 · View on GitHub
Summer 2021 Shopify Developer Intern Challenge Question
Table of Contents
- Project Title
About the Project
This repository houses the API for the Image Repository project. Motivation for this project came as a need for upcoming developers to increasing their chances of having real-world software development experience.
Folder Structure
.
├── .github # Compiled files
├── database # Database migration scripts and seeders
├── docs # Documentation files
├── resources # Email template files
├── src # Source files
├── tests # Automated tests
└── README.md
HTTP Requests
All API requests are made by sending a secure HTTPS request using one of the following methods, depending on the action being taken:
POSTCreate a resourceGETGet a resource or list of resourcesPATCH/PUTUpdate a resource(s)DELETEDelete a resource
For POST and PATCH requests, the body of your request may include a JSON payload.
HTTP Response Codes
Each response will be returned with one of the following HTTP status codes:
200OKThe request was successful400Bad RequestThere was a problem with the request (security, malformed)401UnauthorizedThe supplied API credentials are invalid403ForbiddenThe credentials provided do not have permissions to access the requested resource404Not FoundAn attempt was made to access a resource that does not exist in the API500Server ErrorAn error on the server occurred
Sample HTTP Response
- For a
successresponse, the server will return a response of this format:
{
"status": "success",
"message": "success message"
"data": { ... }
}
- For an
errorresponse, the server will return a response of this format:
{
"status": "error",
"error": {
"message": "error message",
"trace": {
"statusCode": <status-code>
}
}
}
Project Status
Getting Started
Dependencies
Third-Party Services
- SendGrid for emails & marketing.
Sequelizeas ORM.Argon2for password hashing and encryption.Express-Validatorfor server-side validation.Handlebars(withMJML) for email template.Swagger UI Expressfor API documentation.Winstonfor logging.
Installing/Running Locally
-
Clone (or fork) repository
- git clone https://github.com/meetKazuki/image-repository.git - cd image-repository - npm install (or npm i, as the spirit decides) -
Create a PostgreSQL database by running the
cmdbelow:createdb -h localhost -p 5432 -U postgres <database_name> -
Create/configure a
.envfile with your credentials. A sample.env.examplefile has been provided to get you started. Make a duplicate of.env.exampleand rename to.env, then configure your credentials. -
Two
npmscripts are available to spin up the server:npm run devspins up the server and watch for file changesnpm run dev:debugspins up the server and attaches a debugger to it
-
Other
npmscripts are also available for handling database migration and database seeding:npm run db:migrateruns script that is responsible for creating tables and their columns in the database,db:migrate:undo: undoes the effect ofnpm run db:migrate,db:reset: undoes all the migrations, then runs migration on the database,db:seed: responsible for seeding records in the database,
Release Process
To get new changes to production, a release branch is created off develop and merged into master. This triggers a Github action that deploys code to production.
An example release branch is release/2.0.1.
Versioning
This project uses Semantic Versioning. For a list of available versions, see the repository tag list.
Payload
- Project Specifications
- Project Entities (Models)
- SwaggerHub (API Documentation)
- API on Staging Environment
How to Get Help
Notice a bug? please open an issue. Need more clarification on any part of the code base? Contact Desmond.
Contributing
Please review CONTRIBUTING.md for details on our code of conduct and development process.
Further Reading
Authors
See also the list of contributors who participated in this project.
License
Yet to be decided