Skip to content

mattsoza/storyforger

Repository files navigation

storyforger: Make and share your own choose-your-own-adventure stories!

StoryForger is an online application that allows you to create and share choose-your-own-adventure stories, all with the power of your browser!

Created as a project for 6.1040/6.170 in Fall 2022

API Routes

Users

POST /api/users/session - Sign in user

Body

  • username {string} - The user's username
  • password {string} - The user's password

Returns

  • A success message
  • An object with user's details (without password)

Throws

  • 403 if the user is already logged in
  • 400 if username or password is not in correct format format or missing in the req
  • 401 if the user login credentials are invalid

DELETE /api/users/session - Sign out user

Returns

  • A success message

Throws

  • 403 if user is not logged in

POST /api/users - Create an new user account

Body

  • username {string} - The user's username
  • password {string} - The user's password

Returns

  • A success message
  • An object with the created user's details (without password)

Throws

  • 403 if there is a user already logged in
  • 400 if username or password is in the wrong format
  • 409 if username is already in use

PUT /api/users - Update a user's profile

Body (no need to add fields that are not being changed)

  • username {string} - The user's username
  • password {string} - The user's password

Returns

  • A success message
  • An object with the update user details (without password)

Throws

  • 403 if the user is not logged in
  • 400 if username or password is in the wrong format
  • 409 if the username is already in use

DELETE /api/users - Delete user

Returns

  • A success message

Throws

  • 403 if the user is not logged in

Book

GET /api/book/ - Gets the books of the currently signed-in users

GET /api/book/:id - Gets the book and its pages

POST /api/book/ - Creates a new book

DELETE /api/book/:id - Deletes a book

PATCH /api/book/:id - Modifies the book

Page

GET /api/page/:id - Gets a page

POST /api/page - Create a new page

PATCH /api/page/:id - Modifies the page

GET /api/connection/:id - Gets a connection

POST /api/connection/ - Creates a new connection

DELETE /api/connection/:id - Deletes a connection

Connection

GET /api/connections/?bookId=bookId - Get all connections in book

GET /api/connections/?pageId=pageId - Get all outgoing connections from a page

GET /api/connections/:connectionId - Get specific connection

POST /api/connections/ - Create a new connection

body: {parent: pageId, child: pageId, text: string}

PUT /api/connections/:connectionId - Modify a connection

body: {child?: pageId, text?: string}

DELETE /api/connections/:connectionId - Delete connection from a page