POC of zombie Rest API in Node.js with Express.
git clone https://github.com/frydlewicz/zombie.git
cd zombie
npm i
cp config.sample.json config.json
npm run watch
You can test the API on my sandbox environment:
http://sandbox.frydlewicz.pl:4051
For example:
http://sandbox.frydlewicz.pl:4051/api/zombie/1
API returns an array of zombies ids already created.
GET /api/zombies
HTTP/1.1 200
Content-Type: application/json
{
"timestamp": 1598171967983,
"zombies": [ 1 ]
}
API returns an object containing creation timestamp, zombie name, array of detailed items and total value divided into currencies.
GET /api/zombie/:id
HTTP/1.1 200
Content-Type: application/json
{
"timestamp": 1598172594746,
"zombie": {
"createdAt": 1598172585337,
"name": "Zombiak",
"items": [{
"id": 2,
"name": "Trident",
"price": 200
}],
"values": {
"PLN": 200,
"USD": 54,
"EUR": 46
}
}
}
HTTP/1.1 404
Content-Type: application/json
{
"status": "error",
"error": "Zombie 1 does not exist!"
}
You have to provide a zombie name and an array of items ids, both parameters are required. API will return new zombie id.
POST /api/zombie
Content-Type: application/json
{
"name": "Zombiak",
"items": [ 2 ]
}
HTTP/1.1 200
Content-Type: application/json
{
"status": "success",
"id": 1
}
HTTP/1.1 400
Content-Type: application/json
{
"status": "error",
"error": "name is required string parameter!"
}
You can update zombie name or items ids or both at the same time.
PATCH /api/zombie/:id
Content-Type: application/json
{
"name": "Zombiaczek",
"items": [ 3 ]
}
HTTP/1.1 200
Content-Type: application/json
{
"status": "success"
}
HTTP/1.1 404
Content-Type: application/json
{
"status": "error",
"error": "Zombie 1 doesn't exist!"
}
Zombie will be deleted permanently.
DELETE /api/zombie/:id
HTTP/1.1 200
Content-Type: application/json
{
"status": "success"
}
HTTP/1.1 404
Content-Type: application/json
{
"status": "error",
"error": "Zombie 1 does not exist!"
}