Inspired by komarserjio/notejam
Notejam is a web application which allows user to sign up/in/out and create/view/edit/delete notes. Notes are grouped in pads. There will 2 part of the application. First is the backend which is provide HTTP API for the second part: the frontend which handles the UI.
Your task is to build the HTTP API application. We will name it: Notejam API.
Structure of objects (aka models or entities) used in the app:
- Note: id, pad_id, user_id, name, text, created_at, updated_at
- Pad: id, user_id, name
- User: id, email, password
See recommended "data"base schema for details.
All responses must be encoded in JSON and have the appropriate Content-Type header and HTTP status code.
Content-Type: "application/json"
POST /notes/create
{
"pad_id": 1,
"user_id": 1,
"name": "Hello, World!"
"text": "Lorem ipsum"
}
Attribute | Description |
---|---|
pad_id | Pad ID |
user_id | User ID |
name | Note title/name |
text | Note body |
Returns:
{
"data": [
{
"id": 1,
"pad_id": 1,
"user_id": 1,
"name": "Hello, World!",
"text": "Lorem ipsum"
}
]
}
Error | Description |
---|---|
400 | any required attribute is not present |
409 | The desired name is already in use by the user_id |
GET /notes/<note_id>
Returns:
{
"data": [
{
"id": 1,
"pad_id": 1,
"user_id": 1,
"name": "Hello, World!",
"text": "Lorem ipsum"
}
]
}
Error | Description |
---|---|
404 | The desired note_id is not found |
PUT /notes/<note_id>
{
"pad_id": 1,
"user_id": 1,
"name": "Hello, World!"
"text": "Lorem ipsum"
}
Returns:
{
"data": [
{
"id": 1,
"pad_id": 1,
"user_id": 1,
"name": "Hello, World!",
"text": "Lorem ipsum"
}
]
}
Error | Description |
---|---|
404 | The desired note_id is not found |
400 | any required attribute is not present |
DELETE /notes/<note_id>
Returns:
{
"data": null
}
Error | Description |
---|---|
404 | The desired note_id is not found |
POST /pads/create
{
"user_id": 1,
"name": "General"
}
Attribute | Description |
---|---|
user_id | User ID |
name | Pad title/name |
Returns:
{
"data": [
{
"id": 1,
"user_id": 1,
"name": "General"
}
]
}
Error | Description |
---|---|
400 | any required attribute is not present |
409 | The desired name is already in use by the user_id |
GET /pads/<pad_id>
Returns:
{
"data": [
{
"id": 1,
"user_id": 1,
"name": "General"
}
]
}
Error | Description |
---|---|
404 | The desired pad_id is not found |
PUT /pads/<pad_id>
{
"user_id": 1,
"name": "General"
}
Returns:
{
"data": [
{
"id": 1,
"user_id": 1,
"name": "General"
}
]
}
Error | Description |
---|---|
404 | The desired pad_id is not found |
400 | any required attribute is not present |
DELETE /pads/<pad_id>
Returns:
{
"data": null
}
Error | Description |
---|---|
404 | The desired pad_id is not found |
Any kind of tests are very desirable.
Recommended test cases
- Note can be successfully created
- Note can't be created if required fields are missing
- Note can't be edited if required fields are missing
- Note can be successfully deleted
- Pad can be successfully created
- Pad can't be created if required fields are missing
- Pad can't be edited if required fields are missing
- Pad can be successfully deleted