Skip to content

emaranowski/erm-api-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meetup Clone

Intro

The project is a light clone of Meetup, with features for groups that can host events.

Users can view, create, update, and delete groups (including adding group images upon group creation).

Groups include information on group name, organizer name, location, visibility (public/private), description, and number of events (total, upcoming, and past).

Groups can be made by any user. The user that creates the group is its organizer.

Users can view, create, update, and delete events for a group (including adding event images upon event creation).

Events include information on event name, host name, hosting group, start date and time, end date and time, price, type (in person/online), description.

Events can be made by the organizer or any co-hosts of the group that hosts the event.

Technologies Used

Backend: Express router, and Seqeulize to build the local database using SQLite.

Frontend: React and Redux.

Languages: JavaScript, HTML, and CSS.

Deployment: Render (using PostgreSQL).

Landing Page

meetbuds

Launch Instructions

  • Clone this repo.

  • In the root directory, run npm i -D.

  • In the backend directory, run npm i -D.

  • In the backend, create a .env file modeled after .env.example, editing any details as desired, and adding your own JWT_SECRET.

  • In the backend, run migrations and seeders: npx dotenv sequelize db:migrate && npx dotenv sequelize db:seed:all. If needed, undo with: npx dotenv sequelize db:seed:undo:all && npx dotenv sequelize db:migrate:undo:all.

  • In the backend directory, run npm start.

  • In the frontend directory, run npm i -D.

  • In the frontend directory, run npm start.

Database Schema Design

meetup-database-schema

API Documentation

USER AUTHENTICATION/AUTHORIZATION

All endpoints that require authentication

All endpoints that require a current user to be logged in.

  • Request: endpoints that require authentication
  • Error Response: Require authentication
    • Status Code: 401

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Authentication required"
      }

All endpoints that require proper authorization

All endpoints that require authentication and the current user does not have the correct role(s) or permission(s).

  • Request: endpoints that require proper authorization
  • Error Response: Require proper authorization
    • Status Code: 403

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Forbidden"
      }

Get the Current User

Returns the information about the current user that is logged in.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/session
    • Body: none
  • Successful Response when there is a logged in user

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "user": {
          "id": 1,
          "firstName": "John",
          "lastName": "Smith",
          "email": "[email protected]",
          "username": "JohnSmith"
        }
      }
  • Successful Response when there is no logged in user

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "user": null
      }

Log In a User

Logs in a current user with valid credentials and returns the current user's information.

  • Require Authentication: false

  • Request

    • Method: POST

    • URL: /api/session

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "credential": "[email protected]",
        "password": "secret password"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "user": {
          "id": 1,
          "firstName": "John",
          "lastName": "Smith",
          "email": "[email protected]",
          "username": "JohnSmith"
        }
      }
  • Error Response: Invalid credentials

    • Status Code: 401

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Invalid credentials"
      }
  • Error response: Body validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "email": "Email is required",
          "password": "Password is required"
        }
      }

Sign Up a User

Creates a new user, logs them in as the current user, and returns the current user's information.

  • Require Authentication: false

  • Request

    • Method: POST

    • URL: /api/users

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "firstName": "John",
        "lastName": "Smith",
        "email": "[email protected]",
        "username": "JohnSmith",
        "password": "secret password"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "user": {
          "id": 1,
          "firstName": "John",
          "lastName": "Smith",
          "email": "[email protected]",
          "username": "JohnSmith"
        }
      }
  • Error response: User already exists with the specified email

    • Status Code: 500

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "User already exists",
        "errors": {
          "email": "User with that email already exists"
        }
      }
  • Error response: User already exists with the specified username

    • Status Code: 500

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "User already exists",
        "errors": {
          "username": "User with that username already exists"
        }
      }
  • Error response: Body validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "email": "Invalid email",
          "firstName": "First Name is required",
          "lastName": "Last Name is required"
        }
      }

GROUPS

Get all Groups

Returns all the groups.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/groups
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Groups": [
          {
            "id": 1,
            "organizerId": 1,
            "name": "Evening Tennis on the Water",
            "about": "Enjoy rounds of tennis with a tight-nit group of people on the water facing the Brooklyn Bridge. Singles or doubles.",
            "type": "In person",
            "privacy": true,
            "city": "New York",
            "state": "NY",
            "createdAt": "2021-11-19 20:39:36",
            "updatedAt": "2021-11-19 20:39:36",
            "numMembers": 10,
            "previewImage": "image url",
          }
        ]
      }

Get all Groups joined or organized by the Current User

