Skip to content

Commit 5973e0d

Browse files
committed
feat: Add debug logging for Contentrain database path resolution
- Implement debug logging to help diagnose database path issues - Log absolute database path, file existence, and current working directory - Resolve database path relative to current working directory - Remove unnecessary configuration options to simplify loader initialization
1 parent fd08a6b commit 5973e0d

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

packages/nuxt/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @contentrain/nuxt
22

3+
## 3.1.0
4+
5+
### Minor Changes
6+
7+
- debug log
8+
39
## 3.0.0
410

511
### Major Changes

packages/nuxt/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentrain/nuxt",
3-
"version": "3.0.0",
3+
"version": "3.1.0",
44
"description": "Official Nuxt module for Contentrain SDK, providing seamless integration with Contentrain CMS",
55
"author": "Contentrain Inc.",
66
"license": "MIT",

packages/nuxt/src/runtime/server/utils/sdk.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { SQLiteLoader } from '@contentrain/query';
22
import type { RuntimeConfig } from '@nuxt/schema';
3+
import { existsSync } from 'node:fs';
4+
import { resolve } from 'node:path';
5+
import process from 'node:process';
36
import { QueryFactory, SQLiteLoader as SQLiteLoaderImpl } from '@contentrain/query';
47

58
let _sdk: SQLiteLoader | null = null;
@@ -14,12 +17,19 @@ export function getSDK(config: RuntimeConfig): SQLiteLoader {
1417
throw new Error('databasePath is required for SQLite loader');
1518
}
1619

20+
// Resolve absolute path
21+
const dbPath = resolve(process.cwd(), config.contentrain.databasePath);
22+
23+
// Check if database file exists
24+
const dbExists = existsSync(dbPath);
25+
console.log('Contentrain DB Path:', dbPath);
26+
console.log('DB File Exists:', dbExists);
27+
console.log('Current Working Directory:', process.cwd());
28+
1729
const loader = new SQLiteLoaderImpl({
18-
databasePath: config.contentrain.databasePath,
30+
databasePath: dbPath,
1931
cache: config.contentrain.cache !== false,
2032
maxCacheSize: config.contentrain.maxCacheSize || 100,
21-
defaultLocale: config.contentrain.defaultLocale,
22-
modelTTL: config.contentrain.modelTTL || {},
2333
});
2434

2535
QueryFactory.setLoader(loader);

0 commit comments

Comments
 (0)