https://greenfield-hippos-backend.onrender.com/
To help software engineering students improve their skills and knowledge
- Laurence (CC36)
- Vicente (CC36)
- Jason (CC36)
- Node.js
- Express.js
- Knex.js
- PostgreSQL
-
Clone the repo locally using your preferred method (HTTPS, SSH, etc.)
-
On your local machine, open command line, go to the root directly of the repo, and run
npm installto install all dependencies -
Create a
.env.localfile with a line to assign a value forOPENAI_API_KEY. Ask a team member for the value that should be used for this key -
Finally, run
npm startto start the server. Note that it will run on port 8080 if no value is specified for the environment variableprocess.env.PORT
-
For local testing, connect to
psqlto create a database using the commandCREATE DATABASE greenfield; -
Back in your terminal, run
npm buildto trigger the migrations that will create the database tables you need -
Using Postman, while the server is running, create a user for yourself by sending a
POSTcommand to the endpoint/signupwith the following JSON body. If it's successful, you will receive a reply with the JSON for your newly created user in its body
{
"username": "putYourUserNameHere",
"password": "putYourPasswordHere"
}
-
In psql, verify your new user exists locally by running the command
SELECT * FROM chat_user;. You should see your new user as a row in the table that is output. -
In terminal, run
npm run seedto run the seeds that will populate the other database tables,messageandconversationwith dummy data.
Now you should have what you need to get started!
-
POST
/signup: Used to create a new user account. Expectsusernameandpasswordin the JSON request body. Responds with the user object that was created -
POST
/login: Used to log in with an existing user account. Expectsusernameandpasswordin the JSON request body. Responds with the user object that was created and a boolean,authenticationSuccessful, that indicates the result of the attempted login -
POST
/logout: Used to log out of a user account. Does not expect anything in the request body -
POST
/api/chat: Used to interface with ChatGPT. Expectsuser_idandmessagein the JSON request body. Including an optionalconversation_idwill allow the message to be associated with an existing conversation instead of creating a new one. Responds with theresponsefrom ChatGPT and theconversation_idassociated with the current conversation -
GET
/users/:uid/messages: Used to retrieve all messages associated with a given user ID. Responds with an array ofmessageobjects -
GET
/users/:uid/conversations/:cid/messages: Used to retrieve all messages associated with a given conversation ID for a given user. Responds with an array ofmessageobjects -
GET
/users/:uid/conversations: Used to retrieve all conversations associated with a given user ID. Responds with an array ofconversationobjects