$ git clone https://github.com/wcrichter/persons-api.git
$ cd persons-api
$ npm install
$ npm start
GET
POST
DELETE
PUT
Returns a JSON object representing a person for a given person id.
id
- The primary key of the person to retrieve.
GET /persons/[email protected]
Example Response (Success):
{
"_id": "[email protected]",
"_rev": "3-3a94a40198e67b8d67909e6aa156ec70",
"firstName": "David",
"lastName": "Puddy",
"email": "[email protected]",
"type": "person"
}
Example Response (Error):
{
"error": "not_found",
"reason": "missing",
"name": "not_found",
"status": 404,
"message": "missing"
}
Adds a JSON object representing a person with specified keys and values.
doc
- The document of the person to add to the data.
POST /persons
Body:
{
"_id": "[email protected]",
"firstName": "Frank",
"lastName": "Costanza",
"email": "[email protected]",
"type": "person"
}
Example Response (Success):
{
"ok": true,
"id": "[email protected]",
"rev": "1-b052be6014e8625f93649d10c5d090e4"
}
Example Response (Error):
{
"error": "conflict",
"reason": "Document update conflict.",
"name": "conflict",
"status": 409,
"message": "Document update conflict."
}
Delete a JSON object representing a person with a given id.
id
- The id of the person to delete from the database.
DELETE /persons/[email protected]
Body:
{
"_id": "[email protected]",
"firstName": "Frank",
"lastName": "Costanza",
"email": "[email protected]",
"type": "person"
}
Example Response (Success):
{
"ok": true,
"id": "[email protected]",
"rev": "2-34783470fb39a24b6581849403caa7b5"
}
Example Response (Error):
{
"name": "not_found",
"status": 404,
"message": "deleted",
"reason": "deleted",
"error": "not_found"
}
Adds a JSON object representing a person with specified keys and values.
doc
- The document of the person to add to the data.
POST /persons
Body:
{
"_id": "[email protected]",
"firstName": "Frank",
"lastName": "Costanza",
"email": "[email protected]",
"type": "person"
}
Example Response (Success):
{
"ok": true,
"id": "[email protected]",
"rev": "1-b052be6014e8625f93649d10c5d090e4"
}
Example Response (Error):
{
"error": "conflict",
"reason": "Document update conflict.",
"name": "conflict",
"status": 409,
"message": "Document update conflict."
}
Update a JSON object (representing a person) with a new JSON object with a given id.
id
- The id of the person to update from the database.
DELETE /persons/[email protected]
Body:
{
"_id": "[email protected]",
"_rev": "3-ab7eef2f9976fd1a6c37743f6ac3fa59",
"firstName": "Elaine",
"lastName": "Bennis",
"email": "[email protected]",
"type": "person"
}
This new object body updates the email value from [email protected] to [email protected]
Example Response (Success):
{
"ok": true,
"id": "[email protected]",
"rev": "4-918291f0b62f9941a55c1178ddb44d09"
}
Example Response (Error):
{
"name": "conflict",
"status": 409,
"message": "Document update conflict.",
"reason": "Document update conflict.",
"error": "conflict"
}
Returns a JSON object containing all 'person' documents from the database.
id
- The id of the person to update from the database.
GET /persons
Example Response (Success):
[
{
"_id": "[email protected]",
"_rev": "1-3b4b0fa77d27c252f20fb36dc9ecae5c",
"firstName": "Bob",
"lastName": "Saccamano",
"email": "[email protected]",
"type": "person"
},
{
"_id": "[email protected]",
"_rev": "5-56a069d8a3d0a6f36ebe09641a377b0a",
"firstName": "Chris",
"lastName": "Richter",
"email": "[email protected]",
"type": "person"
},
{
"_id": "[email protected]",
"_rev": "3-3a94a40198e67b8d67909e6aa156ec70",
"firstName": "David",
"lastName": "Puddy",
"email": "[email protected]",
"type": "person"
},
{
"_id": "[email protected]",
"_rev": "4-918291f0b62f9941a55c1178ddb44d09",
"firstName": "Elaine",
"lastName": "Bennis",
"email": "[email protected]",
"type": "person"
},
]
Example Response (Error):
Cannot GET /people