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

View File

@ -10,7 +10,7 @@
}, },
"scripts": { "scripts": {
"dev": "tsx watch index.ts", "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" "start": "node dist/index.js"
}, },
"dependencies": { "dependencies": {
@ -25,6 +25,7 @@
"@types/express": "^5.0.6", "@types/express": "^5.0.6",
"@types/node": "^24.10.1", "@types/node": "^24.10.1",
"concurrently": "^9.2.1", "concurrently": "^9.2.1",
"esbuild": "^0.27.2",
"tsx": "^4.21.0", "tsx": "^4.21.0",
"typescript": "~5.9.3" "typescript": "~5.9.3"
} }

View File

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

View File

@ -25,6 +25,26 @@ services:
TAYLORDB_SERVER_ID: vars.TAYLORDB_SERVER_ID TAYLORDB_SERVER_ID: vars.TAYLORDB_SERVER_ID
FRONTEND_URL: routing.client.url 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: client:
workDir: apps/client workDir: apps/client
install: install:
@ -36,6 +56,19 @@ services:
env: env:
vars: vars:
VITE_TRPC_URL: routing.server.url 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: taylordb:
types: types: