Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transcendence

Implementing a multiplayer responsive Pong game website SPA using NestJs and React.

HomePage

PongPage

ProfilePage

Technologies used

Commands

  • docker compose : docker-compose up --build
  • Makefile : make
  • clean volumes + images + containers : make clean
  • postgres : npm run postgres:up
  • bakend: npm run backend:build
  • frontend : npm run frontend:build
  • deploy depuis le local : cd backend + npm run prima:dev:deploy

Auth

OAuth flow

  • 1 : Creating a client UID and a secret to 42's API
  • 2 : NextAuth is a NextJS library that gives access to providers exposing their API. Amongst which there was 42-School.

Tuto followed for A, B, C steps: https://youtu.be/AbUVY16P4Ys

Tuto followed for for D, E steps: https://api.intra.42.fr/apidoc

  • A : In the lib/auth.ts, we had to add the FortyProvider to the list of the providers to which we'd like to send requests - as an attribute to authConfig(which is of type NextAuthOptions)
  • B : In the api/auth/[...nextauth]/route.ts we had to define a handler that takes authConfig as an argument. The handler could make GET and POST requests.
  • C : We were obliged to create a callback page (and introduce it to 42's API params) in the path api/auth/[...nextAuth]/callback/42-school (defined by NextAuth). That page would either receive an access code(in case the auth went alrigth), or get notified that something went wrong.
  • D : After having the access code from the authorization server, we exchange it with an access token by sending a POST fetch to the 42's API endpoint (https://api.intra.42.fr/oauth/token)
  • E : The response to the fetch request above should be added as a header ("Authorization: Bearer YOUR_ACCESS_TOKEN") to all the API calls to access 42's API exposed data

Updating prisma scheme - Steps

  • 1 : Edit schema.prisma
  • 2 : Launch Postgres (docker compose up --build postgres)
  • 3 : Move to "./srcs/backend" and run : npm run prisma:dev:dev ("prisma:dev:dev": "npx dotenv -e ./prisma/.env.dev npx prisma migrate dev") (.env.dev names POSTGRES_HOST to "localhost")
  • 4 : If none of the above works, delete the folder "migrations" and start steps 2 and 3

Authors

Deployment

To deploy this project run

git clone https://github.com/LolinEagle/Transcendence && cd Transcendence && make

Related projects

Here are some related projects

Inception

Net Practice

About

Implementing a multiplayer responsive Pong game website.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages