/superapp

Simba is a city like Florence, Vienna, or San Francisco but built via the internet.

Primary LanguageTypeScriptMIT LicenseMIT

Simba City

Project setup

Duplicate env.example and .env.test.example and rename to .env and .env.test

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

Database

run 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

Run tests

yarn test

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

yarn test User

Check test coverage:

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