Giter Club home page Giter Club logo

in-memory-webshop-api's Introduction

In-memory webshop API

A simple webshop server with in-memory dummy database instead of an actual database. For use in the Frontend Architecture lessons, to learn about:

  • React context / global state
  • Handling authentication in the frontend

How to run it

  • Install the dependencies with npm install
  • Run the server with npm start
  • Visit it at http://localhost:4000, or use HTTPie to test it out from your terminal, like the examples below

Features included

Login

http -v POST http://localhost:4000/login [email protected] password=supersecret

If you send along the right email and password, this will result in a response like so:

{
  "token": "eyJhbGciOiJIUzI1N..."
}

Get all products

http://localhost:4000/products

http -v GET http://localhost:4000/products

Get a single product

http://localhost:4000/products/2

http -v GET http://localhost:4000/products/2

Get all users

http://localhost:4000/users

http -v GET http://localhost:4000/users

Get a single user

http://localhost:4000/users/2

http -v GET http://localhost:4000/users/2

Get your shopping cart's contents

http -v GET http://localhost:4000/cart Authorization:"Bearer eyJhbGciOiJIUzI1N..."

(Put in the whole JWT token though, that you got from first logging in.)

Putting an item in your cart, of changing the quantity

http -v POST http://localhost:4000/cart productId:=2 quantity:=5 Authorization:"Bearer eyJhbGciOiJIUzI1N..."

(Put in the whole JWT token though, that you got from first logging in.)

Removing an item from your cart entirely

http -v DELETE http://localhost:4000/cart productId:=3 Authorization:"Bearer eyJhbGciOiJIUzI1N..."

(Put in the whole JWT token though, that you got from first logging in.)

Features not included

  • Actual persistence of the data. Every time the server restarts, the dummy data is back to where it was. We'll learn about databases next week.

  • Actually buying and shipping the products :) What would it even mean, right?

in-memory-webshop-api's People

Contributors

kelleyvanevert avatar

Watchers

 avatar Wouter de Vos avatar James Cloos avatar Johan Kruse avatar Jeroen Bruinsma avatar Matias Garcia avatar  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.