Skip to content

Commit

Permalink
Merge pull request #67 from windingtree/feat/db-name-config
Browse files Browse the repository at this point in the history
feat: add path to storage options
  • Loading branch information
kostysh authored Nov 29, 2023
2 parents a3a606f + 1a83a91 commit 72f116a
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion examples/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"luxon": "^3.3.0"
},
"dependencies": {
"superjson": "^1.13.1"
"superjson": "^2.2.1"
},
"eslintConfig": {
"extends": [
Expand Down
2 changes: 1 addition & 1 deletion examples/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@windingtree/contracts": "^1.0.0",
"@windingtree/sdk-types": "workspace:*",
"@windingtree/sdk-utils": "workspace:*",
"superjson": "^1.13.1"
"superjson": "^2.2.1"
},
"eslintConfig": {
"extends": [
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@windingtree/sdk-types": "workspace:*",
"@windingtree/sdk-utils": "workspace:*",
"libp2p": "^0.46.14",
"superjson": "^2.0.0",
"superjson": "^2.2.1",
"viem": "^1.3.0"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-manger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@windingtree/contracts": "^1.0.0",
"@windingtree/sdk-logger": "workspace:*",
"@windingtree/sdk-types": "workspace:*",
"superjson": "^1.13.1",
"superjson": "^2.2.1",
"viem": "^1.3.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/node-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@windingtree/sdk-types": "workspace:*",
"abitype": "^0.9.3",
"jose": "^4.14.4",
"superjson": "^1.13.1",
"superjson": "^2.2.1",
"viem": "^1.3.0",
"zod": "^3.21.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@windingtree/sdk-types": "workspace:*",
"@windingtree/sdk-utils": "workspace:*",
"libp2p": "^0.46.14",
"superjson": "^2.0.0",
"superjson": "^2.2.1",
"viem": "^1.3.0"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/pubsub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@windingtree/sdk-utils": "workspace:*",
"libp2p": "^0.46.14",
"multiformats": "^12.0.1",
"superjson": "^1.13.1"
"superjson": "^2.2.1"
},
"scripts": {
"build": "tsup",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"eslint-config-react-app": "^7.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"superjson": "^1.13.1",
"superjson": "^2.2.1",
"typescript": "^5.1.6",
"viem": "^1.3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"buffer": "^6.0.3",
"classic-level": "^1.3.0",
"level-transcoder": "^1.0.1",
"superjson": "^1.13.1"
"superjson": "^2.2.1"
},
"scripts": {
"build": "tsup",
Expand Down
10 changes: 8 additions & 2 deletions packages/storage/src/level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@ const superJsonEncoding: IEncoding<
name: 'super-json-encoding',
};

export interface LevelStorageOptions extends GenericStorageOptions {
path?: string;
}

export class LevelDBStorage extends Storage {
protected db: ClassicLevel<string, string | string[]>;
/** Key for storing ids included in the scope */
scopeIdsKey?: string;

constructor(options?: GenericStorageOptions) {
constructor(options?: LevelStorageOptions) {
super();

options = options ?? {};

this.db = new ClassicLevel<string, string | string[]>('./db', {
const dbPath = options.path || './db';

this.db = new ClassicLevel<string, string | string[]>(dbPath, {
keyEncoding: 'utf8',
valueEncoding: superJsonEncoding,
createIfMissing: true,
Expand Down
47 changes: 20 additions & 27 deletions pnpm-lock.yaml

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

0 comments on commit 72f116a

Please sign in to comment.