Skip to content

Releases: Ajdj100/proj_6_web

v0.2

18 Feb 15:47
ac645ed

Choose a tag to compare

Release v0.2

🛤️ Routes

GET /

  • Route serves the Login.html page.

GET /article

  • Serves the Articles.html page.

GET /browse

  • Serves the Browse.html page.

GET /profile

  • Expects a JSON request body with a 'user_id' field.
  • Returns a 200 with the posts associated with this user in a JSON response body.
  • Returns 500 if error with SQL query.

GET /post

  • Returns the data associated with a user post.
  • Explects a JSON field in the body called 'id' with the desired post id.
  • Returns status code 500 if error with SQL query.

GET /posts

Returns a JSON list of the 5 next posts in the DB.
Expects a request with a JSON body and 'limit', 'current' fields.
Returns status code 500 if error with SQL query.

GET /username

  • Returns the username as JSON in a field called 'username'.
  • Expects the user id in the request body JSON in a field called 'user_id'.
  • Returns status code 500 if error with SQL query.\

POST /login

  • Returns 200 with user_id in JSON body if the credentials authenticated successfully.
  • Expects JSON body with 'username' and 'password' fields.
  • Creates cookie using authenticated user id called current_user.
  • Returns 401 if authentication fails.

POST /signup

  • Returns 200 with user_id in JSON body if the signup was successfull.
  • Expects JSON body with 'username' and 'password' fields.
  • Returns 500 if error inserting new user into DB.

POST /post

  • Returns new post id in JSON body field 'insertId'.
  • Expects user_id, title, and body in request JSON body.
  • Returns 500 if error creating post.

POST /comment

  • Returns new comment id in JSON as 'insertId'.
  • Expects the commented post's id, user id, comment body in the request body as 'post_id', 'user_id', 'body'.
  • Returns 500 if there is an error with the SQL query.

PATCH /post

  • xpects a JSON body with 'title' and or 'body'.
  • Updates the post given the new fields.
  • Returns 200 with success message in response as 'message' JSON field.
  • Returns 500 if error occurred during the update.

PUT /comment

  • Expects a JSON body with 'comment_id', 'post_id' and 'body'.
  • Replaces the comment with the new fields.
  • Returns 200 with success message in response as 'message' JSON field.
  • Returns 500 if error occurred during the update.

DELETE /post

  • Expects a JSON body with the 'post_id'.
  • Removes the matching post from the Db.
  • Returns 200 success if query is successful.
  • Returns 500 if error occurrred during query.

OPTIONS /

  • Returns accepted header types and method types. Works globally, on all routes in the system.

What's Changed

Full Changelog: v0.1...v0.2

Release v0.1

29 Jan 21:38
9362d98

Choose a tag to compare

🛤️ Routes

GET /

  • Route serves the Login.html page.

GET /article

  • Serves the Articles.html page.

GET /browse

  • Serves the Browse.html page.

GET /profile

  • Expects a JSON request body with a 'user_id' field.
  • Returns a 200 with the posts associated with this user in a JSON response body.
  • Returns 500 if error with SQL query.

GET /post

  • Returns the data associated with a user post.
  • Explects a JSON field in the body called 'id' with the desired post id.
  • Returns status code 500 if error with SQL query.
  • GET /posts

  • Returns a JSON list of the 5 next posts in the DB.
  • Expects a request with a JSON body and 'limit', 'current' fields.
  • Returns status code 500 if error with SQL query.

GET /username

  • Returns the username as JSON in a field called 'username'.
  • Expects the user id in the request body JSON in a field called 'user_id'.
  • Returns status code 500 if error with SQL query.

POST /login

  • Returns 200 with user_id in JSON body if the credentials authenticated successfully.
  • Expects JSON body with 'username' and 'password' fields.
  • Creates cookie using authenticated user id called current_user.
  • Returns 401 if authentication fails.

POST /signup

  • Returns 200 with user_id in JSON body if the signup was successfull.
  • Expects JSON body with 'username' and 'password' fields.
  • Returns 500 if error inserting new user into DB.

POST /post

  • Returns new post id in JSON body field 'insertId'.
  • Expects user_id, title, and body in request JSON body.
  • Returns 500 if error creating post.

POST /comment

  • Returns new comment id in JSON as 'insertId'.
  • Expects the commented post's id, user id, comment body in the request body as 'post_id', 'user_id', 'body'.
  • Returns 500 if there is an error with the SQL query.

PATCH /post

  • Expects a JSON body with 'title' and or 'body'.
  • Updates the post given the new fields.
  • Returns 200 with success message in response as 'message' JSON field.
  • Returns 500 if error occurred during the update.

PUT /comment

  • Expects a JSON body with 'comment_id', 'post_id' and 'body'.
  • Replaces the comment with the new fields.
  • Returns 200 with success message in response as 'message' JSON field.
  • Returns 500 if error occurred during the update.

OPTIONS /

  • Returns accepted header types and method types. Works globally, on all routes in the system.

🗄️ File Changes

Full Changelog: https://github.com/Ajdj100/proj_6_web/commits/v0.1