A basic REST API with Authentication built using Node.js and MongoDB
-
Run server.js
-
send a post request to ' URL:3000/signup ' (URL -> localhost in my case) with a json file as body containing the fields "email" and "password".
-
send a post requist to ' URL:3000/login ' with a json file as body containing the fields "email" and "password". Note down your auth token for future use.
-
There are 5 requests available to manage the records.
GET : /person
GET : /person/<person_ID>
POST : /person
PATCH : /person/<person_ID>
DELETE : /person/<person_ID>
usage: URL:3000/person
send a json body with the field { "token" : "<your auth token>" }
usage: URL:3000/person/<person_ID
send a json body with the field "{ "token" : "<your auth token>" }
usage: URL:3000/person
send a json body with the fields { "token" : "<your auth token>", "name" : "<person name>" }
you can also add an optional field "createdAt" : "<Date time>"
usage: URL:3000/person/<person_ID>
send a json body with the fields
"{ "token" : "<your auth token>",
"fields" : [ {
"propValue" : "<name of the field in record>" ,
"value" : "<the value to be updated>"
}, { "propValue" : "<name of another field in record (if you need to update)>" ,
"<the value to be updated>"}...
]
}"
NOTE : you can add as many fields as you want to update.
It should be an array of objects with two fiels namely " propName" and "value"
usage: URL:3000/person/<person_ID
send a json body with the field "{ "token" : "<your auth token>" }