/coder-heroes-be

Primary LanguageJavaScriptMIT LicenseMIT

*NOTE: "schedules" as used in endpoints refer to childrens' enrollments to courses; "schedule" specific endpoints join the children, enrollments, and courses tables and return data matching the given profile_id

Profiles


{
  profile_id: INCREMENT (primary key, auto-increments, generated by database),
  okta_id: STRING (unique),
  name: STRING (required),
  email: STRING (required),
  role_id: INTEGER (required, foreign key),
  avatarUrl: STRING (required, defaults to: 'https://i.stack.imgur.com/frlIf.png'),
}
Method URL Description
[GET] /profile/ Returns an array of all existing profiles.
[GET] /profile/:okta_id/ Returns the profile object with the specified okta_id.
[GET] /profiles/users/:profile_id (BUG: /profiles/users route does not exist; app.js only connects to /profiles/user) Returns an array filled with event objects that contains information based on profile_id and role_id.
[GET] /profile/role/:role_id (BUG: does not return any data) Returns an array filled with event objects that contain information based on role_id for all profiles of a role_id type.
[POST] /profile/ Requires a name, password, and email. Registers a new user.
[PUT] /profile/ Returns an event object with the specified okta. Updates specific profile.
[DELETE] /profile/:okta_id/ Returns an event object with the specified okta. Deletes specific profile.

User:

These endpoints are user-focused. As opposed to the more flexible Profile endpoints where profile_id must be specified, these endpoints retrieve data specific only to the user profile that is making the API request by using the logged-in user's profile_id.

Method URL Description
[GET] /user/ Returns an event object with the specified okta and type.
[GET] /user/inbox/ Returns an event object with the specified okta. (NOT IMPLEMENTED)
[GET] /user/schedules/ Returns an event object with the specified okta.
[PUT] /user/ Returns an event object with the specified id. Updates specific user.
[POST] /user/register Posts a new user in the database and in the Okta Dashboard.

NOTE: these are the password requirements: at least 8 characters, a lowercase letter, an uppercase letter, a number, no parts of your username.
The required fields include the following: { firstName: string, lastName: string, email: string, password: string, role_id: int, avatarUr(not required): string, }

Parents

{
  parent_id: INCREMENT (primary key, auto-increments, generated by database),
  profile_id: INTEGER (required, foreign key),
}
Method URL Description
[GET] /parent/:profile_id/children/ Returns an array filled with children event objects with the specified profile_id.
[GET] /parent/:profile_id/schedules/ Returns an array filled with schedules event objects with the specified profile_id.

Children

{
  child_id: INCREMENT (primary key, auto-increments, generated by database),
  profile_id: INTEGER (required, unique, foreign key),
  username: STRING (required),
  age: INTEGER (required),
  parent_id: INTEGER (required, foreign key),
}
Method URL Description
[GET] /children Returns an array containing all existing children.
[POST] /children Requires a username, name, and age. Returns the name, profile_id, and parent_id.
[GET] /children/:child_id Returns the child with the given 'id'.
[PUT] /children/:child_id Returns the updated child object
[DELETE] /children/:child_id Returns the name of the child deleted
[GET] /children/:child_id/enrollments Returns an array filled with event objects with the specified id.
[POST] /children/:child_id/enrollments Returns the event object with the specified id. Enrolls a student.
[PUT] /children/enrollments/ Returns the event object with the specified id. Updates a student's enrollments. (Not Implemented)
[DELETE] /children/enrollments/:id Returns the event object with the specified id. Unenrolls student from course. (Not Implemented)

Instructors

{
  instructor_id: INCREMENT (primary key, auto-increments, generated by database),
  rating: INTEGER (required),
  availability: STRING (optional),
  bio: STRING (required),
  profile_id: INTEGER (required, foreign key),
  status: STRING (required, default: 'pending'),
  approved_by: INTEGER (optional, foreign key, default: null, references admin_id),
}
Method URL Description
[GET] /instructor/courses/ Returns an array containing all course event objects belonging to the currently logged in instructor.

Programs

{
  program_id: INCREMENT (primary key, auto-increments, generated by database),
  program_name: STRING (required, unique),
  program_description: STRING (required),
}
Method URL Description
[GET] /program/ Returns an array filled with program objects.
[GET] /program/:id Returns the program object with the specified id.
[POST] /program/ Contains fields: program_name and program_description. Returns the newly created program object.
[PUT] /program/:id Updates the program with the specified id using data from the request body. Returns the modified program
[DELETE] /program/:id Removes the program with the specified id and returns deletion success message .

Courses

{
  course_id: INCREMENT (primary key, auto-increments, generated by database),
  course_name: STRING (required),
  course_description: STRING (required),
  days_of_week: ARRAY[strings] (optional),
  max_size: INTEGER (required),
  min_age: INTEGER (required),
  max_age: INTEGER (required),
  instructor_id: INTEGER (required, foreign key),
  program_id: INTEGER (required, foreign key),
  start_time: TIME (required),
  end_time: TIME (required),
  start_date: DATE (required),
  end_date: DATE (required),
  location: STRING (required),
  number_of_sessions: INTEGER (required),
}
Method URL Description
[GET] /course Returns an array containing all course objects
[GET] /course/:course_id Returns the course object with the specified course_id.
[POST] /course --needs to be fleshed out--
[PUT] /course/:course_id Updates and returns the updated course object with the specified course_id.
[DELETE] /course/:course_id Deletes the course object with the specified course_id and returns a message containing the deleted course_id on successful deletion

