- npm init
- node install --save
- express
- mongoose
- cors
- docker
- docker run -d --name cs-forum-2022-mongo -e MONGO_INITDB_ROOT_USERNAME=user -e MONGO_INITDB_ROOT_PASSWORD=password -e MONGO_INITDB_DATABASE=cs-forum-2022 -p 27018:27017 -v $PWD/mongo-entrypoint/:/docker-entrypoint-initdb.d/ mongo
List all of the threads in the database
- GET
- /forum
- N/A
- 200
- 500 == Any Error
[
{
"_id": "60a480fbf9c872478ed3da2b",
"user_id": "163480fbf9c872478ed3da98",
"description": "cool description",
"name": "The Name",
"category": "Category Name",
"createdAt": "2022-06-08T03:14:53.086Z",
"updatedAt": "2022-06-08T03:14:53.086Z",
"__v": 0,
"user": {
"_id": "163480fbf9c872478ed3da98",
"username": "[email protected]",
"fullname": "John Doe",
"__v": 0
}
},
{
"_id": "jd9834jc8849cjf84830294j",
"user_id": "908480fbf9c872478ed3d867",
"description": "another cool description",
"name": "The Name",
"category": "Category Name",
"createdAt": "2022-06-08T03:14:53.086Z",
"updatedAt": "2022-06-08T03:14:53.086Z",
"__v": 0,
"user": {
"_id": "908480fbf9c872478ed3d867",
"username": "[email protected]",
"fullname": "Jane Doe",
"__v": 0
}
}
]
Get a specific thread
- GET
- /forum/{id}
- N/A
- 200
- 404 == Not Found
- 500 == Any Other Error
{
"_id": "60a480fbf9c872478ed3da2b",
"user_id": "908480fbf9c872478ed3d867",
"description": "cool description",
"name": "The Name",
"category": "Category Name",
"createdAt": "2022-06-08T03:14:53.086Z",
"updatedAt": "2022-06-08T03:14:53.086Z",
"posts": [
{
"_id": "60a480fbf9c872478ed3da2b",
"user_id": "8ea480fbf9c872478ed3d84c",
"body": "The body of the post",
"thread_id": "60a480fbf9c872478ed3da2b",
"createdAt": "2022-06-08T03:14:53.086Z",
"updatedAt": "2022-06-08T03:14:53.086Z",
"user": {
"_id": "8ea480fbf9c872478ed3d84c",
"username": "[email protected]",
"fullname": "John Doe",
"__v": 0
}
}
}
],
"__v": 0,
"user": {
"_id": "908480fbf9c872478ed3d867",
"username": "[email protected]",
"fullname": "John Doe",
"__v": 0
}
},
Create a new thread. Any argument that is left out will default.
- Strings ==
""
- Boolean ==
false
- POST
- /thread/
{
"name": "",
"category": "",
"description": ""
}
- 201
- 401 == Not Authenticated
- 500 == Any Error
{
"_id": "60a480fbf9c872478ed3da2b",
"user_id": "908480fbf9c872478ed3d867",
"description": "cool description",
"name": "The Name",
"category": "Category Name",
"createdAt": "2022-06-08T03:14:53.086Z",
"updatedAt": "2022-06-08T03:14:53.086Z"
"__v": 0
}
Removes an existing forum and its posts.
- DELETE
- /forum/{id}
- N/A
- 200
- 401 == Not Authenticated
- 403 == Not Authorized
- 404 == Not Found
- 500 == Any Other Error
{
"_id": "60a480fbf9c872478ed3da2b",
"user_id": "908480fbf9c872478ed3d867",
"description": "cool description",
"name": "The Name",
"category": "Category Name",
"createdAt": "2022-06-08T03:14:53.086Z",
"updatedAt": "2022-06-08T03:14:53.086Z",
"posts": [
{
"_id": "60a480fbf9c872478ed3da2b",
"user_id": "8ea480fbf9c872478ed3d84c",
"body": "The body of the post",
"thread_id": "60a480fbf9c872478ed3da2b",
"createdAt": "2022-06-08T03:14:53.086Z",
"updatedAt": "2022-06-08T03:14:53.086Z"
}
],
"__v": 0
},
Create a new post. Any argument that is left out will default.
- Strings ==
""
- Boolean ==
false
- POST
- /thread/
{
"thread_id": "",
"description": ""
}
- 201
- 401 == Not Authenticated
- 500 == Any Error
{
"_id": "60a480fbf9c872478ed3da2b",
"user_id": "8ea480fbf9c872478ed3d84c",
"body": "The body of the post",
"thread_id": "60a480fbf9c872478ed3da2b",
"createdAt": "2022-06-08T03:14:53.086Z",
"updatedAt": "2022-06-08T03:14:53.086Z"
}
Removes an existing posts.
- DELETE
- /thread/{thread_id}/post/{post_id}
- N/A
- 200
- 401 == Not Authenticated
- 403 == Not Authorized
- 404 == Not Found
- 500 == Any Other Error
{
"_id": "60a480fbf9c872478ed3da2b",
"user_id": "8ea480fbf9c872478ed3d84c",
"body": "The body of the post",
"thread_id": "60a480fbf9c872478ed3da2b",
"createdAt": "2022-06-08T03:14:53.086Z",
"updatedAt": "2022-06-08T03:14:53.086Z"
}
Authenticates.
- POST
- /session
{
"username": "",
"password": ""
}
- 201
- 401 == Not Authenticated
Authenticates.
- GET
- /session
- N/A
- 200
- 401 == Not Authenticated
Create a user.
- POST
- /user/
{
"username": "",
"password": "",
"full_name": ""
}
- 201
- 500 == Any Error
{
"_id": "62b70f66f4dae754a38ccc9c",
"username": "[email protected]",
"fullname": "John Doe",
"password": "pass",
"__v": 0
}