|
| 1 | +# Website Development |
| 2 | + |
| 3 | +To get started with development of the website, you can follow these steps: |
| 4 | + |
| 5 | +1. Initialize the DB |
| 6 | + |
| 7 | +If you haven't already, you can initialize the database with the following command: |
| 8 | + |
| 9 | +```bash |
| 10 | +cd docs && pnpm run init-db |
| 11 | +``` |
| 12 | + |
| 13 | +This will initialize an SQLite database at `./docs/sqlite.db`. |
| 14 | + |
| 15 | +2. Setup environment variables |
| 16 | + |
| 17 | +Copy the `.env.example` file to `.env.local` and set the environment variables. |
| 18 | + |
| 19 | +```bash |
| 20 | +cp .env.example .env.local |
| 21 | +``` |
| 22 | + |
| 23 | +If you want to test logging in, or payments see more information below [in the environment variables section](#environment-variables). |
| 24 | + |
| 25 | +3. Start the development server |
| 26 | + |
| 27 | +```bash |
| 28 | +cd docs && pnpm run dev |
| 29 | +``` |
| 30 | + |
| 31 | +This will start the development server on port 3000. |
| 32 | + |
| 33 | +## Environment Variables |
| 34 | + |
| 35 | +### Logging in |
| 36 | + |
| 37 | +To test logging in, you can set the following environment variables: |
| 38 | + |
| 39 | +```bash |
| 40 | +AUTH_SECRET=test |
| 41 | +# Github OAuth optionally |
| 42 | +AUTH_GITHUB_ID=test |
| 43 | +AUTH_GITHUB_SECRET=test |
| 44 | +``` |
| 45 | + |
| 46 | +Note: the GITHUB_ID and GITHUB_SECRET are optional, but if you want to test logging in with Github you'll need to set them. For local development, you'll need to set the callback URL to `http://localhost:3000/api/auth/callback/github` |
| 47 | + |
| 48 | +### Payments |
| 49 | + |
| 50 | +To test payments, you can set the following environment variables: |
| 51 | + |
| 52 | +```bash |
| 53 | +POLAR_ACCESS_TOKEN=test |
| 54 | +POLAR_WEBHOOK_SECRET=test |
| 55 | +``` |
| 56 | + |
| 57 | +For testing payments, you'll need access to the polar sandbox which needs to be configured to point a webhook to your local server. This can be configured at: <https://sandbox.polar.sh/dashboard/blocknote/settings/webhooks> |
| 58 | + |
| 59 | +You'll need something like [ngrok](https://ngrok.com/) to expose your local server to the internet. |
| 60 | + |
| 61 | +```bash |
| 62 | +ngrok http http://localhost:3000 |
| 63 | +``` |
| 64 | + |
| 65 | +You'll need the webhook to point to ngrok like so: |
| 66 | + |
| 67 | +``` |
| 68 | +https://0000-00-00-000-00.ngrok-free.app/api/auth/polar/webhooks |
| 69 | +``` |
| 70 | + |
| 71 | +With this webhook pointing to your local server, you should be able to test payments. |
| 72 | + |
| 73 | +### Email sending |
| 74 | + |
| 75 | +Note, this is not required, if email sending is not configured, the app will log the email it would send to the console. Often this is more convenient for development. |
| 76 | + |
| 77 | +To test email sending, you can set the following environment variables: |
| 78 | + |
| 79 | +```bash |
| 80 | +SMTP_HOST= |
| 81 | +SMTP_USER= |
| 82 | +SMTP_PASS= |
| 83 | +SMTP_PORT= |
| 84 | +SMTP_SECURE=false |
| 85 | +``` |
| 86 | + |
| 87 | +When configured, you'll be able to send emails to the email address you've configured. |
| 88 | + |
| 89 | +To setup with protonmail, you'll need to go to <https://account.proton.me/u/0/mail/imap-smtp> and create a new SMTP submission token. |
| 90 | + |
| 91 | +You'll need to set the following environment variables: |
| 92 | + |
| 93 | +```bash |
| 94 | +SMTP_HOST=smtp.protonmail.com |
| 95 | +SMTP_USER=my.email@protonmail.com |
| 96 | +SMTP_PASS=my-smtp-token |
| 97 | +SMTP_PORT=587 |
| 98 | +SMTP_SECURE=false |
| 99 | +``` |
0 commit comments