Newsfeed

{
  newsfeed_id: INCREMENT (primary key, auto-increments, generated by database),
  title: STRING (required),
  link: STRING (required),
  description: STRING (required),
  posted_at: TIMESTAMP (auto-generated),
}
Method URL Description
[GET] /newsfeed/ Returns an array containing all newsfeed objects.
[GET] /newsfeed/:newsfeed_id/ Returns the event object with the specified newsfeed_id.
[POST] /newsfeed/ Creates a new newsfeed object and returns the newly created newsfeed.
[PUT] /newsfeed/:newsfeed_id Updates the newsfeed object with the given newsfeed_id and returns the newly updated newsfeed
[DELETE] /newsfeed/:newsfeed_id/ Deletes the newsfeed object with the given newsfeed_id and returns the deleted newsfeed.

Conversations

{
  conversation_id: INCREMENT (primary key, auto-increments, generated by database),
  profile_id: INTEGER (required, foreign key),
}
Method URL Description
[GET] /conversation_id/ Returns an array filled with inbox event objects.
[GET] /conversation_id/:profile_id/ Retrieves an inbox with the specified inbox_id BUG(?): incorrectly labeled as profile_id in codebase rather than inbox_id
[POST] /conversation_id/ Creates an inbox and returns the newly created inbox.
[POST] /conversation_id/messages/ Returns the event object with the specified inbox_id. Sends a message.
[PUT] /conversation_id/:profile_id Returns an array filled with event objects with the specific profile_id. Updates an inbox.
[DELETE] /conversation_id/:profile_id/ Returns an array filled with event objects with the specific okta. Deletes an inbox.

Calendar Events

{
  event_id: INCREMENT (primary key, auto-increments, generated by database),
  date: STRING (required),
  time: STRING (required),
  type: STRING (required),
  content: STRING (required),
  details: STRING (required),
  profile_id: INTEGER (required, foreign key, auto-generated by database),
}
Method URL Description
[GET] /calendar-events/ Returns an array filled with calendar event objects.
[GET] /calendar-events/user/ Retrieves calendar event objects with the profile_id of logged in user
[GET] /calendar-events/:event_id/ Retrieves calendar event object with the specified event_id
[POST] /calendar-events/ Creates a calendar event and returns the newly created calendar event.
[PUT] /calendar-events/:event_id Updates and returns the updated calendar event object with the specific event_id.
[DELETE] /calendar-events/:event_id/ Deletes a calendar event and returns a success message on successful deletion.

Schedule (Not Implemented)

Method URL Description
[GET] /schedule/ Returns an array filled with event objects.
[GET] /schedule/:id/ Returns the event object with the specified id.
[POST] /schedule/ Returns the event object with the specified id. Creates a schedule.
[POST] /schedule/sessions/ Returns the event object with the specified id. Creates a session.
[PUT] /schedule/ Returns the event object with the specified id. Updates specific schedule.
[DELETE] /schedule/:id/ Returns the event object with the specified id. Deletes specific schedule.

Data Tables Without Existing Endpoints

Super Admins

{
  super_admin_id: INCREMENT (primary key, auto-increments, generated by database),
  profile_id: INTEGER (required, foreign key),
}

Admins

{
  admin_id: INCREMENT (primary key, auto-increments, generated by database),
  profile_id: INTEGER (required, foreign key),
}

Messages

{
  messages_id: INCREMENT (primary key, auto-increments, generated by database),
  sent_at: TIMESTAMP (auto-generated),
  title: STRING (required),
  read: BOOLEAN (required, default: false),
  message: STRING (required),
  sent_by_profile_id: INTEGER (required, foreign key),
  inbox_id: INTEGER (required, foreign key,
}

Instructors' Program Types

Join Table: Programs instructors are approved to teach

{
  instructors_program_types_id: INCREMENT (primary key, auto-increments, generated by database),
  instructor_id: INTEGER (required, foreign key),
  program_id: INTEGER (required, foreign key),
}

Enrollments

Join Table: Courses signed up for by children

{
  enrollments_id: INCREMENT (primary key, auto-increments, generated by database),
  completed: BOOLEAN (required, default: false),
  child_id: INTEGER (required, foreign key),
  course_id: INTEGER (required, foreign key),
}

Resources

{
  resource_id: INCREMENT (primary key, auto-increments, generated by database),
  resource: STRING (required),
  description: STRING (optional),
  task: BOOLEAN (required),
  instructor_id: INTEGER (required, foreign key),
}

Visual Database Schema: https://dbdesigner.page.link/WTZRbVeTR7EzLvs86 *Currently Outdated

Loom Video PT1 Loom Video PT2 Loom Video PT3 Loom Video PT4