Setting up your dev environment - 0Calories/untitled-block-game-api GitHub Wiki

In order to run this project locally, you will have

How to setup a local Postgres database

  1. Create a new database using pgAdmin or the command line
  2. Navigate to the prisma directory in the project
  3. Create a new file and name it .env
  4. Add the environment variable for the database URL, replacing the username and password with your credentials, and db with the name of your database: DATABASE_URL=postgresql://janedoe:mypassword@localhost:5432/mydb
  5. Run npx prisma migrate dev --preview-feature
  6. Generate a new Prisma client by running npx prisma generate

Running the API locally

At this point, you should have a local database ready to go. You can test out the API by doing the following:

  1. Create a new config directory in the project, and create three new files inside of it: dev.env, prod.env, and test.env.
  2. In each file, add an environment variable called JWT_SECRET.
  3. Assign the secret a value for the dev and test files, you can use a password generator to make them. Ensure that they are different values for each file. You can get the secrets for the prod file by asking a lead developer.
  4. Run yarn dev. When the console tells you the server is up, go to http://localhost:4000/ to view the GraphQL playground