Skip to content

Commit

Permalink
Fix/make database name prefix optional (#152)
Browse files Browse the repository at this point in the history
* chore: update readme

* fix: make dbNamePrefix optional

* chore: version bump
  • Loading branch information
jkoenig134 authored May 7, 2024
1 parent c519129 commit 96d5daf
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 73 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.10.1

- the prefix `acc-` that is appended to the configured dbName in the config is now configurable via the key `database:dbNamePrefix`

## 3.10.0

-> SDK 4.2.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This monorepo consolidates the following packages / applications:
| Component | Version(s) |
| -- | -- |
| [The Connector docker images](./) | [see ghcr.io](https://github.com/nmshd/connector/pkgs/container/connector) |
| [The Connector helm charts](./) | [see ghcr.io](https://github.com/nmshd/connector/pkgs/container/connector-helm-chart) and [![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/enmeshed-connector)](https://artifacthub.io/packages/search?repo=enmeshed-connector) |
| [The Connector helm charts](./helmChart) | [see ghcr.io](https://github.com/nmshd/connector/pkgs/container/connector-helm-chart) and [![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/enmeshed-connector)](https://artifacthub.io/packages/search?repo=enmeshed-connector) |
| [TypeScript Connector SDK](packages/sdk/) | [![npm version](https://badge.fury.io/js/@nmshd%2fconnector-sdk.svg)](https://www.npmjs.com/package/@nmshd/connector-sdk) |

## Documentation
Expand Down
4 changes: 4 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"type": "string",
"default": "default",
"minLength": 1
},
"dbNamePrefix": {
"type": "string",
"default": "acc-"
}
},
"required": ["connectionString"],
Expand Down
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
},
"database": {
"driver": "mongodb",
"dbName": "default"
"dbName": "default",
"dbNamePrefix": "acc-"
},
"logging": {
"appenders": {
Expand Down
68 changes: 3 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nmshd/connector",
"version": "3.10.0",
"version": "3.10.1",
"private": true,
"description": "The Enmeshed Connector",
"homepage": "https://enmeshed.eu/integrate",
Expand Down
2 changes: 1 addition & 1 deletion src/ConnectorRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class ConnectorRuntime extends Runtime<ConnectorRuntimeConfig> {
}

protected async initAccount(): Promise<void> {
const db = await this.transport.createDatabase(`acc-${this.runtimeConfig.database.dbName}`);
const db = await this.transport.createDatabase(`${this.runtimeConfig.database.dbNamePrefix}${this.runtimeConfig.database.dbName}`);

this.accountController = await new AccountController(this.transport, db, this.transport.config).init().catch((e) => {
if (e instanceof ApplicationError && e.code === "error.transport.general.platformClientInvalid") {
Expand Down
2 changes: 1 addition & 1 deletion src/ConnectorRuntimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface LokiJSSettings {
export interface ConnectorRuntimeConfig extends RuntimeConfig {
debug: boolean;

database: (MongoDBSettings | LokiJSSettings) & { dbName: string };
database: (MongoDBSettings | LokiJSSettings) & { dbName: string; dbNamePrefix: string };

logging: log4js.Configuration;

Expand Down
10 changes: 8 additions & 2 deletions src/jsonSchemas/connectorConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
"dbName": {
"type": "string"
},
"dbNamePrefix": {
"type": "string"
},
"driver": {
"const": "mongodb",
"type": "string"
}
},
"required": ["connectionString", "dbName", "driver"],
"required": ["connectionString", "dbName", "dbNamePrefix", "driver"],
"type": "object"
},
{
Expand All @@ -27,6 +30,9 @@
"dbName": {
"type": "string"
},
"dbNamePrefix": {
"type": "string"
},
"driver": {
"const": "lokijs",
"type": "string"
Expand All @@ -35,7 +41,7 @@
"type": "string"
}
},
"required": ["dbName", "driver", "folder"],
"required": ["dbName", "dbNamePrefix", "driver", "folder"],
"type": "object"
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/jsonSchemas/connectorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface LokiJSSettings {
export interface ConnectorConfig {
debug: boolean;

database: (MongoDBSettings | LokiJSSettings) & { dbName: string };
database: (MongoDBSettings | LokiJSSettings) & { dbName: string; dbNamePrefix: string };

transportLibrary: IConfigOverwrite;

Expand Down

0 comments on commit 96d5daf

Please sign in to comment.