Skip to content

Commit

Permalink
chore: single top level dev .env file and quicker quickstart (#1021)
Browse files Browse the repository at this point in the history
Use a single top level .env flle to set all dev env vars. With this PR getting started with the api and website is just

- create a magic.link account
- copy .env.tpl to .env in the monorepo root and fill out the magic link keys
- npm i
- npm start

and you'll be off to the races with the api and website 🏇 💨 ✨ 

This PR includes:

- create a new .env.tpl template that aggregates all the module env needs.
- add top level `npm start` task to run the api and the website, for a quicker quickstart.
- remove old FAUNA logic from pinpin so we don't have to set the DATABASE var any more.
- Updated README's

TODO: 
- [x] warn people that they need to copy the env template and fill out their magic link keys, and maybe copy their SALT over.
- [x] fix it so that the api start command does't fail if you are already running the cluster and db containers.

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans <[email protected]>
  • Loading branch information
olizilla authored Feb 28, 2022
1 parent 8c0ca4b commit e537f26
Show file tree
Hide file tree
Showing 25 changed files with 670 additions and 8,102 deletions.
56 changes: 56 additions & 0 deletions .env.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# web3.storage DEV environment variables

# Copy me to `.env` and fill out the missing values.
# This file is only for DEV. In prod, set the env vars a process needs as secrets.
ENV=dev


## ---- api -------------------------------------------------------------------

# Create a https://magic.link account and set secret keys here. Set NEXT_PUBLIC_MAGIC with the publi key.
MAGIC_SECRET_KEY=

# Open https://csprng.xyz/v1/api and use the value of `Data`, or just use this one. it's for dev, it's ok.
SALT="Q6d8sTZa+wpIPrppPq6VdIKEbknjrsSCQklh/hVU4U0="

# base64 test:test - the creds for the local cluster test container
CLUSTER_BASIC_AUTH_TOKEN="dGVzdDp0ZXN0"
CLUSTER_API_URL=http://127.0.0.1:9094

# PostgREST API token, for role "postgres", using secret value PGRST_JWT_SECRET from './postgres/docker/docker-compose.yml' see: https://postgrest.org/en/v8.0/tutorials/tut1.html#step-3-sign-a-token
PG_REST_JWT="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoicG9zdGdyZXMifQ.oM0SXF31Vs1nfwCaDxjlczE237KcNKhTpKEYxMX-jEU"
PG_REST_URL=http://127.0.0.1:3000
# FOR TESTS ONLY: DB connection string for locally running postgres
PG_CONNECTION=postgres://postgres:[email protected]:5432/postgres

# IPFS Gateaway URL pointing to dockerised ipfs instance
GATEWAY_URL=http://localhost:8080

## ---- website ---------------------------------------------------------------

# vars to expose to the public website build have to be prefixed with NEXT_PUBLIC_
# see: https://nextjs.org/docs/basic-features/environment-variables#exposing-environment-variables-to-the-browser

NEXT_PUBLIC_MAGIC=
NEXT_PUBLIC_API=http://127.0.0.1:8787
NEXT_PUBLIC_ENV=dev

# set me to test Countly analytics integration.
# NEXT_PUBLIC_COUNTLY_KEY=
# NEXT_PUBLIC_COUNTLY_URL=


## ---- cron ------------------------------------------------------------------

# TODO: these are a duplicate of the api vars. Fix cron jobs so we can reuse the api vars.
DEV_PG_REST_JWT="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoicG9zdGdyZXMifQ.oM0SXF31Vs1nfwCaDxjlczE237KcNKhTpKEYxMX-jEU"
DEV_PG_REST_URL=http://127.0.0.1:3000
DEV_PG_CONNECTION=postgres://postgres:[email protected]:5432/postgres

CLUSTER_IPFS_PROXY_API_URL=http://127.0.0.1:9095/api/v0/


## ---- pinpin ----------------------------------------------------------------

# set me to test repinning our pins on pinata
PINATA_JWT="<your jwt here>"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env
.env.local
.env.development.local
.env.test.local
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@

This project uses node v16 and npm v7. It's a monorepo that use [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) to handle resolving dependencies between the local `packages/*` folders.

You need an account on https://magic.link, and Docker running locally.

Copy the <.env.tpl> file to `.env` and set the values for the `MAGIC_SECRET_KEY` & `NEXT_PUBLIC_MAGIC`, from your magic.link account dashboard.

Then install the deps with `npm` and then run all the things with `npm start`

```console
# install deps
npm install

# start the api and website
npm start
```

To add a new workspace to the repo:
Expand Down
Loading

0 comments on commit e537f26

Please sign in to comment.