@powerhousedao/switchboard 2.2.122-dev.0 → 2.2.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/clients/redis.d.ts +1 -1
- package/dist/src/clients/redis.d.ts.map +1 -1
- package/dist/src/clients/redis.js +1 -5
- package/dist/src/clients/redis.js.map +1 -1
- package/dist/src/index.js +18 -24
- package/dist/src/index.js.map +1 -1
- package/dist/src/install-packages.js +1 -1
- package/dist/src/install-packages.js.map +1 -1
- package/package.json +6 -6
- package/src/clients/redis.ts +1 -6
- package/src/index.ts +23 -26
- package/src/install-packages.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RedisClientType } from "redis";
|
|
2
2
|
export declare let redisClient: RedisClientType;
|
|
3
|
-
export declare const initRedis: () => Promise<RedisClientType>;
|
|
3
|
+
export declare const initRedis: (url: string) => Promise<RedisClientType>;
|
|
4
4
|
export declare const closeRedis: () => void;
|
|
5
5
|
//# sourceMappingURL=redis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../../src/clients/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,OAAO,CAAC;AAE3D,eAAO,IAAI,WAAW,EAAE,eAAe,CAAC;AACxC,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../../src/clients/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,OAAO,CAAC;AAE3D,eAAO,IAAI,WAAW,EAAE,eAAe,CAAC;AACxC,eAAO,MAAM,SAAS,GAAU,KAAK,MAAM,6BAuB1C,CAAC;AAeF,eAAO,MAAM,UAAU,YAItB,CAAC"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { createClient } from "redis";
|
|
2
2
|
export let redisClient;
|
|
3
|
-
export const initRedis = async () => {
|
|
3
|
+
export const initRedis = async (url) => {
|
|
4
4
|
if (!redisClient) {
|
|
5
|
-
const url = process.env.REDIS_TLS_URL ?? process.env.REDIS_URL;
|
|
6
|
-
if (!url) {
|
|
7
|
-
throw new Error("REDIS_TLS_URL is not set");
|
|
8
|
-
}
|
|
9
5
|
const socket = url.includes("rediss")
|
|
10
6
|
? {
|
|
11
7
|
tls: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../../src/clients/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAE3D,MAAM,CAAC,IAAI,WAA4B,CAAC;AACxC,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../../src/clients/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAE3D,MAAM,CAAC,IAAI,WAA4B,CAAC;AACxC,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE;IAC7C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACnC,CAAC,CAAC;gBACE,GAAG,EAAE,IAAI;gBACT,kBAAkB,EAAE,KAAK;aAC1B;YACH,CAAC,CAAC,SAAS,CAAC;QAEd,WAAW,GAAG,YAAY,CAAC;YACzB,GAAG;YACH,MAAM;SACP,CAAC,CAAC;QAEH,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE;YACtC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QAEH,WAAW,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,WAAW,CACvB,KAAK,IAAI,EAAE;IACT,IAAI,CAAC;QACH,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC,EACD,IAAI,GAAG,EAAE,GAAG,CAAC,CACd,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE;IAC7B,aAAa,CAAC,KAAK,CAAC,CAAC;IAErB,WAAW,CAAC,UAAU,EAAE,CAAC;AAC3B,CAAC,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { startAPI } from "@powerhousedao/reactor-api";
|
|
3
3
|
import * as Sentry from "@sentry/node";
|
|
4
|
-
import { ReactorBuilder, driveDocumentModelModule } from "document-drive";
|
|
4
|
+
import { InMemoryCache, ReactorBuilder, driveDocumentModelModule, } from "document-drive";
|
|
5
5
|
import RedisCache from "document-drive/cache/redis";
|
|
6
|
+
import { FilesystemStorage } from "document-drive/storage/filesystem";
|
|
6
7
|
import { PrismaStorageFactory } from "document-drive/storage/prisma";
|
|
7
8
|
import { documentModelDocumentModelModule, } from "document-model";
|
|
8
9
|
import dotenv from "dotenv";
|
|
9
10
|
import express from "express";
|
|
11
|
+
import path from "path";
|
|
10
12
|
import { initRedis } from "./clients/redis.js";
|
|
11
13
|
import { initProfilerFromEnv } from "./profiler.js";
|
|
12
|
-
import { PackagesManager } from "./utils/package-manager.js";
|
|
13
14
|
dotenv.config();
|
|
14
15
|
// Create a monolith express app for all subgraphs
|
|
15
16
|
const app = express();
|
|
@@ -33,32 +34,29 @@ const main = async () => {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
try {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
packages,
|
|
41
|
-
});
|
|
42
|
-
const { documentModels, subgraphs } = await pkgManager.init();
|
|
43
|
-
const redis = await initRedis();
|
|
44
|
-
const connectionString = process.env.DATABASE_URL;
|
|
45
|
-
if (!connectionString) {
|
|
46
|
-
throw new Error("Please set env var DATABASE_URL");
|
|
37
|
+
const redisUrl = process.env.REDIS_TLS_URL ?? process.env.REDIS_URL;
|
|
38
|
+
let redis;
|
|
39
|
+
if (redisUrl) {
|
|
40
|
+
redis = await initRedis(redisUrl);
|
|
47
41
|
}
|
|
42
|
+
const connectionString = process.env.DATABASE_URL ?? "./.ph/drive-storage";
|
|
48
43
|
const dbUrl = connectionString.includes("amazonaws") &&
|
|
49
44
|
!connectionString.includes("sslmode=no-verify")
|
|
50
45
|
? connectionString + "?sslmode=no-verify"
|
|
51
46
|
: connectionString;
|
|
52
|
-
const
|
|
53
|
-
const storageFactory =
|
|
54
|
-
|
|
47
|
+
const cache = redis ? new RedisCache(redis) : new InMemoryCache();
|
|
48
|
+
const storageFactory = dbUrl.startsWith("postgres")
|
|
49
|
+
? new PrismaStorageFactory(dbUrl, cache)
|
|
50
|
+
: undefined;
|
|
51
|
+
const storage = storageFactory
|
|
52
|
+
? storageFactory.build()
|
|
53
|
+
: new FilesystemStorage(path.join(process.cwd(), dbUrl));
|
|
55
54
|
const reactor = new ReactorBuilder([
|
|
56
55
|
documentModelDocumentModelModule,
|
|
57
56
|
driveDocumentModelModule,
|
|
58
|
-
...documentModels,
|
|
59
57
|
])
|
|
60
58
|
.withStorage(storage)
|
|
61
|
-
.withCache(
|
|
59
|
+
.withCache(cache)
|
|
62
60
|
.build();
|
|
63
61
|
// init drive server
|
|
64
62
|
await reactor.initialize();
|
|
@@ -66,13 +64,9 @@ const main = async () => {
|
|
|
66
64
|
await startAPI(reactor, {
|
|
67
65
|
express: app,
|
|
68
66
|
port: serverPort,
|
|
69
|
-
dbPath: dbUrl,
|
|
70
|
-
|
|
67
|
+
dbPath: dbUrl.startsWith("postgres") ? dbUrl : "./.ph/read-storage",
|
|
68
|
+
configFile: path.join(process.cwd(), "powerhouse.config.json"),
|
|
71
69
|
});
|
|
72
|
-
// start http server
|
|
73
|
-
// httpServer.listen({ port: serverPort }, () => {
|
|
74
|
-
// console.log(`Subgraph server listening on port ${serverPort}`);
|
|
75
|
-
// });
|
|
76
70
|
}
|
|
77
71
|
catch (e) {
|
|
78
72
|
Sentry.captureException(e);
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,aAAa,EACb,cAAc,EACd,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,UAAU,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAEL,gCAAgC,GACjC,MAAM,gBAAgB,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,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AC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install-packages.js","sourceRoot":"","sources":["../../src/install-packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AACvD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,IAAI,GAAG,KAAK,EAAE;QAAE,SAAS;IACzB,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;IACnC,QAAQ,CAAC,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"install-packages.js","sourceRoot":"","sources":["../../src/install-packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AACvD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,IAAI,GAAG,KAAK,EAAE;QAAE,SAAS;IACzB,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;IACnC,QAAQ,CAAC,YAAY,GAAG,SAAS,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AAC3D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/switchboard",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.143",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"switchboard": "dist/src/index.js"
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"express": "^4.21.2",
|
|
21
21
|
"graphql": "^16.10.0",
|
|
22
22
|
"redis": "^4.7.0",
|
|
23
|
-
"@powerhousedao/config": "1.
|
|
24
|
-
"@powerhousedao/reactor-api": "1.
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"document-model": "
|
|
23
|
+
"@powerhousedao/config": "1.28.1",
|
|
24
|
+
"@powerhousedao/reactor-api": "1.31.0",
|
|
25
|
+
"document-drive": "1.30.1",
|
|
26
|
+
"@powerhousedao/scalars": "2.0.1",
|
|
27
|
+
"document-model": "3.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/express": "^5.0.0",
|
package/src/clients/redis.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { createClient, type RedisClientType } from "redis";
|
|
2
2
|
|
|
3
3
|
export let redisClient: RedisClientType;
|
|
4
|
-
export const initRedis = async () => {
|
|
4
|
+
export const initRedis = async (url: string) => {
|
|
5
5
|
if (!redisClient) {
|
|
6
|
-
const url = process.env.REDIS_TLS_URL ?? process.env.REDIS_URL;
|
|
7
|
-
if (!url) {
|
|
8
|
-
throw new Error("REDIS_TLS_URL is not set");
|
|
9
|
-
}
|
|
10
|
-
|
|
11
6
|
const socket = url.includes("rediss")
|
|
12
7
|
? {
|
|
13
8
|
tls: true,
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { startAPI } from "@powerhousedao/reactor-api";
|
|
3
3
|
import * as Sentry from "@sentry/node";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
InMemoryCache,
|
|
6
|
+
ReactorBuilder,
|
|
7
|
+
driveDocumentModelModule,
|
|
8
|
+
} from "document-drive";
|
|
5
9
|
import RedisCache from "document-drive/cache/redis";
|
|
10
|
+
import { FilesystemStorage } from "document-drive/storage/filesystem";
|
|
6
11
|
import { PrismaStorageFactory } from "document-drive/storage/prisma";
|
|
7
12
|
import {
|
|
8
13
|
type DocumentModelModule,
|
|
@@ -10,9 +15,10 @@ import {
|
|
|
10
15
|
} from "document-model";
|
|
11
16
|
import dotenv from "dotenv";
|
|
12
17
|
import express from "express";
|
|
18
|
+
import path from "path";
|
|
19
|
+
import { type RedisClientType } from "redis";
|
|
13
20
|
import { initRedis } from "./clients/redis.js";
|
|
14
21
|
import { initProfilerFromEnv } from "./profiler.js";
|
|
15
|
-
import { PackagesManager } from "./utils/package-manager.js";
|
|
16
22
|
|
|
17
23
|
dotenv.config();
|
|
18
24
|
|
|
@@ -42,36 +48,32 @@ const main = async () => {
|
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
try {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const pkgManager = new PackagesManager({
|
|
50
|
-
packages,
|
|
51
|
-
});
|
|
52
|
-
const { documentModels, subgraphs } = await pkgManager.init();
|
|
53
|
-
const redis = await initRedis();
|
|
54
|
-
const connectionString = process.env.DATABASE_URL;
|
|
55
|
-
if (!connectionString) {
|
|
56
|
-
throw new Error("Please set env var DATABASE_URL");
|
|
51
|
+
const redisUrl = process.env.REDIS_TLS_URL ?? process.env.REDIS_URL;
|
|
52
|
+
let redis: RedisClientType | undefined;
|
|
53
|
+
if (redisUrl) {
|
|
54
|
+
redis = await initRedis(redisUrl);
|
|
57
55
|
}
|
|
56
|
+
const connectionString = process.env.DATABASE_URL ?? "./.ph/drive-storage";
|
|
58
57
|
const dbUrl =
|
|
59
58
|
connectionString.includes("amazonaws") &&
|
|
60
59
|
!connectionString.includes("sslmode=no-verify")
|
|
61
60
|
? connectionString + "?sslmode=no-verify"
|
|
62
61
|
: connectionString;
|
|
63
62
|
|
|
64
|
-
const
|
|
65
|
-
const storageFactory =
|
|
66
|
-
|
|
63
|
+
const cache = redis ? new RedisCache(redis) : new InMemoryCache();
|
|
64
|
+
const storageFactory = dbUrl.startsWith("postgres")
|
|
65
|
+
? new PrismaStorageFactory(dbUrl, cache)
|
|
66
|
+
: undefined;
|
|
67
|
+
const storage = storageFactory
|
|
68
|
+
? storageFactory.build()
|
|
69
|
+
: new FilesystemStorage(path.join(process.cwd(), dbUrl));
|
|
67
70
|
|
|
68
71
|
const reactor = new ReactorBuilder([
|
|
69
72
|
documentModelDocumentModelModule,
|
|
70
73
|
driveDocumentModelModule,
|
|
71
|
-
...documentModels,
|
|
72
74
|
] as DocumentModelModule[])
|
|
73
75
|
.withStorage(storage)
|
|
74
|
-
.withCache(
|
|
76
|
+
.withCache(cache)
|
|
75
77
|
.build();
|
|
76
78
|
|
|
77
79
|
// init drive server
|
|
@@ -81,14 +83,9 @@ const main = async () => {
|
|
|
81
83
|
await startAPI(reactor, {
|
|
82
84
|
express: app,
|
|
83
85
|
port: serverPort,
|
|
84
|
-
dbPath: dbUrl,
|
|
85
|
-
|
|
86
|
+
dbPath: dbUrl.startsWith("postgres") ? dbUrl : "./.ph/read-storage",
|
|
87
|
+
configFile: path.join(process.cwd(), "powerhouse.config.json"),
|
|
86
88
|
});
|
|
87
|
-
|
|
88
|
-
// start http server
|
|
89
|
-
// httpServer.listen({ port: serverPort }, () => {
|
|
90
|
-
// console.log(`Subgraph server listening on port ${serverPort}`);
|
|
91
|
-
// });
|
|
92
89
|
} catch (e) {
|
|
93
90
|
Sentry.captureException(e);
|
|
94
91
|
console.error("App crashed", e);
|
package/src/install-packages.ts
CHANGED