Returns all the groups.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/groups/current
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Groups": [
          {
            "id": 1,
            "organizerId": 1,
            "name": "Evening Tennis on the Water",
            "about": "Enjoy rounds of tennis with a tight-nit group of people on the water facing the Brooklyn Bridge. Singles or doubles.",
            "type": "In person",
            "privacy": true,
            "city": "New York",
            "state": "NY",
            "createdAt": "2021-11-19 20:39:36",
            "updatedAt": "2021-11-19 20:39:36",
            "numMembers": 10,
            "previewImage": "image url",
          }
        ]
      }

Get details of a Group from an id

Returns the details of a group specified by its id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/groups/:groupId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "organizerId": 1,
        "name": "Evening Tennis on the Water",
        "about": "Enjoy rounds of tennis with a tight-nit group of people on the water facing the Brooklyn Bridge. Singles or doubles.",
        "type": "In person",
        "privacy": true,
        "city": "New York",
        "state": "NY",
        "createdAt": "2021-11-19 20:39:36",
        "updatedAt": "2021-11-19 20:39:36",
        "numMembers": 10,
        "GroupImages": [
          {
            "id": 1,
            "url": "image url",
            "preview": true
          },
          {
            "id": 2,
            "url": "image url",
            "preview": false
          }
        ],
        "Organizer": {
          "id": 1,
          "firstName": "John",
          "lastName": "Smith"
        },
        "Venues": [
          {
            "id": 1,
            "groupId": 1,
            "address": "123 Disney Lane",
            "city": "New York",
            "state": "NY",
            "lat": 37.7645358,
            "lng": -122.4730327
          }
        ]
      }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found",
      }

Create a Group

Creates and returns a new group.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: /api/groups

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "name": "Evening Tennis on the Water",
        "about": "Enjoy rounds of tennis with a tight-nit group of people on the water facing the Brooklyn Bridge. Singles or doubles.",
        "type": "In person",
        "privacy": true,
        "city": "New York",
        "state": "NY",
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "organizerId": 1,
        "name": "Evening Tennis on the Water",
        "about": "Enjoy rounds of tennis with a tight-nit group of people on the water facing the Brooklyn Bridge. Singles or doubles.",
        "type": "In person",
        "privacy": true,
        "city": "New York",
        "state": "NY",
        "createdAt": "2021-11-19 20:39:36",
        "updatedAt": "2021-11-19 20:39:36"
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "name": "Name must be 60 characters or less",
          "about": "Description must be 30 characters or more",
          "type": "Type must be 'Online' or 'In Person'",
          "privacy": "Privacy must be a boolean",
          "city": "City is required",
          "state": "State is required",
        }
      }

Add an Image to a Group based on the Group's id

Create and return a new image for a group specified by id.

  • Require Authentication: true

  • Require proper authorization: Current User must be the organizer for the group

  • Request

    • Method: POST

    • URL: /api/groups/:groupId/images

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "url": "image url",
        "preview": true
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "url": "image url",
        "preview": true
      }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }

Edit a Group

Updates and returns an existing group.

  • Require Authentication: true

  • Require proper authorization: Group must belong to the current user

  • Request

    • Method: PUT

    • URL: /api/groups/:groupId

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "name": "Evening Tennis on the Water",
        "about": "Enjoy rounds of tennis with a tight-nit group of people on the water facing the Brooklyn Bridge. Singles or doubles.",
        "type": "In person",
        "privacy": true,
        "city": "New York",
        "state": "NY",
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "organizerId": 1,
        "name": "Evening Tennis on the Water",
        "about": "Enjoy rounds of tennis with a tight-nit group of people on the water facing the Brooklyn Bridge. Singles or doubles.",
        "type": "In person",
        "privacy": true,
        "city": "New York",
        "state": "NY",
        "createdAt": "2021-11-19 20:39:36",
        "updatedAt": "2021-11-20 10:06:40"
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "name": "Name must be 60 characters or less",
          "about": "Description must be 30 characters or more",
          "type": "Type must be 'Online' or 'In Person'",
          "privacy": "Privacy must be a boolean",
          "city": "City is required",
          "state": "State is required",
        }
      }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }

Delete a Group

Deletes an existing group.

  • Require Authentication: true

  • Require proper authorization: Group must belong to the current user

  • Request

    • Method: DELETE
    • URL: /api/groups/:groupId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }

VENUES

Get All Venues for a Group specified by its id

