From ecb815043a2dc4cb453f620eb30598223de74d9a Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Thu, 2 Feb 2023 16:15:19 -0500 Subject: api docs --- public/api.html | 542 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 542 insertions(+) create mode 100644 public/api.html (limited to 'public/api.html') diff --git a/public/api.html b/public/api.html new file mode 100644 index 0000000..6e6086a --- /dev/null +++ b/public/api.html @@ -0,0 +1,542 @@ + + + + + + + + + XSSBook - API Documentation + + + +
+
+
+ POST + /api/auth/register + Registeres a new account +
+
+

Body

+
+ {
+ "firstname" : "[Object"
+ "lastname" : "object]"
+ "email" : "object@object.object"
+ "password" : "i love js"
+ "gender" : "lettuce"
+ "day" : 1
+ "month" : 1
+ "year" : 1970
+ }
+
+

Responses

+
+ 201 + Successfully created new user, auth cookie is returned +
+
+ 400 + Body does not match paramaters +
+
+
+
+
+ POST + /api/auth/login + Logs into an existing account +
+
+

Body

+
+ {
+ "email" : "object@object.object"
+ "password" : "i love js"
+ }
+
+

Responses

+
+ 200 + Successfully logged in, auth cookie is returned +
+
+ 400 + Body does not match paramaters, or email/password is already in use +
+
+
+
+
+ POST + /api/auth/logout + Logs out of an logged in account + auth cookie is required for authentication +
+
+

Responses

+
+ 200 + Successfully logged out +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to log out user +
+
+
+
+
+ POST + /api/posts/create + Creates a new post + auth cookie is required for authentication +
+
+

Body

+
+ {
+ "content" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
+ }
+
+

Responses

+
+ 201 + Successfully created post +
+
+ 400 + Body does not match paramaters +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to create post +
+
+
+
+
+ POST + /api/posts/page + Load a section of posts from newest to oldest + auth cookie is required for authentication +
+
+

Body

+
+ {
+ "page" : 0
+ }
+
+

Responses

+
+ 200 + Returns posts in application/json +
+
+ 400 + Body does not match paramaters +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to fetch posts +
+
+
+
+
+ POST + /api/posts/user + Load a section of posts from newest to oldest from a specific user + auth cookie is required for authentication +
+
+

Body

+
+ {
+ "user_id" : 3
+ "page" : 0
+ }
+
+

Responses

+
+ 200 + Returns posts in application/json +
+
+ 400 + Body does not match paramaters +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to fetch posts +
+
+
+
+
+ PATCH + /api/posts/comment + Adds a comment to a post + auth cookie is required for authentication +
+
+

Body

+
+ {
+ "content" : "This is a very good post"
+ "post_id" : 0
+ }
+
+

Responses

+
+ 200 + Successfully added comment +
+
+ 400 + Body does not match paramaters +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to add comment +
+
+
+
+
+ PATCH + /api/posts/like + Set like status on a post + auth cookie is required for authentication +
+
+

Body

+
+ {
+ "state" : true
+ "post_id" : 0
+ }
+
+

Responses

+
+ 200 + Successfully set like status +
+
+ 400 + Body does not match paramaters +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to set like status +
+
+
+
+
+ POST + /api/users/load + Load a requested set of users + auth cookie is required for authentication +
+
+

Body

+
+ {
+ "ids" : [0,3,7]
+ }
+
+

Responses

+
+ 200 + Returns users in application/json +
+
+ 400 + Body does not match paramaters +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to fetch users +
+
+
+
+
+ POST + /api/users/page + Load a section of users from newest to oldest + auth cookie is required for authentication +
+
+

Body

+
+ {
+ "page" : 0
+ }
+
+

Responses

+
+ 200 + Returns users in application/json +
+
+ 400 + Body does not match paramaters +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to fetch users +
+
+
+
+
+ POST + /api/users/self + Returns current authenticated user (whoami) + auth cookie is required for authentication +
+
+

Responses

+
+ 200 + Returns authed user in application/json +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to fetch user +
+
+
+
+
+ PUT + /api/users/avatar + Set your current profile avatar + auth cookie is required for authentication +
+
+

Body

+
+ PNG sent as a binary blob +
+

Responses

+
+ 200 + Successfully updated avatar +
+
+ 400 + Invalid PNG or disallowed size +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to update avatar +
+
+
+
+
+ PUT + /api/users/banner + Set your current profile banner + auth cookie is required for authentication +
+
+

Body

+
+ PNG sent as a binary blob +
+

Responses

+
+ 200 + Successfully updated banner +
+
+ 400 + Invalid PNG or disallowed size +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to update banner +
+
+
+
+
+ POST + /api/admin/auth + Authenticates on the admin panel +
+
+

Body

+
+ {
+ "secret" : "admin"
+ }
+
+

Responses

+
+ 200 + Successfully authed, admin cookie returned +
+
+ 400 + Body does match parameters, or invalid admin scret +
+
+
+
+
+ POST + /api/admin/query + Run a SQL query on the database + admin cookie is required for authentication +
+
+

Body

+
+ {
+ "query" : "DROP TABLE users;"
+ }
+
+

Responses

+
+ 200 + Successfully ran SQL query +
+
+ 400 + Body does match parameters +
+
+ 401 + Unauthorized +
+
+ 500 + SQL query error +
+
+
+
+
+ POST + /api/admin/posts + Returns the entire posts table + admin cookie is required for authentication +
+
+

Responses

+
+ 200 + Returns sql table in text/html +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to fetch data +
+
+
+
+
+ POST + /api/admin/users + Returns the entire users table + admin cookie is required for authentication +
+
+

Responses

+
+ 200 + Returns sql table in text/html +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to fetch data +
+
+
+
+
+ POST + /api/admin/sessions + Returns the entire posts sessions + admin cookie is required for authentication +
+
+

Responses

+
+ 200 + Returns sql table in text/html +
+
+ 401 + Unauthorized +
+
+ 500 + Failed to fetch data +
+
+
+
+ \ No newline at end of file -- cgit v1.2.3-freya