Listen to music from Youtube and chat with everyone else watching the same video.
This is project is built with Next.js and Wundergraph and uses github authentication.There are also other 3rd party API's from https://randomuser.me and https://api.chucknorris.io/ which help keep the chat box lively.
-
Clone this repository.
-
Install dependencies with:
yarn-
Signup for mongodb-cloud and create a new project and a cluster. For the detailed mongodb-atlas setup see here.
-
Setup a github oAuth app. For the detailed setup see here.
-
Run the app
yarn startAll the services used are available under free-tier of mongo cloud.
- Create a new project and a cluster.
- Navigate into the cluster dashboard into the
Collectionstab. - Create a new collection named
Usersand add the following: Note: set datatype ofverifiedas boolean
{
"color" : "lime",
"name":"Pythonista7",
"verified":true
}- Create another Collection called public chat with the following:
Note: set datatype of
tsas DateTime
{
"color":"lime",
"id":"nkvg9c9oczM",
"msg":"sweet sweet rain.",
"name":"Pythonista7",
"ts": 2022-09-04T19:10:49.675+00:00
}Once we have sample data mongo cloud lets us generate a graphql schema from the sample data and also provides us a graphql endpoint to query/mutate the data into mongodb.
-
Navigate to
App Servicesand create a new app service. -
Go into the dashboard of the new service and open
Data Access > Schematab, where you have an option toGenerate Schemafrom existing data in the collection. Generate schema for both the created collections.They should look something like this:
{
"title": "PublicChat",
"properties": {
"_id": {
"bsonType": "objectId"
},
"color": {
"bsonType": "string"
},
"id": {
"bsonType": "string"
},
"msg": {
"bsonType": "string"
},
"name": {
"bsonType": "string"
},
"ts": {
"bsonType": "date"
}
}
}{
"title": "User",
"properties": {
"_id": {
"bsonType": "objectId"
},
"color": {
"bsonType": "string"
},
"name": {
"bsonType": "string"
},
"verified": {
"bsonType": "bool"
}
}
}-
IMPORTANT: Make sure you allow read and write roles to both the collections under
Data Access>Rules. -
Now we're all set to use a graphql endpoint. Head over to
Build>GraphQLtab to try out the graphiql and copy the graphql endpoint and save toMONGODB_ENDPOINTin.envfile. -
Lastly to access this api we need to create a new user for this
App Serviceby navigating toData Access>App Usersand creating a new user. This will give us an API key to use for authentication. Make sure you immediately save this key as it'll only be shown to you on creation. Add this api key toMONGODB_APIKEYin.envfile. -
MongoDB is now ready !
-
Enter in your details and give the
Authorization callback URLas http://localhost:9991/app/main/auth/cookie/callback/github and generate the OAuth App. -
Copy the client id and client secret and save them as
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRETrespectively in.envfile.
