- I installed and used joi for data validation, without joi this server will not function, to install it you can use:
npm i joi
Alternatively you can install all npm packages from my package.json (which will include joi):
npm i
- The data input format is
{
"name": "username",
"age" : 35
}
The server attaches the id to the new user automatically, the server will not allow an id to be attached to the json body input
- The port chosen for local testing is:
3000
, alternatively you may set a preferred PORT using the process.env.PORT variable, this can be done,
using cmd:
set PORT=3333
using powershell:
$env:PORT=3333
using bash/zsh:
export PORT=3333
-
The id is being generated by randomly picking a number ranging from
1-1000
as long as it has not already been used. Normally this would be generated using uuid, though for the sake of the assignment setup and testing it was kept as integers. -
Due to the increased complexity of generating random unique numbers with a higher number of users, this server is limited to a maximum of
15
users. -
I used the imsomnia client to test this server and have added my insomnia.json export to this github page for easy testing. Upon importing, the testing methods can be found on the
DEBUG
section. You can download imsomnia for free at: https://insomnia.rest/download