Giter Site home page Giter Site logo

cart-service's Introduction

Cart service

This is an implementation in Golang of a cart microservice extracted from a monolith migration. The current version is a work in progress and it is not fully completed.

Status

Things that are working.

Things that are sort of working.

  • Basic authentication: Currently, the list of users/passwords are hard coded.
  • Database: The persistence layer is currently a SQLite database in memory with automatic migrations. It is good enough for development, but not for production.

Things that are not working.

  • /cart/{cartId}/item endpoint.
  • Unit testing.
  • Dockerfile.
  • General polishing.

Getting started

Requirements

  • Go 1.15
  • SQLite 3.33.0

How to build & run

cd /cmd/cart
go mod download
go build
./cart

Some examples

Unauthorised access

❯ http GET http://localhost:3000/cart
HTTP/1.1 401 Unauthorized
Access-Control-Allow-Methods: POST,GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH
Access-Control-Allow-Origin: *
Content-Length: 67
Content-Type: application/json; charset=utf-8

{
    "description": "Unauthorised",
    "error": "Unauthorised",
    "description": "Unauthorised"
}

Create a cart

❯ http POST http://user:user@localhost:3000/cart
HTTP/1.1 201 Created
Access-Control-Allow-Methods: POST,GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH
Access-Control-Allow-Origin: *
Content-Length: 131
Content-Type: application/json; charset=utf-8

{
    "created_at": "2020-09-05T21:51:38.9030783+02:00",
    "id": 1,
    "items": null,
    "update_at": "2020-09-05T21:51:38.9030783+02:00",
    "user_id": 2
}

Retrieve a cart

❯ http GET http://user:user@localhost:3000/cart/1
HTTP/1.1 200 OK
Access-Control-Allow-Methods: GET,GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH
Access-Control-Allow-Origin: *
Content-Length: 131
Content-Type: application/json; charset=utf-8

{
    "created_at": "2020-09-05T21:51:38.9030783+02:00",
    "id": 1,
    "items": null,
    "update_at": "2020-09-05T21:51:38.9030783+02:00",
    "user_id": 2
}

cart-service's People

Contributors

threkk avatar

Stargazers

 avatar

Watchers

 avatar  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.