go-shop

module
v0.0.0-...-6bf1803 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2020 License: Apache-2.0

README

go-shop

A simple web shop API written in go

Badges:

Go Report Card Actions Status

Usage You can run a make to lint and build the images

To start the server on port 8080 use:

PORT=8080 make run-server

⚠ This command blocks. You need to run it in the backgournd of you intend to continue using this terminal session while still having the server running

To start the client on port 8080 use:

PORT=8080 make run-client

If the port is not given, then both client and server start by default on port 9090.

API

Path Scope
/api/v1/login Use basic auth to login to the application. This will generate a JWT Token that will be used for subsequent requests
/api/v1/logout Blacklists the current JWT Token so it is no longer usable
/api/v1/cart/add Add a product to the cart. This is a POST requests that expects a message of the form {"id":1,"quantity":2} where id is the product ID and quantity is how much you want. This errors out when your cart contains more products of a certain kind that are available in stock. The response contains the current contents of your shopping cart
/api/v1/cart/checkout Attemps to buy the items in your cart. Has a chance to fail. Should block any other people from trying to buy the items

Directories

Path Synopsis
cmd
internal
pkg
products/inventory/mocks
Package mock_inventory is a generated GoMock package.
Package mock_inventory is a generated GoMock package.
products/store/mocks
Package mock_store is a generated GoMock package.
Package mock_store is a generated GoMock package.
users/authentication/mocks
Package mock_authentication is a generated GoMock package.
Package mock_authentication is a generated GoMock package.
users/store/mocks
Package mock_store is a generated GoMock package.
Package mock_store is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL