Two related fixes:
1. Phone (and any LAN client) couldn't reach the web container because
the dev compose mapped 127.0.0.1:WEB_PORT instead of binding all
interfaces. Drop the loopback prefix.
2. Turbopack and NodeNext disagree on extension handling: bot's tsc
needs `.js` extensions in source imports; Turbopack's transpilePackages
path can't resolve those `.js` requests back to `.ts` source. Switch
to consuming the workspace packages via their compiled dist instead:
- packages/db + packages/shared point `main`/`exports` at ./dist/*
- drop transpilePackages from next.config.ts; web picks up the
compiled `.js` files directly
- dev compose command for web builds shared+db before running
`next dev` so dist is fresh when Turbopack starts
- put the `.js` extensions back in packages/db source so NodeNext
compilers (bot's tsc, packages/db's own tsc) are happy
30 lines
807 B
TypeScript
30 lines
807 B
TypeScript
import { createClient, operators } from "./index.js";
|
|
|
|
const databaseUrl = process.env.DATABASE_URL;
|
|
const operatorTelegramId = process.env.SEED_OPERATOR_TELEGRAM_ID;
|
|
const operatorName = process.env.SEED_OPERATOR_NAME ?? "Operator";
|
|
|
|
if (!databaseUrl) {
|
|
console.error("DATABASE_URL not set");
|
|
process.exit(1);
|
|
}
|
|
if (!operatorTelegramId || operatorTelegramId === "0") {
|
|
console.error("SEED_OPERATOR_TELEGRAM_ID not set");
|
|
process.exit(1);
|
|
}
|
|
|
|
const { db, pool } = createClient(databaseUrl);
|
|
|
|
await db
|
|
.insert(operators)
|
|
.values({
|
|
telegramUserId: Number(operatorTelegramId),
|
|
displayName: operatorName,
|
|
role: "admin",
|
|
defaultTimezone: "Asia/Kuala_Lumpur",
|
|
})
|
|
.onConflictDoNothing();
|
|
|
|
console.log(`Seeded operator with telegram_user_id=${operatorTelegramId}`);
|
|
await pool.end();
|