The project contains the API surface that supports the following Hey Mentor projects. See the API Surface section below for more details.
-
Node.js and NPM
-
MongoDB
-
Environment Variables
You can set up your own deployment by following these steps:
-
You can download the community server if you want to run the DB locally, or you can sign up for MongoDB Atlas, which is free cloud hosting of a Mongo DB instance.
This tutorial will assume that you are deploying the community server version.
Special notes for installing on Windows:
* Choose the MSI installer * Use default settings to install as network service * You may need to create a folder C:\data\db
-
Execute Mongo DB once you have it installed
For Windows, "C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe"
-
Install MongoDB Compass, Robo3T or any preferred Mongo DB UI
-
In the UI, connect to your MongoDB database, usually
localhost:27017
-
Create one database called
HeyMentor
(only do this the first time you set up)In the new database, create a new collection:
Users
-
In order to correctly populate the DB, and to run the API itself, you will need an environment variables file.
Under the root project folder, create a new file:
.env
If you are part of the Hey Mentor dev team, contact your administrator for the correct
.env
data. -
To test that your deployment is working, run the test suite
npm test
<Set .env with correct variables>
npm install
npm start
Once you correctly have Mongoose running locally on your machine (following the instructions above),and you have the correct environment variables, you can run npm run db:populate
to populate the db with a bunch of fake data for local testing and development work.
Before submitting changes, run the test suite locally via npm test
to identify any test or linting failures
Endpoint: /register/<facebook||google>?access_token=<token>
Upgrades a federated identity access token (example: a Facebook access token) for a Hey Mentor identity token (api key), which can be used to authenticate against the API.
Response: Identity Token, User ID, or Error
Endpoint: GET /profile/:userId?token=<token>
- Gets the user data of the given user.
Endpoint: PUT /profile/:userId?token=<token>
- Update a users profile data
Body:
{
user: {
person: ...
demo: ...
.
.
.
}
}
Endpoint: GET /contacts/:userId?token=<token>
- Gets the public contact info of the users contacts.
Endpoint: POST /chat/token/:userId?token=<token>
- Generates a chat token for client side messaging
Body:
{
device: <client device ID>
}
Endpoint: POST /admin/chat/create?token=<token>
- Creates a user account with chat capability, from an existing Hey Mentor user
Body:
{
user_id: <ID of an existing Hey Mentor user>
}
Endpoint: POST /admin/chat/channel/create?token=<token>
- Creates a fully-initialized chat channel for communication between a set of users
Body:
{
"user_ids": [<User Ids array -- array of strings>]
}