Git Product home page Git Product logo

shopify-developer-challenge's Introduction

Shopify Developer Challenge - Francesco Virga

API URL: https://shopify-developer-challenge.herokuapp.com

File Structure

The structure of this project is how I have designed most APIs I've worked on in the past. I split up my routes, controllers, models, config, and errors in separate folders. All external SDKs required (only mongoose in this case) have their own configuration file under the config folder.

The entry point is index.js, which creates the express app and adds basic middleware. It then passes the express app into router.js which mounts all routes and additional middleware.

Note: I realize that the .env file should usually be ignored from git but to allow for local testing I included it for this specific case

API Design

The API design is simple. All product routes live at /api/products and all shopping cart routes live at /api/carts. Errors are handled by error middleware and a catch-all route shows a basic API landing page.

Database

A MongoDB database is used for this project, along with mongoose as an ODM. I have found this combination to work extremely well for Node.js projects as it is both very powerful (ie. aggregation, geo queries, population, etc.) but also quick and easy to setup for a small project. The MongoDB deployment is managed through mLab.

Hosting

The API is deployed and hosted on Heroku. Although I considered deploying on IaaS such as Google Compute Engine or AWS EC2, I chose to go with Heroku as it comes at zero cost for such tier and provides a nice interface to quickly deploy an application without the need for much additional configuration. Its add-ons also allow for seamless integration with mLab.

Security

For security, I added a simple rate limiter to protect against DDoS attacks (see router.js). If this application were to be scaled across multiple servers, this would have to be configured with a data store such as Redis or Mongo as storing in memory would not support tracking across multiple instances.

I also added Helmet middleware to protect against various attacks through HTTP headers. Although it is not a fully robust security framework, it is a simple way to add a bit of a security layer to an express app.

Documentation

The API documentation was made using Slate. It outline all routes and errors associated with the API and can be found here.

Tests

I wrote integration tests using Jest and Supertest. These tests cover basic usage of the API and can be found in the tests folder. To run them, simply enter npm test after cloning the repository.

shopify-developer-challenge's People

Contributors

francescov1 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.