Returns all venues for a group specified by its id

  • Require Authentication: true

  • Require Authentication: Current User must be the organizer of the group or a member of the group with a status of "co-host"

  • Request

    • Method: GET
    • URL: /api/groups/:groupId/venues
    • Headers:
      • Content-Type: application/json
    • Body: none
  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
    {
      "Venues": [
        {
          "id": 1,
          "groupId": 1,
          "address": "123 Disney Lane",
          "city": "New York",
          "state": "NY",
          "lat": 37.7645358,
          "lng": -122.4730327,
        }
      ]
    }
    
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }

Create a new Venue for a Group specified by its id

Creates and returns a new venue for a group specified by its id

  • Require Authentication: true

  • Require Authentication: Current User must be the organizer of the group or a member of the group with a status of "co-host"

  • Request

    • Method: POST
    • URL: /api/groups/:groupId/venues
    • Headers:
      • Content-Type: application/json
    • Body:
    {
      "address": "123 Disney Lane",
      "city": "New York",
      "state": "NY",
      "lat": 37.7645358,
      "lng": -122.4730327,
    }
  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
    {
      "id": 1,
      "groupId": 1,
      "address": "123 Disney Lane",
      "city": "New York",
      "state": "NY",
      "lat": 37.7645358,
      "lng": -122.4730327,
    }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }
  • Error Response: Body validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "address": "Street address is required",
          "city": "City is required",
          "state": "State is required",
          "lat": "Latitude is not valid",
          "lng": "Longitude is not valid",
        }
      }

Edit a Venue specified by its id

Edit a new venue specified by its id

  • Require Authentication: true

  • Require Authentication: Current User must be the organizer of the group or a member of the group with a status of "co-host"

  • Request

    • Method: PUT
    • URL: /api/venues/:venueId
    • Headers:
      • Content-Type: application/json
    • Body:
    {
      "address": "123 Disney Lane",
      "city": "New York",
      "state": "NY",
      "lat": 37.7645358,
      "lng": -122.4730327,
    }
  • Successful Response

    • Status Code: 200
    • Headers:
      • Content-Type: application/json
    • Body:
    {
      "id": 1,
      "groupId": 1,
      "address": "123 Disney Lane",
      "city": "New York",
      "state": "NY",
      "lat": 37.7645358,
      "lng": -122.4730327,
    }
  • Error response: Couldn't find a Venue with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Venue couldn't be found"
      }
  • Error Response: Body validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "address": "Street address is required",
          "city": "City is required",
          "state": "State is required",
          "lat": "Latitude is not valid",
          "lng": "Longitude is not valid",
        }
      }

EVENTS

Get all Events

Returns all the events.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/events
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Events": [
          {
            "id": 1,
            "groupId": 1,
            "venueId": null,
            "name": "Tennis Group First Meet and Greet",
            "type": "Online",
            "startDate": "2021-11-19 20:00:00",
            "endDate": "2021-11-19 22:00:00",
            "numAttending": 8,
            "previewImage": "image url",
            "Group": {
              "id": 1,
              "name": "Evening Tennis on the Water",
              "city": "New York",
              "state": "NY"
            },
            "Venue": null,
          },
          {
            "id": 1,
            "groupId": 1,
            "venueId": 1,
            "name": "Tennis Singles",
            "type": "In Person",
            "startDate": "2021-11-20 20:00:00",
            "endDate": "2021-11-19 22:00:00",
            "numAttending": 4,
            "previewImage": "image url",
            "Group": {
              "id": 1,
              "name": "Evening Tennis on the Water",
              "city": "New York",
              "state": "NY"
            },
            "Venue": {
              "id": 1,
              "city": "New York",
              "state": "NY",
            },
          },
        ]
      }

Get all Events of a Group specified by its id

Returns all the events of a group specified by its id

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/groups/:groupId/events
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Events": [
          {
            "id": 1,
            "groupId": 1,
            "venueId": null,
            "name": "Tennis Group First Meet and Greet",
            "type": "Online",
            "startDate": "2021-11-19 20:00:00",
            "endDate": "2021-11-19 22:00:00",
            "numAttending": 8,
            "previewImage": "image url",
            "Group": {
              "id": 1,
              "name": "Evening Tennis on the Water",
              "city": "New York",
              "state": "NY"
            },
            "Venue": null,
          },
          {
            "id": 1,
            "groupId": 1,
            "venueId": 1,
            "name": "Tennis Singles",
            "type": "In Person",
            "startDate": "2021-11-20 20:00:00",
            "endDate": "2021-11-19 22:00:00",
            "numAttending": 4,
            "previewImage": "image url",
            "Group": {
              "id": 1,
              "name": "Evening Tennis on the Water",
              "city": "New York",
              "state": "NY"
            },
            "Venue": {
              "id": 1,
              "city": "New York",
              "state": "NY",
            },
          },
        ]
      }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }

