Skip to content

Commit

Permalink
Merge pull request #19 from sophearahsp/readme-setup
Browse files Browse the repository at this point in the history
Update setup README.md
  • Loading branch information
changesbyjames authored Nov 22, 2024
2 parents 2433a7d + da6c784 commit 0298f64
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
80 changes: 39 additions & 41 deletions census/README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,53 @@
# Getting started with developing

Prerequisites:
# Getting started

- Clone the repo
- Ensure you have `pnpm` installed
- Run `pnpm install` to install the dependencies
- Ensure you have `docker` installed and running on your machine
- You will need to copy the `src/services/api/.env.example` file to `src/services/api/.env` and supply the correct environment variables.
## Prerequisites

### Variables you will need to change
1. Clone the repository.
2. Ensure you have `pnpm` installed and run `pnpm install`.
3. Ensure you have `docker` installed and running on your machine.
4. Clone `./api/.env.example` and rename as `./api/.env` and configure it as follows.

- `TWITCH_CLIENT_ID`
- `TWITCH_CLIENT_SECRET`
### Twitch setup
1. Go to the [Twitch Developer Dashboard](https://dev.twitch.tv/console).
2. Create a new application and add the following as OAuth Redirect URLs.
- `http://localhost:35523/auth/redirect`
- `http://localhost:35523/admin/redirect`
3. Copy the generated Client ID and Client Secret
- Update the `./api/.env` file with `TWITCH_CLIENT_ID` and `TWITCH_CLIENT_SECRET`.

Go to the [Twitch Developer Dashboard](https://dev.twitch.tv/console) and create a new application to get your `TWITCH_CLIENT_ID` and `TWITCH_CLIENT_SECRET`. Ensure that you set the redirect URL to `http://localhost:35523/auth/redirect` & `http://localhost:35523/admin/redirect`.

- `STORAGE_ACCOUNT_NAME`
- `STORAGE_ACCOUNT_KEY`
- `CONTAINER_NAME`
### Azure setup

Currently, we don't support the Azurite emulator for local development, so you'll need to have an Azure storage account and container that you can use.

### Variables you could change

- `JWT_SECRET`
1. Go to the Azure Portal.
2. Create a storage account:
- Under Azure services, select Storage accounts and create a new storage account.
- Update the `./api/.env` file with `STORAGE_ACCOUNT_NAME`.
3. Obtain the access key:
- From your storage account's page, navigate to Security + networking > Access keys.
- Update the `./api/.env` file with `STORAGE_ACCOUNT_KEY` with either `key1` or `key2`.
4. Create a storage container:
- From your storage account's page, go to Data storage > Containers and create a new container.
- Update the `./api/.env` file with `CONTAINER_NAME`.
5. Enable public access for the container
- From your storage account's page, go to Configuration and set `Allow Blob anonymous access` to `Enabled`.
- From your container's page, select Change access level and set the `anonymous access level` as `Container` or `Blob`.

### `JWT_SECRET` setup

This is the secret that the API uses to sign the JWTs. For local development, you can stick to the default value but know that it makes the token insecure. If you want to generate a new secret, you can run `pnpm --filter=@alveusgg/census-api setup:jwt` to generate a new secret.

### Variables you probably should keep the same

- `UI_URL`
- `POSTGRES_USER`
- `POSTGRES_PASSWORD`
- `POSTGRES_DB`
- `POSTGRES_HOST`
- `HOST`
- `PORT`

These are all the default values that are used when the local docker compose file is ran. Unless you have a reason to change them, it's best to keep them the same.

### Running the services

In the root of the repo, run `docker compose up` to start the remaining services needed for the API to function.

- Edit the file found in `apps/ui/src/services/backstage/local.ts` and point the `apiBaseUrl` to the API URL you're running locally. (You can probably just uncomment the line.)

You can now make changes to both the UI and API and submit a PR for it!
## Running the services

- Run `pnpm --filter=@alveusgg/census-api start` to start the API (you can use `pnpm --filter=@alveusgg/census-api dev` to start the API in "watch" mode.)
- Run `pnpm --filter=@alveusgg/census-ui start` to start the UI
1. Start the database.
- In the root of the repo, run `docker compose up`.
2. Start the API.
- `pnpm --filter=@alveusgg/census-api start`.
- `pnpm --filter=@alveusgg/census-api dev` to start in watch mode.
3. Start the UI.
- `pnpm --filter=@alveusgg/census-ui start`.

### Seeding the database
## Seeding the database

You will need to seed the database with the correct data. To add yourself as an admin, run `pnpm --filter=@alveusgg/census-api setup:api` and follow the prompts.
You will need to seed the database with the correct data. To add yourself as an admin, run `pnpm --filter=@alveusgg/census-api setup:api` and follow the prompts.
6 changes: 4 additions & 2 deletions census/api/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TWITCH_CLIENT_ID=itag8f5m4r3ynbtrz933d7qh7c6ffq
TWITCH_CLIENT_SECRET=exs4bkvzrlvfq6m2n0gez519zzv4a2
TWITCH_CLIENT_ID=
TWITCH_CLIENT_SECRET=

HOST=localhost
PORT=35523
Expand All @@ -15,3 +15,5 @@ JWT_SECRET=bed840003446895cfee2372afad1c9adace070b0b54cdfdc640d61b521b5a5aeb3af9
STORAGE_ACCOUNT_NAME=
STORAGE_ACCOUNT_KEY=
CONTAINER_NAME=

NODE_ENV=development

0 comments on commit 0298f64

Please sign in to comment.