A CRUD application built on Node JS using the Express Framework and Postgresql for database management.
Checks if customer exists using ID. If it does, then fetches it from the database.
{
"status": true,
"message": "Customer found",
"customer": {
"id": {Customer ID},
"name": {Customer Name},
"email": {Customer Email}
}
}
{
"status": false,
"message": "Internal server error",
}
{
"status": false,
"message": "Customer not found"
}
Fetches the customer list from the database.
{
"status": true,
"message": "Customer list found",
"customerList": [
{
"id": {Customer 1 ID},
"name": {Customer 1 Name},
"email": {Customer 1 Email}
},
{
"id": {Customer 2ID},
"name": {Customer 2 Name},
"email": {Customer 2 Email}
},
...
]
}
{
"status": false,
"message": "Customer list not found"
}
{
"status": false,
"message": "Internal server error",
}
Adds the customer to the database. It also checks if the email does not already exist.
BODY
name: {Customer Name}
email: {Customer Email}
{
"status": true,
"message": "Customer added",
"id": {New Customer's ID}
}
{
"status": false,
"message": "Invalid request body"
}
{
"status": false,
"message": "Email already exists"
}
{
"status": false,
"message": "Internal server error",
}
Edits the customer in the database. It also checks - (1) if the customer exists and (2) if the new email does not already exist.
BODY
id: {Customer ID}
name: {Customer Name}
email: {Customer Email}
{
"status": true,
"message": "Customer updated",
"id": {Updated Customer's ID}
}
{
"status": false,
"message": "Invalid request body"
}
{
"status": false,
"message": "Email already exists"
}
{
"status": false,
"message": "Customer does not exist"
}
{
"status": false,
"message": "Internal server error",
}
Deletes the customer from the database. It also checks if the customer exists and returns the deleted customer.
BODY
id: {Customer ID}
{
"status": true,
"message": "Customer deleted",
"deletedCustomer": {
"id": {Customer ID},
"name": {Customer Name},
"email": {Customer Email}
}
}
{
"status": false,
"message": "Invalid request body"
}
{
"status": false,
"message": "Customer does not exist"
}
{
"status": false,
"message": "Internal server error",
}