Get details of an Event specified by its id

Returns the details of an event specified by its id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/events/:eventId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "groupId": 1,
        "venueId": 1,
        "name": "Tennis Group First Meet and Greet",
        "description": "First meet and greet event for the evening tennis on the water group! Join us online for happy times!",
        "type": "Online",
        "capacity": 10,
        "price": 18.50,
        "startDate": "2021-11-19 20:00:00",
        "endDate": "2021-11-19 22:00:00",
        "numAttending": 8,
        "Group": {
          "id": 1,
          "name": "Evening Tennis on the Water",
          "privacy": true,
          "city": "New York",
          "state": "NY"
        },
        "Venue": {
          "id": 1,
          "address": "123 Disney Lane",
          "city": "New York",
          "state": "NY",
          "lat": 37.7645358,
          "lng": -122.4730327,
        },
        "EventImages": [
          {
            "id": 1,
            "url": "image url",
            "preview": true
          },
          {
            "id": 2,
            "url": "image url",
            "preview": false
          }
        ],
      }
  • Error response: Couldn't find a Event with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Event couldn't be found"
      }

Create an Event for a Group specified by its id

Creates and returns a new event for a group specified by its id

  • Require Authentication: true

  • Require Authorization: Current User must be the organizer of the group or a member of the group with a status of "co-host"

  • Request

    • Method: POST

    • URL: /api/groups/:groupId/events

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "venueId": 1,
        "name": "Tennis Group First Meet and Greet",
        "type": "Online",
        "capacity": 10,
        "price": 18.50,
        "description": "The first meet and greet for our group! Come say hello!",
        "startDate": "2021-11-19 20:00:00",
        "endDate": "2021-11-19 22:00:00",
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "groupId": 1,
        "venueId": 1,
        "name": "Tennis Group First Meet and Greet",
        "type": "Online",
        "capacity": 10,
        "price": 18.50,
        "description": "The first meet and greet for our group! Come say hello!",
        "startDate": "2021-11-19 20:00:00",
        "endDate": "2021-11-19 22:00:00",
      }
  • Error Response: Body validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "venueId": "Venue does not exist",
          "name": "Name must be at least 5 characters",
          "type": "Type must be Online or In person",
          "capacity": "Capacity must be an integer",
          "price": "Price is invalid",
          "description": "Description is required",
          "startDate": "Start date must be in the future",
          "endDate": "End date is less than start date",
        }
      }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }

Add an Image to a Event based on the Event's id

Create and return a new image for an event specified by id.

  • Require Authentication: true

  • Require proper authorization: Current User must be an attendee, host, or co-host of the event

  • Request

    • Method: POST

    • URL: /api/events/:eventId/images

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "url": "image url",
        "preview": false
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "url": "image url",
        "preview": false
      }
  • Error response: Couldn't find an Event with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Event couldn't be found"
      }

Edit an Event specified by its id

Edit and returns an event specified by its id

  • Require Authentication: true

  • Require Authorization: Current User must be the organizer of the group or a member of the group with a status of "co-host"

  • Request

    • Method: PUT

    • URL: /api/events/:eventId

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "venueId": 1,
        "name": "Tennis Group First Meet and Greet",
        "type": "Online",
        "capacity": 10,
        "price": 18.50,
        "description": "The first meet and greet for our group! Come say hello!",
        "startDate": "2021-11-19 20:00:00",
        "endDate": "2021-11-19 22:00:00",
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "groupId": 1,
        "venueId": 1,
        "name": "Tennis Group First Meet and Greet",
        "type": "Online",
        "capacity": 10,
        "price": 18.50,
        "description": "The first meet and greet for our group! Come say hello!",
        "startDate": "2021-11-19 20:00:00",
        "endDate": "2021-11-19 22:00:00",
      }
  • Error Response: Body validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "venueId": "Venue does not exist",
          "name": "Name must be at least 5 characters",
          "type": "Type must be Online or In person",
          "capacity": "Capacity must be an integer",
          "price": "Price is invalid",
          "description": "Description is required",
          "startDate": "Start date must be in the future",
          "endDate": "End date is less than start date",
        }
      }
  • Error response: Couldn't find a Venue with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Venue couldn't be found"
      }
  • Error response: Couldn't find an Event with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Event couldn't be found"
      }

