/image-repository

Summer 2021 Shopify Developer Intern Challenge Question

Primary LanguageJavaScriptMIT LicenseMIT

Image Repository

Summer 2021 Shopify Developer Intern Challenge Question

Table of Contents

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:

  • POST Create a resource
  • GET Get a resource or list of resources
  • PATCH/PUT Update a resource(s)
  • DELETE Delete 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:

  • 200 OK The request was successful
  • 400 Bad Request There was a problem with the request (security, malformed)
  • 401 Unauthorized The supplied API credentials are invalid
  • 403 Forbidden The credentials provided do not have permissions to access the requested resource
  • 404 Not Found An attempt was made to access a resource that does not exist in the API
  • 500 Server Error An error on the server occurred
Sample HTTP Response
  • For a success response, the server will return a response of this format:
{
  "status": "success",
  "message": "success message"
  "data": { ... }
}
  • For an error response, the server will return a response of this format:
{
  "status": "error",
  "error": {
    "message": "error message",
    "trace": {
      "statusCode": <status-code>
    }
  }
}

Project Status

Run in Postman Deploy to Heroku Staging

Getting Started

Dependencies

Third-Party Services
  • SendGrid for emails & marketing.
  • Sequelize as ORM.
  • Argon2 for password hashing and encryption.
  • Express-Validator for server-side validation.
  • Handlebars (with MJML) for email template.
  • Swagger UI Express for API documentation.
  • Winston for 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 cmd below:

      createdb -h localhost -p 5432 -U postgres <database_name>
  • Create/configure a .env file with your credentials. A sample .env.example file has been provided to get you started. Make a duplicate of .env.example and rename to .env, then configure your credentials.

  • Two npm scripts are available to spin up the server:

    • npm run dev spins up the server and watch for file changes
    • npm run dev:debug spins up the server and attaches a debugger to it
  • Other npm scripts are also available for handling database migration and database seeding:

    • npm run db:migrate runs script that is responsible for creating tables and their columns in the database,
    • db:migrate:undo: undoes the effect of npm 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

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

Back to top