Skip to content

simbacity/superapp

Repository files navigation

Project setup

npm install
docker-compose up -d
You haven't installed docker and docker-compose on your system?

Here's an installation guide

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

Development workflow

Initial setup:

docker-compose up -d
npx prisma db push

Run:

npm run dev

Then visit http://localhost:3000.

Debug mode

Stop your current running dev server.

Add the debugger; keyword to your code:

image

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:

image

Run tests

npm run test

Optionally, you can add a name pattern of the file name:

npm run test User

Check test coverage:

  1. npm run test:coverage
  2. open file ./coverage/lcov-report/index.html

Database

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).

Here is a more detailed documentation on using Prisma with Planetscale: https://www.prisma.io/docs/guides/database/using-prisma-with-planetscale

Advanced (not required)

Setup firebase Authentication

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:

  1. Go to firebase. Create a new account then click on add project.
  2. Give a name for your app then you can leave everything as default and click next.
  3. Go to the authentication tab in the sidebar. Click get started. Click on Google sign in and enable it. Now simply click on save.
  4. 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.
  5. Now add the credentials to your .env file.
  • image

Part 2:

  1. Stop and start your dev server npm run dev
  2. Click on "Sign in with Google" in the app
  3. 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.
  • image
  1. Now click on ADD URI and add this: http://localhost:3000/api/auth/callback/google
  • image
  1. Then click on save. If you try logging in. You can now log in.