Skip to content

Commit cd7fcb4

Browse files
committed
chore(env): clean up env vars and document setup
1 parent 2c257f0 commit cd7fcb4

File tree

5 files changed

+58
-18
lines changed

5 files changed

+58
-18
lines changed

.env.template

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1+
## SERVICE
2+
INDEXER_ENVIRONMENT=test
13
PORT=4000
2-
KEY=
3-
PROOF=
44

5-
SUPABASE_CACHING_DB_URL=
6-
SUPABASE_CACHING_ANON_API_KEY=
5+
### W3UP - https://github.com/storacha/w3up/tree/main/packages/w3up-client#bringing-your-own-agent-and-delegation
6+
KEY=""
7+
PROOF=""
78

8-
SUPABASE_DATA_DB_URL=
9-
SUPABASE_DATA_ANON_API_KEY=
10-
SUPABASE_DATA_SERVICE_API_KEY=
9+
### SUPABASE JS - https://www.npmjs.com/package/@supabase/supabase-js
1110

12-
SENTRY_DSN=
11+
SUPABASE_CACHING_DB_URL="http://127.0.0.1:54321"
12+
SUPABASE_CACHING_ANON_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
1313

14-
INDEXER_ENVIRONMENT=test
14+
SUPABASE_DATA_DB_URL="http://127.0.0.1:64321"
15+
SUPABASE_DATA_ANON_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
16+
SUPABASE_DATA_SERVICE_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
17+
18+
### KYSELY
19+
20+
CACHING_DATABASE_URL=postgresql://postgres:[email protected]:54322/postgres
21+
DATA_DATABASE_URL=postgresql://postgres:[email protected]:64322/postgres
22+
23+
### SENTRY
24+
SENTRY_ENVIRONMENT=local # local | staging | production
25+
SENTRY_DSN="" #disabled for local
26+
SENTRY_AUTH_TOKEN="" #disabled for local
27+
28+
### RPCs - we implement a fallback to the first available RPC
29+
30+
# https://www.alchemy.com/
31+
ALCHEMY_API_KEY=""
32+
33+
# https://www.infura.io/
34+
INFURA_API_KEY=""
35+
36+
# https://drpc.org/
37+
DRPC_API_KEY=""

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,26 @@ The hypercerts API is the touchpoint for developers to interact with the hyperce
66

77
### Environment variables
88

9+
#### W3UP
10+
911
In `env.template` you'll find KEY and PROOF which are [w3up](https://web3.storage/docs/w3up-client/) key and proofs which you need to set up yourself for local otherwise you'll be superadmin 😉
1012

13+
#### Supabase JS
14+
15+
SupabaseJS is used to connect to both the the caching and data service. The local variables are deterministic and provided in the template.
16+
17+
#### Kysely
18+
19+
Kysely is implemented in favor of SupabaseJS as it allows for more flexibility and complexity in queries. To connect to the database you need to set the `CACHING_DATABASE_URL` and `DATA_DATABASE_URL` in the `.env` file. By default, the local variables are set to the local Supabase instance.
20+
21+
#### Sentry
22+
23+
Sentry is used for monitoring and error reporting. You can read more about it [here](https://docs.sentry.io/platforms/javascript/guides/node/configuration/env-vars/). When Sentry is set to `local` it will be disabled by default.
24+
25+
#### RPCs
26+
27+
The API implements a fallback to the first available RPC. You can set the RPCs in the `.env` file.
28+
1129
### Supabase
1230

1331
* Install Docker
@@ -17,15 +35,15 @@ In `env.template` you'll find KEY and PROOF which are [w3up](https://web3.storag
1735

1836
This will spin up 2 Supabase instances in Docker, one for the indexer service (caching) and one for the data service (static data) which are both exposed by the API.
1937

20-
From both instances, you need to get their respective keys and add them to the env vars. When in doubt you can run `supabase status` to fetch the keys again.
38+
From both instances, you can get their respective keys and add them to the env vars. When in doubt you can run `supabase status` to fetch the keys again. By default this is not needed for local development.
2139

2240
### Run the API locally
2341

2442
`pnpm dev`
2543

26-
This will run a live production instance (I'm proud that it's production) by running swc
44+
This will run a live production instance by running `swc` to compile the code and `nodemon` to restart the server on changes.
2745

28-
You can then find the API at localhost:4000/spec (Swagger instance) and the Graph at localhost:4000/v1/graphql
46+
You can then find the API at `localhost:4000/spec` (Swagger instance) and the GraphQL at `localhost:4000/v1/graphql`
2947

3048
## Deployments
3149

src/__generated__/routes/routes.ts

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__generated__/swagger.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/instrument.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import * as Sentry from '@sentry/node';
22
import {assertExists} from "./utils/assertExists.js";
33
import { nodeProfilingIntegration } from "@sentry/profiling-node";
44

5-
const SENTRY_DSN = assertExists(process.env.SENTRY_DSN, "SENTRY_DSN");
65
// Ensure to call this before importing any other modules!
76
Sentry.init({
8-
dsn: SENTRY_DSN,
7+
dsn: process.env.SENTRY_DSN,
98
integrations: [
109
nodeProfilingIntegration(),
1110
],

0 commit comments

Comments
 (0)