项目作者: kisulken

项目描述 :
Store API ready to run on Kubernetes
高级语言: Go
项目地址: git://github.com/kisulken/shopifyStoreAPI.git
创建时间: 2018-09-23T19:30:09Z
项目社区:https://github.com/kisulken/shopifyStoreAPI

开源协议:

下载


Code for Shopify Winter Internship challenge 2019.

shopifyStoreAPI is an application that provides basic RESTful online store functionality.

Installation with Docker

compose yourself

  1. $ git clone https://github.com/kisulken/shopifyStoreAPI
  2. $ cd shopifyStoreAPI
  3. $ docker-compose build
  4. $ docker-compose up

or run from the existing image

  1. $ docker run -it kisulken/shopifystoreapi:v5

also, do not forget to populate your database

  1. $ docker exec shopifystoredb psql -U postgres-dev dev < dump.sql

kubernetes mounting

  1. $ kubectl create -f app-service.yaml,app-deployment.yaml,app-claim0-persistentvolumeclaim.yaml,db-deployment.yaml,db-service.yaml
  2. $ kubectl port-forward $DB_POD_NAME 5432:5432
  3. ... in another window import dump.sql
  4. $ psql -h localhost -p 5432 -U postgres-dev dev

API endpoints

endpoint methods
/store GET, POST
/store/:storeid GET, PATCH, DELETE
/store/:storeid/products GET, POST
/store/:storeid/products/:productid GET, PATCH, DELETE
/store/:storeid/products/:productid/items GET, POST
/store/:storeid/products/:productid/items/:itemid GET, DELETE
/store/:storeid/products/:productid/items/:itemid/order POST, DELETE
/store/:storeid/orders GET, POST
/store/:storeid/orders/:orderid GET, DELETE

API responses

All API endpoints will respond with a content-type application/json, corresponding http codes and contain a valid json data.

GET methods will respond with requested data i.e store information, product information etc. in case of success

  1. [
  2. {
  3. "id": 1,
  4. "name": "My very cool store",
  5. "description": "Descriptive description"
  6. }
  7. ]

“not found” in case if the requested data was not located in the database

  1. {
  2. "status": "fail",
  3. "data": "not found"
  4. }

POST methods in case of successful insertion will respond with

  1. {
  2. "status": "ok",
  3. "data": id
  4. }

where id is a decimal number representing a unique identifier of the object

All other methods in case of success will respond with

  1. {
  2. "status": "ok"
  3. }

and in case of failure

  1. {
  2. "status": "fail",
  3. "data": "error message"
  4. }

API docs

1. Store

  • /store

GET - returns all available stores.

POST - create a new store.

  1. {
  2. "name": "My cool store",
  3. "description": "Store description"
  4. }
  • /store/:storeid

GET - get specified store with id.

PATCH - update a specific store’s information.

DELETE - delete a specific store.

All the endpoints below follow the same pattern of GET, POST, PATCH, DELETE as the store endpoints described above.

2. Products

  • /store/:storeid/products

GET

POST

  1. {
  2. "name": "Phone",
  3. "price": 999.9
  4. }
  • /store/:storeid/products/:productid

GET, PATCH, DELETE

3. Items

  • /store/:storeid/products/:productid/items

GET

POST

  1. json body is not required
  • /store/:storeid/products/:productid/items/:itemid

GET, DELETE

  • /store/:storeid/products/:productid/items/:itemid/order?id=yourOrderId

POST - Adds an item with :itemid to the existing order with a specified ID automatically adding a price of the product to the total

DELETE - Removes an item with :itemid from the existing order with a specified ID automatically deducting the cost of the item

4. Orders

  • /store/:storeid/orders

GET - returns all non-empty orders.

POST - creates a new empty order.

  1. json body is not required
  • /store/:storeid/orders/:orderid

GET - get a specific order.

DELETE - delete a specific order (all the related items must be unattached/removed beforehand).


Author: Daniil Furmanov @ github.com/kisulken