Fix various TS templates (#4360)

# 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
This commit is contained in:
bradleyshep
2026-02-20 10:05:45 -05:00
committed by GitHub
parent e2f8a60759
commit cea601ffa4
7 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ async function main(): Promise<void> {
// Build and establish connection
DbConnection.builder()
.withUri(HOST)
.withModuleName(DB_NAME)
.withDatabaseName(DB_NAME)
.withToken(token)
.onConnect(onConnect)
.onDisconnect(onDisconnect)
@@ -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');
@@ -21,7 +21,7 @@ export async function fetchPeople(): Promise<PersonData[]> {
const connection = DbConnection.builder()
.withUri(HOST)
.withModuleName(DB_NAME)
.withDatabaseName(DB_NAME)
.onConnect(conn => {
// Subscribe to all people
conn
+1 -1
View File
@@ -22,7 +22,7 @@ async function main(): Promise<void> {
// Build and establish connection
DbConnection.builder()
.withUri(HOST)
.withModuleName(DB_NAME)
.withDatabaseName(DB_NAME)
.withToken(loadToken())
.onConnect(onConnect)
.onDisconnect(onDisconnect)
+1
View File
@@ -1,5 +1,6 @@
export default defineNuxtConfig({
compatibilityDate: '2025-01-01',
telemetry: false,
devServer: {
port: 5173,
},
+1 -1
View File
@@ -14,7 +14,7 @@ export default defineEventHandler(async (): Promise<PersonData[]> => {
DbConnection.builder()
.withUri(HOST)
.withModuleName(DB_NAME)
.withDatabaseName(DB_NAME)
.onConnect(conn => {
conn
.subscriptionBuilder()
@@ -21,7 +21,7 @@ export async function fetchPeople(): Promise<PersonData[]> {
const connection = DbConnection.builder()
.withUri(HOST)
.withModuleName(DB_NAME)
.withDatabaseName(DB_NAME)
.onConnect(conn => {
// Subscribe to all people
conn