Coder Social home page Coder Social logo

ecommerce-rest-api's Introduction

e-commerce REST API

Node/Express REST API to provide typical functionality found in an ecommerce website. Users can create accounts, view products, add products to a cart, and place/view orders.

Running the app

To run locally, npm install, then npm run start

This project requires a PostgreSQL database to be running locally. Reference the ERD diagram located in the resources folder of this repo to view the structure of the tables. You can use pgAdmin to interact with the database manually.

This repo includes an example.env file that contains important environment variables for reference. Make sure to create a .env file and include all variables found in the example.env file, replacing the example values with those specific to your environment/needs.

To easily populate your database with the requisite tables, npm run create-db. This will create tables in your database if they do not already exist. The configuration for this script can be found in the setupDatabase.js file located in the root of this project.

Once the app is running locally, you can access the API at http://localhost:<your-port>

Testing

Swagger documentation available at http://localhost:<your-port>/docs

You can use various HTTP clients such as Postman or Insomnia to make requests to the API endpoints.

Note: Some endpoints are protected and require authentication. In order to properly access these endpoints, you will need to have a session cookie present when making your request. This is accessed by hitting the /auth/login endpoint first. HTTP clients will automatically store cookies and send them with subsequent requests.

Resources

Options for Extension

  • Add additional API endpoints (endpoints for categories, addresses, etc)
  • Add ability to maintain multiple carts per user
  • Add ability to interact with the API as a guest

Endpoints

Authentication

  • POST /auth/login - Login a user
  • POST /auth/logout - Logout a user
  • POST /auth/register - Register a new user

Products

  • GET /products - Get all products
  • GET /products/:id - Get a single product
  • POST /products - Create a new product
  • PUT /products/:id - Update a product
  • DELETE /products/:id - Delete a product

Orders

  • GET /orders - Get all orders
  • GET /orders/:id - Get a single order
  • POST /orders - Create a new order
  • PUT /orders/:id - Update an order
  • DELETE /orders/:id - Delete an order

Carts

  • GET /carts - Get all carts
  • GET /carts/:id - Get a single cart
  • POST /carts - Create a new cart
  • PUT /carts/:id - Update a cart
  • DELETE /carts/:id - Delete a cart

ecommerce-rest-api's People

Contributors

stacksharebot avatar abenteuerzeit avatar

Watchers

 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.