Config: connectString Postgresql in ./app/config/config.js
- postgresql
- nodejs
- npm
## install
- npm install
- npm start
Methods: GET, POST
- http://localhost:3000/users
Response - HTTP 200:
{
"status": "success",
"message": "Users retrieved",
"data": [
{
"id": 2,
"name": "Behlül Bahadır Bölük"
},
{
"id": 1,
"name": "Bahadır Bölük"
}
]
}
-
/users/:userId
Response - HTTP 200:
{
"status": "success",
"message": "Found User",
"data": {
"id": 1,
"name": "Bahadır Bölük",
"books": {
"past": [
{
"id": 1,
"name": "test 1",
"userScore": 9
},
{
"id": 2,
"name": "test 2",
"userScore": 6
}
],
"present": [
{
"id": 3,
"name": "test 3"
}
]
}
}
}
## 3. POST
Body:
{
"name": "Behlül Bahadır Bölük"
}
required_fields = ["name"]
Response - HTTP 200:
{
"status": "success",
"message": "User created",
"data": {
"id": 1,
"name": "Behlül Bahadır Bölük"
}
}
## 4. POST - User borrowed a book with userId and bookId
-
/users/:userId/borrow/:bookId
Response - HTTP 204 No Content
-
/users/:userId/return/:bookId
Body:(Optional)
{
"score": 9
}
Response - HTTP 204 No content
## Books:
Methods: GET, POST
- http://localhost:3000/books
Response - HTTP 200:
{
"status": "success",
"message": "Books retrieved",
"data": [
{
"id": 1,
"name": "test 1"
},
{
"id": 2,
"name": "test 2"
},
{
"id": 3,
"name": "test 3"
}
]
}}
-
/books/:bookId
Response - HTTP 200:
{
"status": "success",
"message": "Found Book",
"data": {
"id": 1,
"name": "test 1",
"score": 7.75
}
}
- Getting a book which is not scored yet
{
"status": "success",
"message": "Found Book",
"data": {
"id": 1,
"name": "test 1",
"score": -1
}
}
## 3. POST
Body:
{
"name": "test 3"
}
required_fields = ["name"]
Response - HTTP 200:
{
"status": "success",
"message": "Book created",
"data": {
"id": 3,
"name": "test 3"
}
}