Well, this is my first nodeJS app. I've been researching on RESTful API best practices, but none seem to directly address my concerns.
Here is the format which my data is saved in the data base:
'1212': {
name: 'Plasma Blaster',
id: 1212,
price: 7000,
quantity: 10,
minimum: false,
date: new Date().toISOString().replace('T', ' ').substr(0, 19),
image: 'http://www.img.com/image.jpeg',
},
Each item is saved with the string of it's unique id as the key.BTW, I'm using simple data structures as db.
A get request made to the endpoint /api/v1/store/products returns the result:
{
"completed": true,
"message": "get products sucessful",
"products": {
"1370": {
"name": "DH-17 blaster pistol",
"id": 1370,
"price": 600,
"quantity": 10,
"minimum": "false",
"date": "2018-11-05 13:29",
"image": "http://www.img.com/image.jpeg"
},
"1473": {
"name": "C-22 fragmentation grenade",
"id": 1473,
"price": 200,
"quantity": 16,
"minimum": "false",
"date": "2018-11-05 13:32",
"image": "http://www.img.com/image.jpeg"
},
"8385": {
"name": "Neon-Blue Crystal Lightsaber",
"id": 8385,
"price": 200,
"quantity": 1,
"minimum": "true",
"date": "2018-11-05 13:35",
"image": "http://www.img.com/image.jpeg"
},
"0836": {
"name": "Treppus-2 vibroblade",
"id": 836,
"price": 2000,
"quantity": 1,
"minimum": "true",
"date": "2018-11-05 13:36",
"image": "http://www.img.com/image.jpeg"
}
}
}
I need know if this an accepted structure. Api response structures I've worked with before are Array of objects. I'll also appreciate help in formatting it better.