Skip to content

Commit

Permalink
chore (website): document generator proxy option (#635)
Browse files Browse the repository at this point in the history
This PR uses localhost instead of 127.0.0.1 as the default address for Electric and documents the `--proxy` option of the CLI's generate command.
  • Loading branch information
kevin-dp authored Nov 8, 2023
1 parent ec1c5cb commit 1016d4b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/friendly-oranges-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"electric-sql": patch
---

Use localhost instead of 127.0.0.1 as default address for Electric.
Update documentation of command-line options for the CLI's generate command.
2 changes: 1 addition & 1 deletion clients/typescript/src/cli/migrations/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type GeneratorArgs = Partial<GeneratorOptions>
* Optional argument providing the url to connect to the PG database via the proxy.
* If not provided, it uses the url set in the `PG_PROXY_URL` environment variable.
* If that variable is not set, it resorts to the default url which is
* 'postgresql://prisma:password@localhost:65432/electric'.
* 'postgresql://prisma:proxy_password@localhost:65432/electric'.
* NOTE: the generator introspects the PG database via the proxy,
* the URL must therefore connect using the "prisma" user.
* - `--out <path>`
Expand Down
2 changes: 1 addition & 1 deletion clients/typescript/src/cli/migrations/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { dedent } from 'ts-dedent'
const appRoot = path.resolve() // path where the user ran `npx electric migrate`

export const defaultOptions = {
service: process.env.ELECTRIC_URL ?? 'http://127.0.0.1:5133',
service: process.env.ELECTRIC_URL ?? 'http://localhost:5133',
proxy:
process.env.ELECTRIC_PROXY_URL ??
'postgresql://prisma:proxy_password@localhost:65432/electric', // use "prisma" user because we will introspect the DB via the proxy
Expand Down
3 changes: 2 additions & 1 deletion docs/api/generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ Note that you can use an optional `--watch` flag to automatically re-generate th
The generate script accepts a number of arguments:

```shell
npx electric-sql generate [--service <url>] [--out <path>] [--watch [<pollingInterval>]]
npx electric-sql generate [--service <url>] [--proxy <url>] [--out <path>] [--watch [<pollingInterval>]]
```
All arguments are optional and are described below:
| Argument | value | description |
|----------|-------|-------------|
| <span className="no-wrap">`--service`</span> | `<url>` | Provides the url to connect to the Electric sync service. If not provided, it uses the url set in the `ELECTRIC_URL` environment variable. If that variable is not set, it resorts to the default url which is `http://localhost:5133`. |
| <span className="no-wrap">`--proxy`</span> | `<url>` | Provides the url to connect to Electric's database proxy. If not provided, it uses the url set in the `PG_PROXY_URL` environment variable. If that variable is not set, it resorts to the default url which is `postgresql://prisma:proxy_password@localhost:65432/electric`. |
| <span className="no-wrap">`--out`</span> | `<path>` | Specifies where to output the generated client. Defaults to `./src/generated/client` |
| <span className="no-wrap">`--watch`</span> | `<pollingInterval>` | Run the generator in watch mode. Accepts an optional polling interval (in milliseconds) which defines how often to poll Electric for database migrations. The default polling interval is 1000ms. |
Expand Down

0 comments on commit 1016d4b

Please sign in to comment.