Merge branch 'main' of github.com:webbeetechnologies/taylordb-fullstack-template

This commit is contained in:
Thet Aung 2026-01-20 16:24:38 +03:00
commit 81a2e1f87d
4 changed files with 44 additions and 10 deletions

View File

@ -11,14 +11,11 @@ export const trpc: CreateTRPCReact<AppRouter, unknown> =
/**
* Get the base URL for tRPC requests
*/
function getBaseUrl() {
if (typeof window !== "undefined") {
// Browser: use relative URL or environment variable
return import.meta.env.VITE_TRPC_URL || "http://localhost:3001/api";
}
// SSR: assume localhost
return "http://localhost:3001/api";
}
const BASE_URL =
(typeof globalThis.process !== "undefined" &&
globalThis.process.env?.VITE_TRPC_URL) ||
import.meta.env.VITE_TRPC_URL ||
"http://localhost:3001/api";
/**
* Create tRPC client
@ -26,7 +23,7 @@ function getBaseUrl() {
export const trpcClient: TRPCClient<AppRouter> = trpc.createClient({
links: [
httpBatchLink({
url: `${getBaseUrl()}/trpc`,
url: `${BASE_URL}/trpc`,
// Optional: add headers, credentials, etc.
// headers() {
// return {

View File

@ -10,7 +10,7 @@
},
"scripts": {
"dev": "tsx watch index.ts",
"build": "npx esbuild index.ts --bundle --outfile=dist/index.js --format=esm --platform=node --packages=external",
"build": "pnpm exec esbuild index.ts --bundle --outfile=dist/index.js --format=esm --platform=node --packages=external",
"start": "node dist/index.js"
},
"dependencies": {
@ -25,6 +25,7 @@
"@types/express": "^5.0.6",
"@types/node": "^24.10.1",
"concurrently": "^9.2.1",
"esbuild": "^0.27.2",
"tsx": "^4.21.0",
"typescript": "~5.9.3"
}

View File

@ -166,6 +166,9 @@ importers:
concurrently:
specifier: ^9.2.1
version: 9.2.1
esbuild:
specifier: ^0.27.2
version: 0.27.2
tsx:
specifier: ^4.21.0
version: 4.21.0

View File

@ -24,6 +24,26 @@ services:
TAYLORDB_API_TOKEN: secrets.TAYLORDB_API_TOKEN
TAYLORDB_SERVER_ID: vars.TAYLORDB_SERVER_ID
FRONTEND_URL: routing.client.url
start:
command: pnpm start --port 3000
port: 3000
env:
vars:
TAYLORDB_BASE_URL: vars.TAYLORDB_INTERNAL_BASE_URL
TAYLORDB_API_TOKEN: secrets.TAYLORDB_API_TOKEN
TAYLORDB_SERVER_ID: vars.TAYLORDB_SERVER_ID
FRONTEND_URL: routing.client.url
build:
commands:
- pnpm build
env:
vars:
TAYLORDB_BASE_URL: vars.TAYLORDB_INTERNAL_BASE_URL
TAYLORDB_API_TOKEN: secrets.TAYLORDB_API_TOKEN
TAYLORDB_SERVER_ID: vars.TAYLORDB_SERVER_ID
FRONTEND_URL: routing.client.url
client:
workDir: apps/client
@ -36,6 +56,19 @@ services:
env:
vars:
VITE_TRPC_URL: routing.server.url
start:
command: pnpm preview --port 5173
port: 5173
env:
vars:
VITE_TRPC_URL: routing.server.url
build:
commands:
- pnpm build
env:
vars:
VITE_TRPC_URL: routing.server.url
taylordb:
types: