API-DOCS-FIX

Co-authored-by: Serkan9748 <Serkan9748@users.noreply.github.com>
This commit is contained in:
Akif9748 2022-08-27 09:53:10 +03:00
parent 0e659a8aa4
commit 87cf4f3274
9 changed files with 32 additions and 223 deletions

View file

@ -1,9 +1,7 @@
# API documentation of Akf-forum # API documentation of Akf-forum
<img src="https://raw.githubusercontent.com/Akif9748/akf-forum/main/public/images/logo.jpg" align="right" width="300px" /> <img src="https://raw.githubusercontent.com/Akif9748/akf-forum/main/public/images/logo.jpg" align="right" width="300px" />
Akf-forum has got an API for other clients etc. Akf-forum has got an API for AJAX, other clients etc.
You can find examples in `tests` folder.
## Authorization ## Authorization
You need this headers for send request to API: You need this headers for send request to API:
@ -13,6 +11,7 @@ You need this headers for send request to API:
"password": "testPassword" "password": "testPassword"
} }
``` ```
But in front end, the API will works with session.
## How to request? ## 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. - POST `/api/messages/:id/react/:type` for react to a message.
### Example request: ### Example request:
```GET /api/messages/1``` GET ```/api/messages/0```
#### Example API Output: #### Example API Output:
```json ```json
{ {
"status": 200, "_id": "63067429bc01da866fad508b",
"result": "threadID": "0",
{ "author": {
"content": "First message", "id": "0",
"time": 1647178873587, "name": "Akif9748",
"avatar": "https://cdn.discordapp.com/avatars/539506680140922890/abd74d10aac094fc8a5ad5c86f29fdb9.png?size=1024",
"time": "2022-08-24T18:54:55.666Z",
"deleted": false, "deleted": false,
"edited": false, "admin": false,
"react": {}, "_id": "630673ffbc01da866fad507b",
"id": "1", "__v": 0
"author": { },
"name": "ForumcuCocuk", "content": "deneme",
"avatar": "/images/guest.png", "deleted": false,
"time": 1647177723873, "edited": false,
"admin": true, "time": "2022-08-24T18:55:37.744Z",
"id": "1" "id": "0",
}, "__v": 0,
"threadID":"0" "react": {
} "0": true
},
"authorID": "0",
"reactCount": 1
} }
```
```

View file

@ -1,7 +1,7 @@
# akf-forum # akf-forum
<img src="https://raw.githubusercontent.com/Akif9748/akf-forum/main/public/images/logo.jpg" align="right" width="300px" /> <img src="https://raw.githubusercontent.com/Akif9748/akf-forum/main/public/images/logo.jpg" align="right" width="300px" />
A forum software written in Node.js. A Node.js based forum software.
## Installation ## Installation
- Clone or download this repo. - 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. Run `node util/reset` to **reset the database**, and run `node util/admin` for give admin perms to first member.
## API ## API
Akf-forum has got an API for other clients etc. You can test api with python files in `test` folder. Akf-forum has got an API for AJAX, other clients etc. And, you can learn about API in `util/APIDOCS.md`.
Python is only for testing 😭
And, you can learn about API in `util/APIDOCS.md`.
## Credits ## Credits
* [Akif9748](https://github.com/Akif9748) - Project mainteiner, main developer, made **old** frontend * [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 ### Old frontend
![akf-forum](https://user-images.githubusercontent.com/70021050/160255959-ef216cba-1348-4d4b-9347-fe67e21348e7.png) ![akf-forum](https://user-images.githubusercontent.com/70021050/160255959-ef216cba-1348-4d4b-9347-fe67e21348e7.png)
### New frontend ### 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 ## Roadmap

View file

@ -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"
}
}

View file

@ -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"
}
}

View file

@ -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"
}
}

View file

@ -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"
}
}

View file

@ -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
}

View file

@ -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",
}
}

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<%- include("extra/meta", {title: "User list!" }) %> <%- include("extra/meta", {title: "Admin Panel!" }) %>
<body style="text-align: center;"> <body style="text-align: center;">
@ -11,10 +11,3 @@
<h2 style="color: #606060;">Write an ID to give someone admin permissions:</h2> <h2 style="color: #606060;">Write an ID to give someone admin permissions:</h2>
</body> </body>
</html> </html>
<!--tam olarak neresi, body içi de, sana komik bisey gostercektim kayybolmus.
veritabanı sifrem sence neydi fdsajıgdsıgasd nereden bileyim oradan müneccime mi benziyorum
neyse tamam sdapgdsjagsadp
lşösdlkşsdklsklsdkl buradan da konuşmadık demeyiz
evet benziyorsn cogu seyi tahmin ediyorsun. buradan konusalim artik zeynep goruldu yok burada, ney yazdiysan da gdiyior gdsagdsgdsh
-->