Skip to content

Latest commit

 

History

History
212 lines (155 loc) · 4.78 KB

README.md

File metadata and controls

212 lines (155 loc) · 4.78 KB

Togather

Togather is a mobile application that encourages social interaction between people during gatherings.

This repo serves as the backend for Togather, powered by Express, Socket.io and MongoDB.

Requirements

Node 8 or greater is required. You also need to install MongoDB locally.

Running the project

Assuming you have all the requirements installed, you can setup and run the project by running:

  • mongodb.exe --dbpath [DB_ROOT] to start up MongoDB server
  • npm install to install the dependencies
  • npm server.js to start up backend

Libraries

Libraries used:

Endpoints

User collection

POST /users

Create a user with incoming JSON data. New authentication token is created.

  • Request

    {
      "email": "[email protected]",
      "password": "password123",
      "firstName": "Exam",
      "lastName": "Ple"
    }
  • Response

    • x-auth header

POST /users/login

Logs in user. New authentication token is created.

  • Request

    {
      "email": "[email protected]",
      "password": "password123",
    }
  • Response

    • x-auth header

DELETE /users/me/token

End user session and delete authentication token. To include x-auth header.

GET /users/me

Get current user details with user's list of events. To include x-auth header.

  • Response

    {
      "_id": "507f191e810c19729de860ea",
      "email": "[email protected]", 
      "firstName": "Exam",
      "lastName": "Ple",
      "events": [
        "507f191e810c19760de86011"
      ]
    }

GET /users/:id

Get user public details. To include x-auth header.

  • Parameter

    • id of user
  • Response

    {
      "_id": "507f191e810c19729de860ea",
      "email": "[email protected]", 
      "firstName": "Exam",
      "lastName": "Ple"
    }

Event collection

POST /events

Create events with current user in member list and update user's event list. To include x-auth header.

  • Request

    {
      "title": "My Event",
      "time": 1427238000000, 
      "latitude": 1.75938746593,
      "longitude": 3.57493748506,
      "duration": 7200000,
    }
  • Response

    {
      "event_id": "507f191e810c19760de86011",
      "room_key": "EOAJV"
    }

POST /events/join

Adds current user to event's member list and update user's event list. To include x-auth header.

  • Request

    {
      "room_key": "EOAJV"
    }
  • Response

    {
      "event_id": "507f191e810c19760de86011",
      "room_key": "EOAJV"
    }

POST /events/leave

Removes current user from event's member list and update user's event list. To include x-auth header.

  • Request

    {
      "room_key": "EOAJV"
    }
  • Response

    {
      "event_id": "507f191e810c19760de86011",
      "room_key": "EOAJV"
    }

GET /events

Retrieves events details of current user. To include x-auth header.

  • Response

    [
        {
            "coin": 0,
            "status": false,
            "members": [
                "5c43e2907fb10e07b0eef1c2",
                ...
            ],
            "_id": "507f191e810c19760de86011",
            "title": "My Event",
            "time": "2015-03-24T09:30:48.585Z", 
            "latitude": 1.75938746593,
            "longitude": 3.57493748506,
            "duration": 7200000,
            "key": "EOAJV",
        },
        ...
    ]