A simple web API to demonstrate relationship of customer and product in a database
Database scheme is located here
Prepare Database - The API has been tested with MySQL & Postgress database, but I believe it can work with any database. Check out TypeORM for more information. (Make sure your preferable database is installed)
Create database
mysql -u root -p;
CREATE DATABASE simple_api;
Configure TypeORM Edit the ormconfig.json
file located in the root of the project with your
databse crediatials. for example:
"type": "mysql",
"host": "localhost",
"port": 3306,
"username": "root",
"password": "admin",
"database": "simple_api",
"synchronize": true,
"logging": false,
...
Install dependencies
yarn
// or
mpm install
Load test data to the database
yarn run loadData
Start the server
yarn run dev
The port is 1337
, you can change it at config file. visit localhost:1337
GET /sim-cards
Parameter | Type | Description |
---|---|---|
none |
json |
list all simcards |
POST /orders
Parameter | Type | Description |
---|---|---|
data |
json |
create order in database |
GET /orders
Parameter | Type | Description |
---|---|---|
none |
json |
list all orders |
PUT /orders/:id
Parameter | Type | Description |
---|---|---|
data |
json |
update an existing order in database |