Delete an Event specified by its id

Delete an event specified by its id

  • Require Authentication: true

  • Require Authorization: Current User must be the organizer of the group or a member of the group with a status of "co-host"

  • Request

    • Method: DELETE
    • URL: /api/events/:eventId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find an Event with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Event couldn't be found"
      }

MEMBERSHIPS

Get all Members of a Group specified by its id

Returns the members of a group specified by its id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/groups/:groupId/members
    • Body: none
  • Successful Response: If you ARE the organizer or a co-host of the group. Shows all members and their statuses.

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Members": [
          {
            "id": 2,
            "firstName": "Clark",
            "lastName": "Adams",
            "Membership": {
              "status": "co-host"
            },
          },
          {
            "id": 3,
            "firstName": "John",
            "lastName": "Smith",
            "Membership": {
              "status": "member"
            },
          },
          {
            "id": 4,
            "firstName": "Jane",
            "lastName": "Doe",
            "Membership": {
              "status": "pending"
            },
          },
        ]
      }
  • Successful Response: If you ARE NOT the organizer of the group. Shows only members that don't have a status of "pending".

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Members": [
          {
            "id": 2,
            "firstName": "Clark",
            "lastName": "Adams",
            "Membership": {
              "status": "co-host"
            },
          },
          {
            "id": 3,
            "firstName": "John",
            "lastName": "Smith",
            "Membership": {
              "status": "member"
            },
          },
        ]
      }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }

Request a Membership for a Group based on the Group's id

Request a new membership for a group specified by id.

  • Require Authentication: true

  • Request

    • Method: POST
    • URL: /api/groups/:groupId/membership
    • Headers:
      • Content-Type: application/json
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "memberId": 2,
        "status": "pending"
      }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }
  • Error response: Current User already has a pending membership for the group

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Membership has already been requested"
      }
  • Error response: Current User is already an accepted member of the group

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "User is already a member of the group"
      }

Change the status of a membership for a group specified by id

Change the status of a membership for a group specified by id.

  • Require Authentication: true

  • Require proper authorization:

    • To change the status from "pending" to "member":
      • Current User must already be the organizer or have a membership to the group with the status of "co-host"
    • To change the status from "member" to "co-host":
      • Current User must already be the organizer
  • Request

    • Method: PUT

    • URL: /api/groups/:groupId/membership

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "memberId": 2,
        "status": "member"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "groupId": 1,
        "memberId": 2,
        "status": "member"
      }
  • Error response: If changing the membership status to "pending".

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validations Error",
        "errors": {
          "status" : "Cannot change a membership status to pending"
        }
      }
  • Error response: Couldn't find a User with the specified memberId

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation Error",
        "errors": {
          "memberId": "User couldn't be found"
        }
      }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }
  • Error response: If membership does not exist

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Membership between the user and the group does not exist"
      }

Delete membership to a group specified by id

Delete a membership to a group specified by id.

  • Require Authentication: true

  • Require proper authorization: Current User must be the host of the group, or the user whose membership is being deleted

  • Request

    • Method: DELETE

    • URL: /api/groups/:groupId/membership

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "memberId": 1
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted membership from group"
      }
  • Error response: Couldn't find a User with the specified memberId

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation Error",
        "errors": {
          "memberId": "User couldn't be found"
        }
      }
  • Error response: Couldn't find a Group with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group couldn't be found"
      }
  • Error response: Membership does not exist for this User

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Membership does not exist for this User"
      }

ATTENDEES

Get all Attendees of an Event specified by its id

Returns the attendees of an event specified by its id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/events/:eventId/attendees
    • Body: none
  • Successful Response: If you ARE the organizer of the group or a member of the group with a status of "co-host". Shows all attendees including those with a status of "pending".

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Attendees": [
          {
            "id": 2,
            "firstName": "Clark",
            "lastName": "Adams",
            "Attendance": {
              "status": "attending"
            },
          },
          {
            "id": 3,
            "firstName": "John",
            "lastName": "Smith",
            "Attendance": {
              "status": "waitlist"
            },
          },
          {
            "id": 4,
            "firstName": "Jane",
            "lastName": "Doe",
            "Attendance": {
              "status": "pending"
            },
          },
        ]
      }
  • Successful Response: If you ARE NOT the organizer of the group or a member of the group with a status of "co-host". Shows all members that don't have a status of "pending".

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Attendees": [
          {
            "id": 2,
            "firstName": "Clark",
            "lastName": "Adams",
            "Attendance": {
              "status": "attending"
            },
          },
          {
            "id": 3,
            "firstName": "John",
            "lastName": "Smith",
            "Attendance": {
              "status": "waitlist"
            },
          },
        ]
      }
  • Error response: Couldn't find an Event with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Event couldn't be found"
      }

