Backend API routes - fbeilke/Thermos GitHub Wiki

Authentication

Authenticate existing user

  • Route (GET '/auth/')
  • Successful auth returns:
 { id, blogName, email, profilePictureUrl }
  • Unsuccessful auth returns:
{'message': 'No logged in user'}
status = 401

Login

  • Route (POST '/auth/login')
  • Successful login returns:
 { id, blogName, email, profilePictureUrl }
  • Unsuccessful login returns:
{
'Email is required'
'Password is required'
'Email provided was not found',
'No such user exists',
'Password was incorrect',
'Password must be at least 8 characters long'
}
status = 401

Logout

  • Route (GET '/auth/logout')
  • Successful logout returns:
{'message': 'User logged out'}

Sign up

  • Route (POST '/auth/signup')
  • Successful signup returns:
{ id, blogName, email, profilePictureUrl }
  • Unsuccessful signup returns:
{
'Email is required'
'Blog name is required'
'Password is required'
'Email address is already in use'
'Blog name is already in use'
'Password must be minimum 8 characters'
'Must be an image file with an allowed extension'
}
status = 400

Unauthorized

  • Route (GET '/auth/unauthorized')
  • Returns:
{ 'errors': {'message': 'Unauthorized'} }
status = 401

Users

Get all users

  • Route (GET '/users/')
  • Successful return:
{
id1: { id1, blogName, email, profilePictureUrl },
id2: { id2, blogName, email, profilePictureUrl },
id3: { id3, blogName, email, profilePictureUrl },
...
}

Get user by blog name

  • Route (GET '/users/string:blog_name')
  • Successful return:
{ id, blogName, email, profilePictureUrl, postsByUser, reblogsByUser }
  • Unsuccessful return:
{ 'error': 'User was not found' }
status = 404

Posts

Get all posts

  • Route (GET '/posts/')
  • Successful return:
{ 
id1: { id, title, content, caption, userId, likes, tags, postType, previousPostId, createdAt, creator, creatorImage },
id2: { id, title, content, caption, userId, likes, tags, postType, previousPostId, createdAt, creator, creatorImage },
id3: { id, title, content, caption, userId, likes, tags, postType, previousPostId, createdAt, creator, creatorImage },
...
}

Create new post

  • Route (POST '/posts/')
  • Successful return:
{ id, title, content, caption, userId, likes, tags, postType, previousPostId, createdAt, creator, creatorImage }
  • Unsuccessful return:
{
'Max title length is 255 characters'
'Tag can be a maximum of 1000 characters long'
'Post must be text, photo, video, or audio'
}
status = 400

Submit file

  • Route (POST '/posts/file')
  • Successful return:
{ url }
  • Unsuccessful return:
{ 
'File is required',
'File allowed {'pdf', 'gif', 'png', 'jpg', jpeg', 'webp', avif', 'mp4', 'mov', 'mp3'}'
}
status = 400

Remove file

  • Route (POST '/posts/file/remove')
  • Successful return:
{ 'message': 'Successfully removed file' }
  • Unsuccessful return:
{ 'error': 'File was not able to be removed' }
status = 500

Update post

  • Route (PUT '/posts/int:id')
  • Successful return:
{ id, title, content, caption, userId, likes, tags, postType, previousPostId, createdAt, creator, creatorImage }
  • Unsuccessful return:
{
'Max title length is 255 characters'
'Tag can be a maximum of 1000 characters long'
'Post must be text, photo, video, or audio'
}
status = 400

Delete post

  • Route (DELETE '/posts/int:id')
  • Successful return:
{ 'message': 'Successfully deleted' }
  • Unsuccessful return:
{ 'message': 'Post was not found' }
status = 404

Reblogs

Get all reblogs

  • Route (GET '/reblogs/')
  • Successful return:
{ 
id1: { id, userId, postId, commentContent, caption, tags, postType, rebloggedFrom, createdAt, reblogCreator, originalPost },
id2: { id, userId, postId, commentContent, caption, tags, postType, rebloggedFrom, createdAt, reblogCreator, originalPost },
id:3 { id, userId, postId, commentContent, caption, tags, postType, rebloggedFrom, createdAt, reblogCreator, originalPost },
...
}

Reblog as is

  • Route (POST '/reblogs/')
  • Successful return:
{ id, userId, postId, commentContent, caption, tags, postType, rebloggedFrom, createdAt, reblogCreator, originalPost }

Delete reblog

  • Route (DELETE '/reblogs/int:id')
  • Successful return:
{ 'message': 'Successfully deleted' }
  • Unsuccessful return:
{ 'message': 'Reblog was not found'}
status = 404
⚠️ **GitHub.com Fallback** ⚠️