Skip to content

adeyinkaoresanya/vending-machine-api

Repository files navigation

vending-machine-api

Goal


This is an api for a vending machine that allows users with the role of “seller” to add, update or remove products, while users with the role of “buyer” role can deposit coins into the machine and make purchases.

Set up


  • Install Node.js, MongoDB
  • Install project dependencies
  • clone this repo
  • update env with example.env
  • run npm run start:dev

How to clone this repo

git clone https://github.com/adeyinkaoresanya/vending-machine-api.git

Install project dependencies

npm install

Update .env with example.env

Run a development server

npm run start:dev

Models


users

Name Type Comments
id autoincrement
uuid string
username string
role string
password string
created_at timestamp
updated_at timestamp

products

Name Type Comments
id autoincrement
uuid string
title string Title of the product
cost int Price of the product
sellerId string ID of the seller who created the product
created_at timestamp
updated_at timestamp
deleted_at timestamp

deposits

Name Type Comments
id autoincrement
uuid string
buyerId string ID of the buyer
amount int How much the product was bought for
created_at timestamp
updated_at timestamp

Usage


Creating a user

  • Route: /api/vd/user/create
  • Method: POST
  • Body
{
"firstName": "Jane",
"lastName": "Bakes",
"userName": "janebakes",
"email": "[email protected]",
"password": "janebakes236"

}

Response

{"firstName":"Jane",
"lastName":"Bakes",
"userName":"janebakes",
"email":"[email protected]"}

Get a list of users

  • Route: /api/vd/user/list
  • Method: GET

Response

```json
[{"firstName":"Jane",
"lastName":"Bakes",
"userName":"janebakes",
"email":"[email protected]"},

{"firstName":"John,
"lastName":"Doe",
"userName":"johndoe",
"email":"[email protected]"}]

Get a single user

  • Route: /api/vd/user/:id
  • Method: GET

Response

```json

{"firstName":"Jane",
"lastName":"Bakes",
"userName":"janebakes",
"email":"[email protected]"}



Contributor


Adeyinka Oresanya

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published