Skip to content

Backend Routes

thedanielcho edited this page May 12, 2021 · 10 revisions

Backend Routes

HTML

  • GET / StaticPagesController#root

API Endpoints

users

  • GET /api/channels/:channel_id/users returns a list of users in a specified channel
  • GET /api/direct_messages/:direct_message_id/users returns a list of users in a specified DM
  • GET /api/users/:id returns all info for a single user
  • POST /api/users creates a new user in the database and returns user's info
  • PATCH /api/users/:id if user being edited is current user

session

  • POST /api/session log in
  • DELETE /api/session log out

channels

  • GET /api/channels returns a list of all channels
  • GET /api/channels/:id returns all the information for a specified channel
  • POST /api/channels creates a new channel in the database, setting the admin as current user and returns that channel's info
  • PATCH /api/channels/:id edit a channel if current user is the admin
  • DELETE /api/channels/:id delete a channel if current user is the admin
  • GET /api/channels/search custom route that that uses a query string to return a list of channels that match the query string

messages

  • GET /api/channels/:channel_id/messages returns a list of all messages for a specified channel
  • GET /api/direct_messages/:direct_message_id/messages returns a list of all messages for a specified DM
  • POST /api/channels/:channel_id/messages creates a new message in the specified channel
  • POST /api/direct_messages/:direct_message_id/messages creates a new message in the specified DM
  • PATCH /api/messages/:id edits a message if message's creator is current user
  • DELETE /api/messages/:id deletes a message if message's creator is current user

direct_messages

  • GET /api/users/:user_id/direct_messages returns a list of all DMs a user is in
  • GET /api/direct_messages/:id returns all the information for a specified DM
  • POST /api/direct_messages creates a new DM in the database

Note: There's no edit or delete route because there's nothing to edit and DM's can't be deleted

memberships

  • POST /api/channels/:channel_id/memberships adds a user to specified channel
  • DELETE /api/channels/:channel_id/memberships removes current user from specified channel

Note: Not entirely sure how to handle memberships for DMs since I can't tell if you can actually leave a DM/if leaving one deletes that entry in the database table, and I don't think you can add users to a DM after it's already been created.

Clone this wiki locally