Skip to content

Commit

Permalink
fix(node): allow to import node package without postgres (#757)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra authored May 10, 2022
1 parent 83ff0f3 commit 59e1058
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core/tests/postgres.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('postgres agents', () => {
}

// loading the postgres wallet plugin
await loadPostgresPlugin(storageConfig.config, storageConfig.credentials)
loadPostgresPlugin(storageConfig.config, storageConfig.credentials)

aliceAgent = new Agent(alicePostgresConfig.config, alicePostgresConfig.agentDependencies)
aliceAgent.registerInboundTransport(new SubjectInboundTransport(aliceMessages))
Expand Down
7 changes: 5 additions & 2 deletions packages/node/src/PostgresPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type NativeIndyPostgres = {
init_storagetype: (arg0: string, arg1: string) => number
}

export const indyPostgresStorage = getLibrary() as NativeIndyPostgres
let indyPostgresStorage: NativeIndyPostgres | undefined

export interface WalletStorageConfig {
url: string
Expand Down Expand Up @@ -96,7 +96,10 @@ export interface IndyPostgresStorageConfig {
}

export function loadPostgresPlugin(config: WalletStorageConfig, credentials: WalletStorageCredentials) {
if (!indyPostgresStorage) {
indyPostgresStorage = getLibrary()
}

indyPostgresStorage.postgresstorage_init()
indyPostgresStorage.init_storagetype(JSON.stringify(config), JSON.stringify(credentials))
return true
}

0 comments on commit 59e1058

Please sign in to comment.