Skip to content

Commit

Permalink
Use hardcoded connection string fallback rather than .env file (#348)
Browse files Browse the repository at this point in the history
Seems like npm filters out `.env` files when publishing. It's probably a
good thing on the whole, but we actually want them included for
`create-y-sweet-app` because we copy them over when bootstrapping a new
project.

Rather than try to work around the issue, I just removed the `.env`
files and set up the document managers like this:

```js
const manager = new DocumentManager(
  process.env.CONNECTION_STRING || "ys://127.0.0.1:8080",
);
```

As a plus, it's a little more explicit what's happening in the code.
  • Loading branch information
jakelazaroff authored Dec 2, 2024
1 parent 6b9b9d4 commit 5a1538a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion js-pkg/create-y-sweet-app/src/frameworks/nextjs/.env.local

This file was deleted.

4 changes: 3 additions & 1 deletion js-pkg/create-y-sweet-app/src/frameworks/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { YDocProvider } from "@y-sweet/react";

import { App } from "@/components/App";

const manager = new DocumentManager(process.env.CONNECTION_STRING!);
const manager = new DocumentManager(
process.env.CONNECTION_STRING || "ys://127.0.0.1:8080",
);

export default async function Home() {
const docId = "my-doc-id";
Expand Down
1 change: 0 additions & 1 deletion js-pkg/create-y-sweet-app/src/frameworks/remix/.env.local

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { DocumentManager } from "@y-sweet/sdk";

export const manager = new DocumentManager(process.env.CONNECTION_STRING!);
export const manager = new DocumentManager(
process.env.CONNECTION_STRING || "ys://127.0.0.1:8080",
);

0 comments on commit 5a1538a

Please sign in to comment.