Skip to content

nalbion/appert-shopping

Repository files navigation

appert-shopping

Coverage Status

  • Test the API at https://appert-shopping.herokuapp.com/swagger
  • Each user is automatically assigned a cartId cookie which is used in subsequent requests.
  • The shopping cart API supports promotions which can be externally configured. Various instances of freebie etc can be configured, and new promotion types can be added without modifications to the PromotionsService code.

TODO

  • authorisation - users should be able to (optionally) log in and access the cart they were using anonymously or from a different device.
  • checkout & payment
  • load/persist to DB, database migration schemas
  • atomic DB transactions on take/return item from inventory
  • CI/CD pipeline (most supporting scripts are provided)
  • Monitor http://localhost:9020/api/health & update to ping DB. If the optional query string ?version=0.0.1 does not match the build version a HTTP status 409 is returned.

Usage

docker build -t nalbion/appert-shopping .
docker run --rm -p 9020:9020 nalbion/appert-shopping

Alternatively, use the npm scripts:

npm run docker:build
npm run docker:run

When running, API documentation is available at http://localhost:9020/swagger. Example requests are provided in the "Try it out" sections.

The schema appert-shopping-api.yml is generated by npm run generate-schema and is also available at http://localhost:9020/swagger/spec.

Development

npm install
npm run test:tdd

or

npm run start:dev

IntelliJ users can execute requests from shopping-cart.http

CI/CD

Scripts to run in CI/CD are provided in ci/scripts


Folder Structure

  • src/api: routes and controllers for api endpoints
  • src/models: definitions of data structure
  • src/service: contains business logic that may be shared amongst routes

Getting Started

  • Need a database? Consider Prisma

Prerequisites

Running on localhost

Create an environment (.env) file by copying the (.env.example) and replacing empty variables.


Testing

Lint

$ npm run lint
$ npm run format

or, do it all together as the pre-commit hook does:

$ npm run format:lint:fix

Unit Tests

$ npm test

Coverage Report

$ npm run coverage

Technology


Best Practices and Coding Patterns

About

Shopping Cart API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors