user: {
id: String!,
username: String!,
email: String!,
avatar: String,
phost: [phost]!,
}
author:{
id: String!,
username: String!,
avatar: String!,
}
phost: {
id: String!,
author_id: String,
img: String!,
text: String!,
created_at: ISOstring!,
comments: [Comment]!,
}
comment: {
id: String!,
author_id: String!,
text: String!,
}
error: {
message: string,
}
APIS for authentication.
Header :
{ }
Query Parameters :
{ }
Body Parameters :
{
username: String!,
password: String!
}
Response :
- If success : Code: 200, Body:
{token: String}
- If fail : Code: 401, Body:
{token: null, error: {Error}}
Descriptions :
username
can be either username or email
Body Parameters :
{
email: String!,
username: String!,
password: String!
}
Response :
- If success : Code: 200, Body:
{user_id: String}
- If fail, user not found : Code: 404, Body:
{user_id: null, error: {Error}}
- If fail, other error : Code: 401, Body:
{user_id: null, error: {Error}}
Desciptions :
- Validation will be finished in frontend. No need to validate in backend.
Body Parameters :
{session_id: String!}
Response :
- If success : Code: 200, Body:
{ }
- If fail : Code: 401, Body:
{error: {Error}}
APIS for phosts CRUD operations.
Get all phosts
Body Parameters :
{ } // Maybe some query filters can be added
Response :
- If success : Code: 200, Body:
{phosts: [phost]}
- If fails: Code: 401, Body:
{error: {Error}}
Notes :
Return 200 with an empty array if there is no phost found.
Get a certain phost with its id.
Path Parameters :
{id: string! }
Response :
- If found: Code: 200, Body:
{phost: <phost>}
- If not found: Code: 404, Body:
{phost: null, error: {Error}}
- If fails: Code: 401, Body:
{phost: null, error: {Error}}
Create a new phost.
Body Parameters :
{
author_id: String!,
img: String!,
text: String!,
}
Respnose :
- If success: Code 200 Body:
{id: string}
- If fails with bad parameters: Code 400 Body:
{id: null, error: {Error}}
- If fails with other reasons, Code 401 Body:
{id: null, error: {Error}}
Notes :
Images should be stored on external servers. We only passes image urls between backend and frontend