diff --git a/util/APIDOCS.md b/APIDOCS.md similarity index 60% rename from util/APIDOCS.md rename to APIDOCS.md index ec2448a..b5b9c9b 100644 --- a/util/APIDOCS.md +++ b/APIDOCS.md @@ -1,9 +1,7 @@ # API documentation of Akf-forum -Akf-forum has got an API for other clients etc. - -You can find examples in `tests` folder. +Akf-forum has got an API for AJAX, other clients etc. ## Authorization You need this headers for send request to API: @@ -13,6 +11,7 @@ You need this headers for send request to API: "password": "testPassword" } ``` +But in front end, the API will works with session. ## How to request? @@ -35,31 +34,33 @@ You need this headers for send request to API: - POST `/api/messages/:id/react/:type` for react to a message. ### Example request: -```GET /api/messages/1``` +GET ```/api/messages/0``` #### Example API Output: - ```json - { - "status": 200, - "result": - { - "content": "First message", - "time": 1647178873587, +```json +{ + "_id": "63067429bc01da866fad508b", + "threadID": "0", + "author": { + "id": "0", + "name": "Akif9748", + "avatar": "https://cdn.discordapp.com/avatars/539506680140922890/abd74d10aac094fc8a5ad5c86f29fdb9.png?size=1024", + "time": "2022-08-24T18:54:55.666Z", "deleted": false, - "edited": false, - "react": {}, - "id": "1", - "author": { - "name": "ForumcuCocuk", - "avatar": "/images/guest.png", - "time": 1647177723873, - "admin": true, - "id": "1" - }, - "threadID":"0" - } + "admin": false, + "_id": "630673ffbc01da866fad507b", + "__v": 0 + }, + "content": "deneme", + "deleted": false, + "edited": false, + "time": "2022-08-24T18:55:37.744Z", + "id": "0", + "__v": 0, + "react": { + "0": true + }, + "authorID": "0", + "reactCount": 1 } - - ``` - - +``` \ No newline at end of file diff --git a/README.md b/README.md index 7a6931f..76c83ef 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # akf-forum -A forum software written in Node.js. +A Node.js based forum software. ## Installation - Clone or download this repo. @@ -12,11 +12,7 @@ A forum software written in Node.js. Run `node util/reset` to **reset the database**, and run `node util/admin` for give admin perms to first member. ## API -Akf-forum has got an API for other clients etc. You can test api with python files in `test` folder. - -Python is only for testing 😭 - -And, you can learn about API in `util/APIDOCS.md`. +Akf-forum has got an API for AJAX, other clients etc. And, you can learn about API in `util/APIDOCS.md`. ## Credits * [Akif9748](https://github.com/Akif9748) - Project mainteiner, main developer, made **old** frontend @@ -27,7 +23,7 @@ And, you can learn about API in `util/APIDOCS.md`. ### Old frontend ![akf-forum](https://user-images.githubusercontent.com/70021050/160255959-ef216cba-1348-4d4b-9347-fe67e21348e7.png) ### New frontend -![image](https://user-images.githubusercontent.com/70021050/186941146-f9a8fbf8-9b2b-4028-afc8-81cff559d9fb.png) +![new-akf-forum](https://user-images.githubusercontent.com/70021050/186941146-f9a8fbf8-9b2b-4028-afc8-81cff559d9fb.png) ## Roadmap diff --git a/util/tests/get_msg.py b/util/tests/get_msg.py deleted file mode 100644 index 43aaea3..0000000 --- a/util/tests/get_msg.py +++ /dev/null @@ -1,34 +0,0 @@ -import requests - -# Headers for login to Akf-forum -headers = { - "username": "testUser", - "password": "testPassword" -} - - -r = requests.get("http://localhost:3000/api/messages/1/", headers=headers) - -print(r.json()) - -example_response = { - 'status': 200, - 'result': { - 'content': 'a', - 'author': { - 'name': 'Akif9748', - 'avatar': 'https://www.technopat.net/sosyal/data/avatars/o/298/298223.jpg?1644694020', - 'time': 1649189944864, - 'admin': False, - 'deleted': False, - 'id': "0" - }, - 'time': 1649189950166, - 'threadID': "0", - 'deleted': False, - 'edited': False, - # Reactions: {userid: isLike (Bool)} - 'react': {'0': True}, - 'id': "0" - } -} diff --git a/util/tests/get_thread.py b/util/tests/get_thread.py deleted file mode 100644 index 0e8fab9..0000000 --- a/util/tests/get_thread.py +++ /dev/null @@ -1,31 +0,0 @@ -import requests - -# Headers for login to Akf-forum -headers = { - "username": "testUser", - "password": "testPassword" -} - - -r = requests.get("http://localhost:3000/api/threads/0/", headers=headers) - -print(r.json()) - -example_response = { - "status": 200, - "result": { - "author": { - "name": "Akif9748", - "avatar": "https://www.technopat.net/sosyal/data/avatars/o/298/298223.jpg?1644694020", - "time": 1647895891332, - "admin": False, - "deleted": False, - "id": "0" - }, - "title": "First Thread", - "messages": ["0", "1", "2", "3"], - "time": 1647895907054, - "deleted": False, - "id": "0" - } -} diff --git a/util/tests/get_user.py b/util/tests/get_user.py deleted file mode 100644 index 0285972..0000000 --- a/util/tests/get_user.py +++ /dev/null @@ -1,24 +0,0 @@ -import requests - -# Headers for login to Akf-forum -headers = { - "username": "testUser", - "password": "testPassword" -} - - -r = requests.get("http://localhost:3000/api/users/0/", headers=headers) - -print(r.json()) - -example_response = { - 'status': 200, - 'result': { - 'name': 'Akif9748', - 'avatar': 'https://www.technopat.net/sosyal/data/avatars/o/298/298223.jpg?1644694020', - 'time': 1647895891332, - 'admin': True, - 'deleted': False, - 'id': "0" - } -} diff --git a/util/tests/post_msg.py b/util/tests/post_msg.py deleted file mode 100644 index bfd4c70..0000000 --- a/util/tests/post_msg.py +++ /dev/null @@ -1,39 +0,0 @@ -import requests - -# Headers for login to Akf-forum -headers = { - "username": "testUser", - "password": "testPassword" -} - -# Body for message parameters -body = { - "content": "This message sent via API", - "threadID": 0 -} - -r = requests.post("http://localhost:3000/api/messages/", - headers=headers, data=body) - -print(r.json()) - -example_response = { - 'status': 200, - 'result': { - 'content': 'This message sent via API', - 'author': { - 'name': 'testUser', - 'avatar': '', - 'time': 1649009854217, - 'admin': False, - 'deleted': False, - 'id': "2" - }, - 'time': 1649010863471, - 'threadID': "1", - 'deleted': False, - 'edited': False, - 'react': {}, - 'id': "6" - } -} diff --git a/util/tests/post_msg_react.py b/util/tests/post_msg_react.py deleted file mode 100644 index 7457a43..0000000 --- a/util/tests/post_msg_react.py +++ /dev/null @@ -1,17 +0,0 @@ -import requests - -# Headers for login to Akf-forum -headers = { - "username": "testUser", - "password": "testPassword" -} - -r = requests.post("http://localhost:3000/api/messages/0/react/like", - headers=headers) - -print(r.json()) - -example_response = { - 'status': 200, - 'result': 1 # Number of likes -} diff --git a/util/tests/post_thread.py b/util/tests/post_thread.py deleted file mode 100644 index 9fdf240..0000000 --- a/util/tests/post_thread.py +++ /dev/null @@ -1,36 +0,0 @@ -import requests - -# Headers for login to Akf-forum -headers = { - "username": "testUser", - "password": "testPassword" -} - -# Body for message parameters -body = { - "content": "This message sent via API", - "title": "This thread opened by API" -} - -r = requests.post("http://localhost:3000/api/threads/", - headers=headers, data=body) - -print(r.json()) - -example_response = { - 'status': 200, - 'result': { - 'author': { - 'name': 'Akif9748', - 'avatar': 'https://www.technopat.net/sosyal/data/avatars/o/298/298223.jpg?1644694020', - 'time': 1647895891332, 'admin': True, 'deleted': False, 'id': "0" - }, - 'title': 'API TEST', - 'messages': ["4", "6"], - 'time': 1649010834064, - 'deleted': False, - 'edited': False, - 'id': "1", - - } -} diff --git a/views/admin.ejs b/views/admin.ejs index c75978e..f8a9929 100644 --- a/views/admin.ejs +++ b/views/admin.ejs @@ -1,7 +1,7 @@ -<%- include("extra/meta", {title: "User list!" }) %> +<%- include("extra/meta", {title: "Admin Panel!" }) %> @@ -11,10 +11,3 @@

Write an ID to give someone admin permissions:

- - \ No newline at end of file