diff --git a/.changeset/friendly-oranges-fold.md b/.changeset/friendly-oranges-fold.md new file mode 100644 index 0000000000..846f1de922 --- /dev/null +++ b/.changeset/friendly-oranges-fold.md @@ -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. diff --git a/clients/typescript/src/cli/migrations/handler.ts b/clients/typescript/src/cli/migrations/handler.ts index 8890f1f786..bca0f59f95 100644 --- a/clients/typescript/src/cli/migrations/handler.ts +++ b/clients/typescript/src/cli/migrations/handler.ts @@ -15,7 +15,7 @@ type GeneratorArgs = Partial * 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 ` diff --git a/clients/typescript/src/cli/migrations/migrate.ts b/clients/typescript/src/cli/migrations/migrate.ts index 811765706b..c7ed1d3351 100644 --- a/clients/typescript/src/cli/migrations/migrate.ts +++ b/clients/typescript/src/cli/migrations/migrate.ts @@ -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 diff --git a/docs/api/generator.md b/docs/api/generator.md index 495fbf4d59..ee1f4b92c3 100644 --- a/docs/api/generator.md +++ b/docs/api/generator.md @@ -22,7 +22,7 @@ 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 ] [--out ] [--watch []] +npx electric-sql generate [--service ] [--proxy ] [--out ] [--watch []] ``` All arguments are optional and are described below: @@ -30,6 +30,7 @@ All arguments are optional and are described below: | Argument | value | description | |----------|-------|-------------| | `--service` | `` | 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`. | +| `--proxy` | `` | 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`. | | `--out` | `` | Specifies where to output the generated client. Defaults to `./src/generated/client` | | `--watch` | `` | 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. |