From cea601ffa4cc3757dde263c3de5065e8ffbcc969 Mon Sep 17 00:00:00 2001 From: bradleyshep <148254416+bradleyshep@users.noreply.github.com> Date: Fri, 20 Feb 2026 10:05:45 -0500 Subject: [PATCH] Fix various TS templates (#4360) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description of Changes Fix `withModuleName` -> `withDatabaseName` in server-side code across multiple TypeScript templates. The 2.0 SDK renamed this method, but several templates still used the old 1.x API name, causing a runtime error (`DbConnection.builder(...).withUri(...).withModuleName is not a function`). **Files changed:** - `templates/nuxt-ts/server/api/people.get.ts` - `templates/remix-ts/app/lib/spacetimedb.server.ts` - `templates/nextjs-ts/lib/spacetimedb-server.ts` - `templates/nodejs-ts/src/main.ts` - `templates/deno-ts/src/main.ts` - `templates/keynote-2/src/connectors/spacetimedb.ts` # API and ABI breaking changes None. This aligns templates with the existing 2.0 SDK API. # Expected complexity level and risk 1 — Trivial string replacement across template files. No logic changes. # Testing - [ ] Run `spacetime dev --template nuxt-ts` and verify the Nuxt SSR server API (`/api/people`) connects without `withModuleName is not a function` error - [ ] Run `spacetime dev --template nextjs-ts` and verify the server-side SpacetimeDB connection works - [ ] Run `spacetime dev --template remix-ts` and verify the server-side SpacetimeDB connection works --- templates/deno-ts/src/main.ts | 2 +- templates/keynote-2/src/connectors/spacetimedb.ts | 2 +- templates/nextjs-ts/lib/spacetimedb-server.ts | 2 +- templates/nodejs-ts/src/main.ts | 2 +- templates/nuxt-ts/nuxt.config.ts | 1 + templates/nuxt-ts/server/api/people.get.ts | 2 +- templates/remix-ts/app/lib/spacetimedb.server.ts | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/templates/deno-ts/src/main.ts b/templates/deno-ts/src/main.ts index 4a39c74df..8af4bf3d3 100644 --- a/templates/deno-ts/src/main.ts +++ b/templates/deno-ts/src/main.ts @@ -20,7 +20,7 @@ async function main(): Promise { // Build and establish connection DbConnection.builder() .withUri(HOST) - .withModuleName(DB_NAME) + .withDatabaseName(DB_NAME) .withToken(token) .onConnect(onConnect) .onDisconnect(onDisconnect) diff --git a/templates/keynote-2/src/connectors/spacetimedb.ts b/templates/keynote-2/src/connectors/spacetimedb.ts index 83bbd2eec..8c6c397aa 100644 --- a/templates/keynote-2/src/connectors/spacetimedb.ts +++ b/templates/keynote-2/src/connectors/spacetimedb.ts @@ -43,7 +43,7 @@ export function spacetimedb( const builder = Db.builder() .withUri(url) - .withModuleName(moduleName) + .withDatabaseName(moduleName) .withConfirmedReads(process.env.STDB_CONFIRMED_READS === '1') .onConnect((ctx) => { console.log('[stdb] connected'); diff --git a/templates/nextjs-ts/lib/spacetimedb-server.ts b/templates/nextjs-ts/lib/spacetimedb-server.ts index 8d0d0d544..28581be0f 100644 --- a/templates/nextjs-ts/lib/spacetimedb-server.ts +++ b/templates/nextjs-ts/lib/spacetimedb-server.ts @@ -21,7 +21,7 @@ export async function fetchPeople(): Promise { const connection = DbConnection.builder() .withUri(HOST) - .withModuleName(DB_NAME) + .withDatabaseName(DB_NAME) .onConnect(conn => { // Subscribe to all people conn diff --git a/templates/nodejs-ts/src/main.ts b/templates/nodejs-ts/src/main.ts index 89f04e492..02633fd2c 100644 --- a/templates/nodejs-ts/src/main.ts +++ b/templates/nodejs-ts/src/main.ts @@ -22,7 +22,7 @@ async function main(): Promise { // Build and establish connection DbConnection.builder() .withUri(HOST) - .withModuleName(DB_NAME) + .withDatabaseName(DB_NAME) .withToken(loadToken()) .onConnect(onConnect) .onDisconnect(onDisconnect) diff --git a/templates/nuxt-ts/nuxt.config.ts b/templates/nuxt-ts/nuxt.config.ts index d9a01aa97..e3b0dd601 100644 --- a/templates/nuxt-ts/nuxt.config.ts +++ b/templates/nuxt-ts/nuxt.config.ts @@ -1,5 +1,6 @@ export default defineNuxtConfig({ compatibilityDate: '2025-01-01', + telemetry: false, devServer: { port: 5173, }, diff --git a/templates/nuxt-ts/server/api/people.get.ts b/templates/nuxt-ts/server/api/people.get.ts index 24a98b533..39c924513 100644 --- a/templates/nuxt-ts/server/api/people.get.ts +++ b/templates/nuxt-ts/server/api/people.get.ts @@ -14,7 +14,7 @@ export default defineEventHandler(async (): Promise => { DbConnection.builder() .withUri(HOST) - .withModuleName(DB_NAME) + .withDatabaseName(DB_NAME) .onConnect(conn => { conn .subscriptionBuilder() diff --git a/templates/remix-ts/app/lib/spacetimedb.server.ts b/templates/remix-ts/app/lib/spacetimedb.server.ts index 16dd6db55..47945b4b2 100644 --- a/templates/remix-ts/app/lib/spacetimedb.server.ts +++ b/templates/remix-ts/app/lib/spacetimedb.server.ts @@ -21,7 +21,7 @@ export async function fetchPeople(): Promise { const connection = DbConnection.builder() .withUri(HOST) - .withModuleName(DB_NAME) + .withDatabaseName(DB_NAME) .onConnect(conn => { // Subscribe to all people conn