Request to Attend an Event based on the Event's id

Request attendance for an event specified by id.

  • Require Authentication: true

  • Require Authorization: Current User must be a member of the group

  • Request

    • Method: POST
    • URL: /api/events/:eventId/attendance
    • Headers:
      • Content-Type: application/json
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "userId": 2,
        "status": "pending"
      }
  • Error response: Couldn't find an Event with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Event couldn't be found"
      }
  • Error response: Current User already has a pending attendance for the event

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Attendance has already been requested"
      }
  • Error response: Current User is already an accepted attendee of the event

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "User is already an attendee of the event"
      }

Change the status of an attendance for an event specified by id

Change the status of an attendance for an event specified by id.

  • Require Authentication: true

  • Require proper authorization: Current User must already be the organizer or have a membership to the group with the status of "co-host"

  • Request

    • Method: PUT

    • URL: /api/events/:eventId/attendance

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "userId": 2,
        "status": "attending"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "eventId": 1,
        "userId": 2,
        "status": "attending"
      }
  • Error response: Couldn't find an Event with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Event couldn't be found"
      }
  • Error response: If changing the attendance status to "pending".

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Cannot change an attendance status to pending"
      }
  • Error response: If attendance does not exist

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Attendance between the user and the event does not exist"
      }

Delete attendance to an event specified by id

Delete an attendance to an event specified by id.

  • Require Authentication: true

  • Require proper authorization: Current User must be the host of the group, or the user whose attendance is being deleted

  • Request

    • Method: DELETE

    • URL: /api/events/:eventId/attendance

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "userId": 1
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted attendance from event"
      }
  • Error response: Couldn't find an Event with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Event couldn't be found"
      }
  • Error response: Attendance does not exist for this User

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Attendance does not exist for this User"
      }
  • Error response: Only the User or organizer may delete an Attendance

    • Status Code: 403

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Only the User or organizer may delete an Attendance"
      }

IMAGES

Delete an Image for a Group

Delete an existing image for a Group.

  • Require Authentication: true

  • Require proper authorization: Current user must be the organizer or "co-host" of the Group

  • Request

    • Method: DELETE
    • URL: /api/group-images/:imageId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find an Image with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Group Image couldn't be found"
      }

Delete an Image for an Event

Delete an existing image for an Event.

  • Require Authentication: true

  • Require proper authorization: Current user must be the organizer or "co-host" of the Group that the Event belongs to

  • Request

    • Method: DELETE
    • URL: /api/event-images/:imageId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find an Image with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Event Image couldn't be found"
      }

Add Query Filters to Get All Events

Return events filtered by query parameters.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/events
    • Query Parameters
      • page: integer, minimum: 1, maximum: 10, default: 1
      • size: integer, minimum: 1, maximum: 20, default: 20
      • name: string, optional
      • type: string, optional
      • startDate: string, optional
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Events": [
          {
            "id": 1,
            "groupId": 1,
            "venueId": null,
            "name": "Tennis Group First Meet and Greet",
            "type": "Online",
            "startDate": "2021-11-19 20:00:00",
            "endDate": "2021-11-19 22:00:00",
            "numAttending": 8,
            "previewImage": "image url",
            "Group": {
              "id": 1,
              "name": "Evening Tennis on the Water",
              "city": "New York",
              "state": "NY"
            },
            "Venue": null,
          },
          {
            "id": 1,
            "groupId": 1,
            "venueId": 1,
            "name": "Tennis Singles",
            "type": "In Person",
            "startDate": "2021-11-20 20:00:00",
            "endDate": "2021-11-19 22:00:00",
            "numAttending": 4,
            "previewImage": "image url",
            "Group": {
              "id": 1,
              "name": "Evening Tennis on the Water",
              "city": "New York",
              "state": "NY"
            },
            "Venue": {
              "id": 1,
              "city": "New York",
              "state": "NY",
            },
          },
        ]
      }
  • Error Response: Query parameter validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "page": "Page must be greater than or equal to 1",
          "size": "Size must be greater than or equal to 1",
          "name": "Name must be a string",
          "type": "Type must be 'Online' or 'In Person'",
          "startDate": "Start date must be a valid datetime",
        }
      }

About

API project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published