fix: Enhance initialization checks in FrameworkOrbitDBService and FrameworkIPFSService; add tsconfig.docker.json for integration tests

This commit is contained in:
anonpenguin 2025-07-02 07:45:55 +03:00
parent b0a68b19c9
commit 1481bd8594
2 changed files with 51 additions and 2 deletions

View File

@ -21,9 +21,18 @@ export interface IPFSInstance {
export class FrameworkOrbitDBService { export class FrameworkOrbitDBService {
private orbitDBService: OrbitDBInstance; private orbitDBService: OrbitDBInstance;
private initialized: boolean = false;
constructor(orbitDBService: OrbitDBInstance) { constructor(orbitDBService: OrbitDBInstance) {
this.orbitDBService = orbitDBService; this.orbitDBService = orbitDBService;
// Check if the service is already initialized by trying to get OrbitDB
try {
if (orbitDBService.getOrbitDB && orbitDBService.getOrbitDB()) {
this.initialized = true;
}
} catch (error) {
// Service not initialized yet
}
} }
async openDatabase(name: string, type: StoreType): Promise<any> { async openDatabase(name: string, type: StoreType): Promise<any> {
@ -31,7 +40,10 @@ export class FrameworkOrbitDBService {
} }
async init(): Promise<void> { async init(): Promise<void> {
if (!this.initialized) {
await this.orbitDBService.init(); await this.orbitDBService.init();
this.initialized = true;
}
} }
async stop(): Promise<void> { async stop(): Promise<void> {
@ -47,13 +59,25 @@ export class FrameworkOrbitDBService {
export class FrameworkIPFSService { export class FrameworkIPFSService {
private ipfsService: IPFSInstance; private ipfsService: IPFSInstance;
private initialized: boolean = false;
constructor(ipfsService: IPFSInstance) { constructor(ipfsService: IPFSInstance) {
this.ipfsService = ipfsService; this.ipfsService = ipfsService;
// Check if the service is already initialized by trying to get Helia
try {
if (ipfsService.getHelia && ipfsService.getHelia()) {
this.initialized = true;
}
} catch (error) {
// Service not initialized yet
}
} }
async init(): Promise<void> { async init(): Promise<void> {
if (!this.initialized) {
await this.ipfsService.init(); await this.ipfsService.init();
this.initialized = true;
}
} }
async stop(): Promise<void> { async stop(): Promise<void> {

View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ES2020",
"moduleResolution": "bundler",
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictPropertyInitialization": false,
"skipLibCheck": true,
"outDir": "dist",
"isolatedModules": true,
"removeComments": true,
"inlineSources": true,
"sourceMap": true,
"allowJs": true,
"strict": true,
"importsNotUsedAsValues": "remove",
"baseUrl": "../../../../"
},
"include": ["blog-api-server.ts", "../../../../src/**/*"],
"ts-node": {
"esm": true
}
}