API for Vetting Games.
Check out the API on Staging: https://vetting-games-api-staging.x-team.com/graphql
- Node.js (v18.12.0)
- NVM - Node Version Manager (optional)
- Docker
- Yarn
- Postgres DB
You'll need some environment variables to get started. You can find a list of them in the .env.example
file. You can copy this file to .env
and fill in the values.
You can get a local instance of Postgres running using Docker. The docker-compose file is configured run a Postgres instance on port 5432
with the following credentials:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
You should ask for the Github OAuth credentials from the team.
GITHUB_CLIENT_ID="[your_oauth_app_client_id]"
GITHUB_CLIENT_SECRET="[your_oauth_app_client_secret]"
You can set the CORS origin to allow requests from a specific domain.
CORS_ORIGIN="http://localhost:5173"
Generate a JWT secret key using the following command:
openssl rand -hex 32
JWT_SECRET="****"
JWT_EXPIRATION="7d"
yarn install
To start the development server, run the following command:
yarn db:up
yarn db:generate
yarn dev
This will start a development server at http://localhost:4000/.
You can also start the server using docker compose
:
yarn compose
To create a new migration or run migrations, run the following commands:
yarn db:migrate-dev
This will start a development server at http://localhost:4000/.
To deploy the Prisma schema to the production database, run the following command:
yarn db:deploy
prisma
- Prisma schema and migrations. Make DB changes here.src
- Source code for the API.db
- Database data for seeding.error
- Custom error classes.modules
- API modules. Structure the API by grouping related functionality into modules. e.g.auth
,user
,game
, etc.context.ts
- Context for the GraphQL server.gql.ts
- Generated GraphQL types and resolvers by GraphQL Code Generator.index.ts
- Entry point for the API.prisma.ts
- Prisma client.seed.ts
- Seed the database with data fromdb
.
schema.json
- JSON schema for the GraphQL API.
- Use Prettier to format the code.
- Use ESLint to lint the code.
- Use TypeScript for type safety.
- Use GraphQL Code Generator to generate the GraphQL types and resolvers.
- Use Prisma to generate the database schema and run migrations.
- Make sure you have a Jira ticket for the work you're doing.
- Create a branch with the ticket number and a short description of the work you're doing. e.g.
VG-123-fix-game-bug
- Make sure your branch is up to date with
develop
before you start working on it. - Open a pull request against
develop
and move the ticket to "In Review" in Jira. - Fill out the pull request template with as much detail as possible.
- Request a code review from the team at
#vetting-games-project
. - Once the code review is complete, merge the pull request and move the ticket to "Staging" in Jira.
- After the pull request is merged, the staging server will automatically deploy the changes.
- Once the changes are deployed to staging, make sure to run the migrations on the staging database.
- Test the changes on staging and make sure everything is working as expected.
- Make sure the code is up to date with
develop
before you start reviewing. - Review the branch name and pull request title to make sure they are descriptive.
- Check the pull request description to make sure it contains all the necessary information.
- Change to the branch and run the code locally.
- Run the migrations on the local database.
- Test the changes locally and make sure everything is working as expected.
- Make sure the code is readable and easy to understand expect for the generated code.
- Add comments to the pull request if you have any questions, suggestions or if you find any issues.
- Approve the pull request if everything looks good.
Ignore the generated code when reviewing the pull request. The generated code is generated using GraphQL Code Generator and Prisma. You can find the configuration files for these tools in the codegen.yml
and prisma/schema.prisma
files.
Files:
prisma/schema.prisma
prisma/migrations/*
src/gql.ts
schema.json
Our database is seeded with data using a script. You can find the script in src/seed.ts
. To run the script, run the following command:
yarn db:seed
If you want to update the seed data, you can do so by updating the files in the src/db
directory.