Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
},
"scripts": {
"dev": "vite",
"dev:api": "AUTH_REQUIRED=true APP_ENCRYPTION_KEY=${APP_ENCRYPTION_KEY:-0000000000000000000000000000000000000000000000000000000000000000} tsx watch src/backend/index.ts",
"dev:api": "cross-env AUTH_REQUIRED=true APP_ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000 tsx watch src/backend/index.ts",
"dev:all": "concurrently -n api,web -c cyan,magenta \"npm run dev:api\" \"npm run dev\"",
"dev:auth": "AUTH_REQUIRED=true LOCAL_SINGLE_USER=false vite",
"dev:api:auth": "AUTH_REQUIRED=true LOCAL_SINGLE_USER=false APP_ENCRYPTION_KEY=${APP_ENCRYPTION_KEY:-0000000000000000000000000000000000000000000000000000000000000000} tsx watch src/backend/index.ts",
"dev:auth": "cross-env AUTH_REQUIRED=true LOCAL_SINGLE_USER=false vite",
"dev:api:auth": "cross-env AUTH_REQUIRED=true LOCAL_SINGLE_USER=false APP_ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000 tsx watch src/backend/index.ts",
"dev:all:auth": "concurrently -n api,web -c cyan,magenta \"npm run dev:api:auth\" \"npm run dev:auth\"",
"build": "tsc && vite build",
"preview": "vite preview",
Expand Down Expand Up @@ -55,6 +55,7 @@
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.2",
"concurrently": "^10.0.3",
"cross-env": "^7.0.3",
"tsx": "^4.22.4",
"vite": "^8.0.12"
}
Expand Down
17 changes: 16 additions & 1 deletion apps/web/src/frontend/api/schemaApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,22 @@ export function invalidateCache(prefix?: string): void {
}

async function parseJson<T>(res: Response): Promise<T> {
const data = (await res.json()) as T & { error?: string };
const text = await res.text();
if (!text.trim()) {
throw new Error(
res.status === 502 || res.status === 504 || res.type === 'opaque'
? 'API server unreachable — run `npm run dev` from the repo root (starts both the API and UI).'
: `Empty response from server (${res.status} ${res.statusText || 'unknown'})`
);
}

let data: T & { error?: string };
try {
data = JSON.parse(text) as T & { error?: string };
} catch {
throw new Error(`Invalid response from server (${res.status}): ${text.slice(0, 200)}`);
}

if (!res.ok) {
throw new Error(
typeof data === 'object' && data && 'error' in data && data.error
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/frontend/lib/provider-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ const db2Settings: ProviderSettings = {
label: 'IBM DB2',
defaultPort: 50000,
defaultSchema: '',
schemaRequired: false,
schemaRequired: true,
buildConnectionString(o) {
if (o.connectionString?.trim()) return o.connectionString.trim();
const host = o.host || 'localhost';
const port = o.port || this.defaultPort;
let cs = `DATABASE=${o.database || ''};HOSTNAME=${host};PORT=${port};PROTOCOL=TCPIP;UID=${o.username || ''};PWD=${o.password || ''};`;
if (o.schema) cs += `CurrentSchema=${o.schema};`;
let cs = `DATABASE=${o.database || ''};HOSTNAME=${host};PORT=${port};PROTOCOL=TCPIP;UID=${o.username || ''};PWD=${o.password || ''};Authentication=SERVER;`;
if (o.schema) cs += `CurrentSchema=${o.schema.toUpperCase()};`;
return cs;
},
};
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/cores/driver-detector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createRequire } from 'node:module';
import type { DriverInfo } from '../interfaces';
import { getAdapter, ADAPTERS } from '../providers/adapter-registry';
import { setupDb2ClientEnv } from '../providers/db2/db2.env';

const nodeRequire = createRequire(import.meta.url);

Expand All @@ -20,6 +21,10 @@ export class DriverDetector {
}

private static checkPackage(dialect: string, packageName: string): DriverInfo {
// ibm_db's native bindings need the bundled clidriver on PATH/LD_LIBRARY_PATH
// (especially on Windows) — same setup the DB2 adapter runs before open().
if (packageName === 'ibm_db') setupDb2ClientEnv();

try {
const mod = nodeRequire(packageName);
return {
Expand Down
Loading