psilore / yggdrasil

Yggrdasil - Avensia assignment for frontend developer role

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Logo

Yggdrasil - Avensia assignment



mockup

Prerequisites

Requires node.js.

Installation

  1. Clone the repo
    git clone https://github.com/psilore/yggdrasil.git
  2. Change to yggdrasil directory
    cd yggdrasil/
  3. Install NPM packages
    npm install

Develop

Start yggdrasil and watch for changes on http://localhost:8003

This will also start the API to utilize the endpoints for the frontend.

$ npm run start
ℹ️ Server running at http://localhost:8003
✨ Built in 447ms

Build static files for distribution

$ npm run build
ℹ️ Server running at http://localhost:8003
✨ Built in 447ms

Tests (Jest)

$ npm run test
shoppingcart@1.0.0 test /Users/psiloc/Dev/avensia/shoppingcart
> jest

 PASS  src/components/Button/Button.test.tsx
  Button
    ✓ handles onClick (33 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        3.097 s
Ran all test suites.

Backend (Simple node app to serve JSON and some images)

I borrowed this from https://github.com/avensia/api-sample-server.git. Since it is needed for the assignment.

Serve backend content

npm run serve

API Endpoints

No parameters

Responds with an Array containing all products.

GET /products/:id

No parameters

Responds with product identified with the given :id.

No parameters

Responds with full cart. Cart items and summary.

DELETE /cart

No parameters

Empty cart. Responds with full updated cart.

POST /cart/:id

Parameters: quantity=[number]

Add quantity to item with product identified with :id. Responds with full updated cart.

PUT /cart/:id

Parameters: quantity=[number]

Update quantity to item with product identified with :id. If item doesn't exist in cart, it will be added with the given quantity. Responds with full updated cart.

DELETE /cart/:id

No parameters

Remove item with :id. Responds with full updated cart.

About

Yggrdasil - Avensia assignment for frontend developer role

License:Apache License 2.0


Languages

Language:TypeScript 98.3%Language:JavaScript 0.9%Language:HTML 0.8%