npm install
docker-compose up -d
You haven't installed docker and docker-compose on your system?
You'll only need these commands when using docker-compose:
# start running containers
docker-compose up -d
# shut-down running containers
docker-compose down
# list running containers
docker-compose ps
Initial setup:
docker-compose up -d
npx prisma db push
Run:
npm run dev
Then visit http://localhost:3000
.
Stop your current running dev server.
Add the debugger;
keyword to your code:
Go to debug tab in VSCode and click on the green Start debugging
button. This will start a dev server in debug mode and you can visit localhost:3000
:
npm run test
Optionally, you can add a name pattern of the file name:
npm run test User
Check test coverage:
npm run test:coverage
- open file
./coverage/lcov-report/index.html
We're using PlanetScale for our database. It uses a MySql database, however PlanetScale doesn't support foreign key constraints and we enabled this on the Prisma level instead of having it at the DB level.
This means there's one thing we need to consider now:
We now always need to add an @@index([...])
if we add a foreign key (otherwise certain queries would run slower).
- find a detailed explaination in this video: https://youtu.be/iaHt5_hg44c?t=757
Here is a more detailed documentation on using Prisma with Planetscale: https://www.prisma.io/docs/guides/database/using-prisma-with-planetscale
We are going to use firebase to create the credentials for us. We can use Google cloud console directly but we will need to configure extra stuff.
How to create credentials in firebase
Part 1:
- Go to firebase. Create a new account then click on add project.
- Give a name for your app then you can leave everything as default and click next.
- Go to the authentication tab in the sidebar. Click get started. Click on Google sign in and enable it. Now simply click on save.
- If you click on edit again and open the Web SDK configuration accordion. You can see the credentials we need. I am showing my credentials for the demo but you shouldn’t show your credentials.
- Now add the credentials to your
.env
file.
Part 2:
- Stop and start your dev server
npm run dev
- Click on "Sign in with Google" in the app
- You'll get an error screen. Now copy the link at which is at the bottom of the error and paste the link into a new tab. Scroll down and you will be able to see redirect URI’s.
- Now click on ADD URI and add this:
http://localhost:3000/api/auth/callback/google
- Then click on save. If you try logging in. You can now log in.