Skip to content

Commit 72f692c

Browse files
committed
chore: fixup neon
1 parent f52dcc3 commit 72f692c

File tree

7 files changed

+20
-12
lines changed

7 files changed

+20
-12
lines changed

frameworks/react-cra/add-ons/mcp/assets/src/mcp-todos.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,9 @@ export function subscribeToTodos(callback: (todos: Todo[]) => void) {
4343

4444
// Notify all subscribers of a user's cart
4545
function notifySubscribers() {
46-
subscribers.forEach((cb) => cb(todos))
46+
for (const cb of subscribers) {
47+
try {
48+
cb(todos)
49+
} catch {}
50+
}
4751
}

frameworks/react-cra/add-ons/mcp/assets/src/routes/api.mcp-todos.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ export const Route = createFileRoute('/api/mcp-todos')({
88
GET: () => {
99
const stream = new ReadableStream({
1010
start(controller) {
11-
setInterval(() => {
12-
controller.enqueue(`event: ping\n\n`)
13-
}, 1000)
11+
function ping() {
12+
try {
13+
controller.enqueue(`event: ping\n\n`)
14+
setTimeout(ping, 1000)
15+
} catch {}
16+
}
17+
ping()
1418
const unsubscribe = subscribeToTodos((todos) => {
1519
controller.enqueue(`data: ${JSON.stringify(todos)}\n\n`)
1620
})

frameworks/react-cra/add-ons/mcp/assets/src/utils/mcp-handler.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export async function handleMcpRequest(
3131
await clientTransport.close()
3232
await serverTransport.close()
3333

34-
console.log('responseData', JSON.stringify(responseData, null, 2))
35-
3634
return Response.json(responseData, {
3735
headers: {
3836
'Content-Type': 'application/json',
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# These will be automatically created by Neon Launchpad (https://neon.new).
2-
DATABASE_URL=
3-
DATABASE_URL_POOLER=
2+
# You will also need to
3+
VITE_DATABASE_URL=
4+
VITE_DATABASE_URL_POOLER=

frameworks/react-cra/add-ons/neon/assets/src/db.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { neon } from '@neondatabase/serverless'
33
let client: ReturnType<typeof neon>
44

55
export async function getClient() {
6-
if (!process.env.DATABASE_URL) {
6+
if (!process.env.VITE_DATABASE_URL) {
77
return undefined
88
}
99
if (!client) {
10-
client = await neon(process.env.DATABASE_URL!)
10+
client = await neon(process.env.VITE_DATABASE_URL!)
1111
}
1212
return client
1313
}

frameworks/react-cra/add-ons/start/assets/vite.config.ts.ejs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const config = defineConfig({
1616
type: "sql-script",
1717
path: "db/init.sql"
1818
},
19-
referrer: 'create-tanstack'
19+
referrer: 'create-tanstack',
20+
dotEnvKey: 'VITE_DATABASE_URL',
2021
}),
2122
<% } %>
2223
// this is the plugin that enables path aliases

packages/cta-engine/src/create-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Use the following commands to start your app:
234234
getPackageManagerScriptCommand(options.packageManager, ['dev']),
235235
)}
236236
237-
Please check the README.md for information on testing, styling, adding routes, etc.${errorStatement}`,
237+
Please read the README.md for information on testing, styling, adding routes, etc.${errorStatement}`,
238238
)
239239
}
240240

0 commit comments

Comments
 (0)