@latticexyz/store-indexer 2.2.18-90aac1d4acce19ac592d47a090732dd11c1c3e7a → 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2
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/bin/postgres-decoded-indexer.cjs +322 -0
- package/dist/bin/postgres-decoded-indexer.cjs.map +1 -0
- package/dist/bin/postgres-decoded-indexer.d.cts +1 -0
- package/dist/bin/postgres-decoded-indexer.js +92 -1
- package/dist/bin/postgres-decoded-indexer.js.map +1 -1
- package/dist/bin/postgres-frontend.cjs +567 -0
- package/dist/bin/postgres-frontend.cjs.map +1 -0
- package/dist/bin/postgres-frontend.d.cts +1 -0
- package/dist/bin/postgres-frontend.js +258 -5
- package/dist/bin/postgres-frontend.js.map +1 -1
- package/dist/bin/postgres-indexer.cjs +368 -0
- package/dist/bin/postgres-indexer.cjs.map +1 -0
- package/dist/bin/postgres-indexer.d.cts +1 -0
- package/dist/bin/postgres-indexer.js +106 -1
- package/dist/bin/postgres-indexer.js.map +1 -1
- package/dist/bin/sqlite-indexer.cjs +567 -0
- package/dist/bin/sqlite-indexer.cjs.map +1 -0
- package/dist/bin/sqlite-indexer.d.cts +1 -0
- package/dist/bin/sqlite-indexer.js +243 -1
- package/dist/bin/sqlite-indexer.js.map +1 -1
- package/dist/chunk-66BWQNF7.js +38 -0
- package/dist/{chunk-R7HX5BT2.js.map → chunk-66BWQNF7.js.map} +1 -1
- package/dist/chunk-CGE4ONKA.js +44 -0
- package/dist/{chunk-YQ7E5W26.js.map → chunk-CGE4ONKA.js.map} +1 -1
- package/dist/chunk-GDNGJPVT.js +16 -0
- package/dist/{chunk-AYPBOJNL.js.map → chunk-GDNGJPVT.js.map} +1 -1
- package/dist/chunk-L5CWEDU6.js +53 -0
- package/dist/{chunk-O2SDU7EQ.js.map → chunk-L5CWEDU6.js.map} +1 -1
- package/dist/chunk-O4XAWAXU.js +72 -0
- package/dist/{chunk-ED45N3IT.js.map → chunk-O4XAWAXU.js.map} +1 -1
- package/dist/chunk-R7UQFYRA.js +99 -0
- package/dist/{chunk-JDWVOODJ.js.map → chunk-R7UQFYRA.js.map} +1 -1
- package/dist/chunk-SJLOWI5M.js +31 -0
- package/dist/{chunk-7O2ZWWUX.js.map → chunk-SJLOWI5M.js.map} +1 -1
- package/dist/healthcheck-2DQWYXPX.js +7 -0
- package/dist/helloWorld-6IXGINV6.js +7 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -0
- package/dist/metrics-HO5SO4EX.js +7 -0
- package/dist/metrics-HO5SO4EX.js.map +1 -0
- package/package.json +17 -9
- package/dist/chunk-7O2ZWWUX.js +0 -2
- package/dist/chunk-AYPBOJNL.js +0 -2
- package/dist/chunk-ED45N3IT.js +0 -2
- package/dist/chunk-JDWVOODJ.js +0 -2
- package/dist/chunk-O2SDU7EQ.js +0 -7
- package/dist/chunk-R7HX5BT2.js +0 -2
- package/dist/chunk-YQ7E5W26.js +0 -2
- package/dist/healthcheck-57YETUEX.js +0 -2
- package/dist/helloWorld-4VT4FZ7F.js +0 -2
- package/dist/metrics-4BMCDEZZ.js +0 -2
- /package/dist/{healthcheck-57YETUEX.js.map → healthcheck-2DQWYXPX.js.map} +0 -0
- /package/dist/{helloWorld-4VT4FZ7F.js.map → helloWorld-6IXGINV6.js.map} +0 -0
- /package/dist/{metrics-4BMCDEZZ.js.map → index.cjs.map} +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/koa-middleware/metrics.ts"],"sourcesContent":["import { Middleware } from \"koa\";\nimport promClient from \"prom-client\";\n\ntype MetricsOptions = {\n isHealthy?: () => boolean;\n isReady?: () => boolean;\n getLatestStoredBlockNumber?: () => Promise<bigint | undefined>;\n getDistanceFromFollowBlock?: () => Promise<bigint>;\n followBlockTag?: \"latest\" | \"safe\" | \"finalized\";\n};\n\n/**\n * Middleware to add Prometheus metrics endpoints\n */\nexport function metrics({\n isHealthy,\n isReady,\n getLatestStoredBlockNumber,\n getDistanceFromFollowBlock,\n followBlockTag,\n}: MetricsOptions = {}): Middleware {\n promClient.collectDefaultMetrics();\n if (isHealthy != null) {\n new promClient.Gauge({\n name: \"health_status\",\n help: \"Health status (0 = unhealthy, 1 = healthy)\",\n collect(): void {\n this.set(Number(isHealthy()));\n },\n });\n }\n\n if (isReady != null) {\n new promClient.Gauge({\n name: \"readiness_status\",\n help: \"Readiness status (whether the service is ready to receive requests, 0 = not ready, 1 = ready)\",\n collect(): void {\n this.set(Number(isReady()));\n },\n });\n }\n\n if (getLatestStoredBlockNumber != null) {\n new promClient.Gauge({\n name: \"latest_stored_block_number\",\n help: \"Latest block number stored in the database\",\n async collect(): Promise<void> {\n this.set(Number(await getLatestStoredBlockNumber()));\n },\n });\n }\n\n if (followBlockTag != null) {\n const blockTagGauge = new promClient.Gauge({\n name: \"follow_block_tag\",\n help: \"Block tag the indexer is following (0 = finalized, 1 = safe, 2 = latest)\",\n });\n const blockTagToValue = {\n finalized: 0,\n safe: 1,\n latest: 2,\n };\n blockTagGauge.set(blockTagToValue[followBlockTag]);\n }\n\n if (getDistanceFromFollowBlock != null) {\n new promClient.Gauge({\n name: \"distance_from_follow_block\",\n help: \"Block distance from the block tag this the indexer is following\",\n async collect(): Promise<void> {\n this.set(Number(await getDistanceFromFollowBlock()));\n },\n });\n }\n\n return async function metricsMiddleware(ctx, next): Promise<void> {\n if (ctx.path === \"/metrics\") {\n ctx.status = 200;\n ctx.body = await promClient.register.metrics();\n return;\n }\n\n await next();\n };\n}\n"],"mappings":"AACA,
|
1
|
+
{"version":3,"sources":["../src/koa-middleware/metrics.ts"],"sourcesContent":["import { Middleware } from \"koa\";\nimport promClient from \"prom-client\";\n\ntype MetricsOptions = {\n isHealthy?: () => boolean;\n isReady?: () => boolean;\n getLatestStoredBlockNumber?: () => Promise<bigint | undefined>;\n getDistanceFromFollowBlock?: () => Promise<bigint>;\n followBlockTag?: \"latest\" | \"safe\" | \"finalized\";\n};\n\n/**\n * Middleware to add Prometheus metrics endpoints\n */\nexport function metrics({\n isHealthy,\n isReady,\n getLatestStoredBlockNumber,\n getDistanceFromFollowBlock,\n followBlockTag,\n}: MetricsOptions = {}): Middleware {\n promClient.collectDefaultMetrics();\n if (isHealthy != null) {\n new promClient.Gauge({\n name: \"health_status\",\n help: \"Health status (0 = unhealthy, 1 = healthy)\",\n collect(): void {\n this.set(Number(isHealthy()));\n },\n });\n }\n\n if (isReady != null) {\n new promClient.Gauge({\n name: \"readiness_status\",\n help: \"Readiness status (whether the service is ready to receive requests, 0 = not ready, 1 = ready)\",\n collect(): void {\n this.set(Number(isReady()));\n },\n });\n }\n\n if (getLatestStoredBlockNumber != null) {\n new promClient.Gauge({\n name: \"latest_stored_block_number\",\n help: \"Latest block number stored in the database\",\n async collect(): Promise<void> {\n this.set(Number(await getLatestStoredBlockNumber()));\n },\n });\n }\n\n if (followBlockTag != null) {\n const blockTagGauge = new promClient.Gauge({\n name: \"follow_block_tag\",\n help: \"Block tag the indexer is following (0 = finalized, 1 = safe, 2 = latest)\",\n });\n const blockTagToValue = {\n finalized: 0,\n safe: 1,\n latest: 2,\n };\n blockTagGauge.set(blockTagToValue[followBlockTag]);\n }\n\n if (getDistanceFromFollowBlock != null) {\n new promClient.Gauge({\n name: \"distance_from_follow_block\",\n help: \"Block distance from the block tag this the indexer is following\",\n async collect(): Promise<void> {\n this.set(Number(await getDistanceFromFollowBlock()));\n },\n });\n }\n\n return async function metricsMiddleware(ctx, next): Promise<void> {\n if (ctx.path === \"/metrics\") {\n ctx.status = 200;\n ctx.body = await promClient.register.metrics();\n return;\n }\n\n await next();\n };\n}\n"],"mappings":";AACA,OAAO,gBAAgB;AAahB,SAAS,QAAQ;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAoB,CAAC,GAAe;AAClC,aAAW,sBAAsB;AACjC,MAAI,aAAa,MAAM;AACrB,QAAI,WAAW,MAAM;AAAA,MACn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ry/node";
|
3
|
+
import { ProfilingIntegration } from "@sentry/profiling-node";
|
4
|
+
import { stripUrlQueryAndFragment } from "@sentry/utils";
|
5
|
+
|
6
|
+
// src/debug.ts
|
7
|
+
import createDebug from "debug";
|
8
|
+
var debug = createDebug("mud:store-indexer");
|
9
|
+
var error = createDebug("mud:store-indexer");
|
10
|
+
debug.log = console.debug.bind(console);
|
11
|
+
error.log = console.error.bind(console);
|
12
|
+
|
13
|
+
// src/koa-middleware/sentry.ts
|
14
|
+
import compose from "koa-compose";
|
15
|
+
function errorHandler() {
|
16
|
+
return async function errorHandlerMiddleware(ctx, next) {
|
17
|
+
try {
|
18
|
+
await next();
|
19
|
+
} catch (err) {
|
20
|
+
Sentry.withScope((scope) => {
|
21
|
+
scope.addEventProcessor((event) => {
|
22
|
+
return Sentry.addRequestDataToEvent(event, ctx.request);
|
23
|
+
});
|
24
|
+
Sentry.captureException(err);
|
25
|
+
});
|
26
|
+
throw err;
|
27
|
+
}
|
28
|
+
};
|
29
|
+
}
|
30
|
+
function requestHandler() {
|
31
|
+
return async function requestHandlerMiddleware(ctx, next) {
|
32
|
+
await Sentry.runWithAsyncContext(async () => {
|
33
|
+
const hub = Sentry.getCurrentHub();
|
34
|
+
hub.configureScope(
|
35
|
+
(scope) => scope.addEventProcessor(
|
36
|
+
(event) => Sentry.addRequestDataToEvent(event, ctx.request, {
|
37
|
+
include: {
|
38
|
+
user: false
|
39
|
+
}
|
40
|
+
})
|
41
|
+
)
|
42
|
+
);
|
43
|
+
await next();
|
44
|
+
});
|
45
|
+
};
|
46
|
+
}
|
47
|
+
function tracing() {
|
48
|
+
return async function tracingMiddleware(ctx, next) {
|
49
|
+
const reqMethod = (ctx.method || "").toUpperCase();
|
50
|
+
const reqUrl = ctx.url && stripUrlQueryAndFragment(ctx.url);
|
51
|
+
let traceparentData;
|
52
|
+
if (ctx.request.get("sentry-trace")) {
|
53
|
+
traceparentData = Sentry.extractTraceparentData(ctx.request.get("sentry-trace"));
|
54
|
+
}
|
55
|
+
const transaction = Sentry.startTransaction({
|
56
|
+
name: `${reqMethod} ${reqUrl}`,
|
57
|
+
op: "http.server",
|
58
|
+
...traceparentData
|
59
|
+
});
|
60
|
+
ctx.__sentry_transaction = transaction;
|
61
|
+
Sentry.getCurrentHub().configureScope((scope) => {
|
62
|
+
scope.setSpan(transaction);
|
63
|
+
});
|
64
|
+
ctx.res.on("finish", () => {
|
65
|
+
setImmediate(() => {
|
66
|
+
if (ctx._matchedRoute) {
|
67
|
+
const mountPath = ctx.mountPath || "";
|
68
|
+
transaction.setName(`${reqMethod} ${mountPath}${ctx._matchedRoute}`);
|
69
|
+
}
|
70
|
+
transaction.setHttpStatus(ctx.status);
|
71
|
+
transaction.finish();
|
72
|
+
});
|
73
|
+
});
|
74
|
+
await next();
|
75
|
+
};
|
76
|
+
}
|
77
|
+
function sentry(dsn) {
|
78
|
+
debug("Initializing Sentry");
|
79
|
+
Sentry.init({
|
80
|
+
dsn,
|
81
|
+
integrations: [
|
82
|
+
// Automatically instrument Node.js libraries and frameworks
|
83
|
+
...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
|
84
|
+
new ProfilingIntegration()
|
85
|
+
],
|
86
|
+
// Performance Monitoring
|
87
|
+
tracesSampleRate: 1,
|
88
|
+
// Set sampling rate for profiling - this is relative to tracesSampleRate
|
89
|
+
profilesSampleRate: 1
|
90
|
+
});
|
91
|
+
return compose([errorHandler(), requestHandler(), tracing()]);
|
92
|
+
}
|
93
|
+
|
94
|
+
export {
|
95
|
+
debug,
|
96
|
+
error,
|
97
|
+
sentry
|
98
|
+
};
|
99
|
+
//# sourceMappingURL=chunk-R7UQFYRA.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/koa-middleware/sentry.ts","../src/debug.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\";\nimport { ProfilingIntegration } from \"@sentry/profiling-node\";\nimport { stripUrlQueryAndFragment } from \"@sentry/utils\";\nimport { debug } from \"../debug\";\nimport Koa from \"koa\";\nimport compose from \"koa-compose\";\n\nexport function errorHandler(): Koa.Middleware {\n return async function errorHandlerMiddleware(ctx, next) {\n try {\n await next();\n } catch (err) {\n Sentry.withScope((scope) => {\n scope.addEventProcessor((event) => {\n return Sentry.addRequestDataToEvent(event, ctx.request);\n });\n Sentry.captureException(err);\n });\n throw err;\n }\n };\n}\n\nexport function requestHandler(): Koa.Middleware {\n return async function requestHandlerMiddleware(ctx, next) {\n await Sentry.runWithAsyncContext(async () => {\n const hub = Sentry.getCurrentHub();\n hub.configureScope((scope) =>\n scope.addEventProcessor((event) =>\n Sentry.addRequestDataToEvent(event, ctx.request, {\n include: {\n user: false,\n },\n }),\n ),\n );\n await next();\n });\n };\n}\n\nexport function tracing(): Koa.Middleware {\n // creates a Sentry transaction per request\n return async function tracingMiddleware(ctx, next) {\n const reqMethod = (ctx.method || \"\").toUpperCase();\n const reqUrl = ctx.url && stripUrlQueryAndFragment(ctx.url);\n\n // Connect to trace of upstream app\n let traceparentData;\n if (ctx.request.get(\"sentry-trace\")) {\n traceparentData = Sentry.extractTraceparentData(ctx.request.get(\"sentry-trace\"));\n }\n\n const transaction = Sentry.startTransaction({\n name: `${reqMethod} ${reqUrl}`,\n op: \"http.server\",\n ...traceparentData,\n });\n\n ctx.__sentry_transaction = transaction;\n\n // We put the transaction on the scope so users can attach children to it\n Sentry.getCurrentHub().configureScope((scope) => {\n scope.setSpan(transaction);\n });\n\n ctx.res.on(\"finish\", () => {\n // Push `transaction.finish` to the next event loop so open spans have a chance to finish before the transaction closes\n setImmediate(() => {\n // If you're using koa router, set the matched route as transaction name\n if (ctx._matchedRoute) {\n const mountPath = ctx.mountPath || \"\";\n transaction.setName(`${reqMethod} ${mountPath}${ctx._matchedRoute}`);\n }\n\n transaction.setHttpStatus(ctx.status);\n transaction.finish();\n });\n });\n\n await next();\n };\n}\n\nexport function sentry(dsn: string): Koa.Middleware {\n debug(\"Initializing Sentry\");\n Sentry.init({\n dsn,\n integrations: [\n // Automatically instrument Node.js libraries and frameworks\n ...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),\n new ProfilingIntegration(),\n ],\n // Performance Monitoring\n tracesSampleRate: 1.0,\n // Set sampling rate for profiling - this is relative to tracesSampleRate\n profilesSampleRate: 1.0,\n });\n\n return compose([errorHandler(), requestHandler(), tracing()]);\n}\n","import createDebug from \"debug\";\n\nexport const debug = createDebug(\"mud:store-indexer\");\nexport const error = createDebug(\"mud:store-indexer\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n"],"mappings":"AAAA,
|
1
|
+
{"version":3,"sources":["../src/koa-middleware/sentry.ts","../src/debug.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\";\nimport { ProfilingIntegration } from \"@sentry/profiling-node\";\nimport { stripUrlQueryAndFragment } from \"@sentry/utils\";\nimport { debug } from \"../debug\";\nimport Koa from \"koa\";\nimport compose from \"koa-compose\";\n\nexport function errorHandler(): Koa.Middleware {\n return async function errorHandlerMiddleware(ctx, next) {\n try {\n await next();\n } catch (err) {\n Sentry.withScope((scope) => {\n scope.addEventProcessor((event) => {\n return Sentry.addRequestDataToEvent(event, ctx.request);\n });\n Sentry.captureException(err);\n });\n throw err;\n }\n };\n}\n\nexport function requestHandler(): Koa.Middleware {\n return async function requestHandlerMiddleware(ctx, next) {\n await Sentry.runWithAsyncContext(async () => {\n const hub = Sentry.getCurrentHub();\n hub.configureScope((scope) =>\n scope.addEventProcessor((event) =>\n Sentry.addRequestDataToEvent(event, ctx.request, {\n include: {\n user: false,\n },\n }),\n ),\n );\n await next();\n });\n };\n}\n\nexport function tracing(): Koa.Middleware {\n // creates a Sentry transaction per request\n return async function tracingMiddleware(ctx, next) {\n const reqMethod = (ctx.method || \"\").toUpperCase();\n const reqUrl = ctx.url && stripUrlQueryAndFragment(ctx.url);\n\n // Connect to trace of upstream app\n let traceparentData;\n if (ctx.request.get(\"sentry-trace\")) {\n traceparentData = Sentry.extractTraceparentData(ctx.request.get(\"sentry-trace\"));\n }\n\n const transaction = Sentry.startTransaction({\n name: `${reqMethod} ${reqUrl}`,\n op: \"http.server\",\n ...traceparentData,\n });\n\n ctx.__sentry_transaction = transaction;\n\n // We put the transaction on the scope so users can attach children to it\n Sentry.getCurrentHub().configureScope((scope) => {\n scope.setSpan(transaction);\n });\n\n ctx.res.on(\"finish\", () => {\n // Push `transaction.finish` to the next event loop so open spans have a chance to finish before the transaction closes\n setImmediate(() => {\n // If you're using koa router, set the matched route as transaction name\n if (ctx._matchedRoute) {\n const mountPath = ctx.mountPath || \"\";\n transaction.setName(`${reqMethod} ${mountPath}${ctx._matchedRoute}`);\n }\n\n transaction.setHttpStatus(ctx.status);\n transaction.finish();\n });\n });\n\n await next();\n };\n}\n\nexport function sentry(dsn: string): Koa.Middleware {\n debug(\"Initializing Sentry\");\n Sentry.init({\n dsn,\n integrations: [\n // Automatically instrument Node.js libraries and frameworks\n ...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),\n new ProfilingIntegration(),\n ],\n // Performance Monitoring\n tracesSampleRate: 1.0,\n // Set sampling rate for profiling - this is relative to tracesSampleRate\n profilesSampleRate: 1.0,\n });\n\n return compose([errorHandler(), requestHandler(), tracing()]);\n}\n","import createDebug from \"debug\";\n\nexport const debug = createDebug(\"mud:store-indexer\");\nexport const error = createDebug(\"mud:store-indexer\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n"],"mappings":";AAAA,YAAY,YAAY;AACxB,SAAS,4BAA4B;AACrC,SAAS,gCAAgC;;;ACFzC,OAAO,iBAAiB;AAEjB,IAAM,QAAQ,YAAY,mBAAmB;AAC7C,IAAM,QAAQ,YAAY,mBAAmB;AAGpD,MAAM,MAAM,QAAQ,MAAM,KAAK,OAAO;AAGtC,MAAM,MAAM,QAAQ,MAAM,KAAK,OAAO;;;ADJtC,OAAO,aAAa;A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IAAI,eAAe;AACrB,gBAAM,YAAY,IAAI,aAAa;AACnC,sBAAY,QAAQ,GAAG,SAAS,IAAI,SAAS,GAAG,IAAI,aAAa,EAAE;AAAA,QACrE;AAEA,oBAAY,cAAc,IAAI,MAAM;AACpC,oBAAY,OAAO;AAAA,MACrB,CAAC;AAAA,IACH,CAAC;AAED,UAAM,KAAK;AAAA,EACb;AACF;AAEO,SAAS,OAAO,KAA6B;AAClD,QAAM,qBAAqB;AAC3B,EAAO,YAAK;AAAA,IACV;AAAA,IACA,cAAc;AAAA;AAAA,MAEZ,GAAU,yDAAkD;AAAA,MAC5D,IAAI,qBAAqB;AAAA,IAC3B;AAAA;AAAA,IAEA,kBAAkB;AAAA;AAAA,IAElB,oBAAoB;AAAA,EACtB,CAAC;AAED,SAAO,QAAQ,CAAC,aAAa,GAAG,eAAe,GAAG,QAAQ,CAAC,CAAC;AAC9D;","names":[]}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
// src/koa-middleware/healthcheck.ts
|
2
|
+
function healthcheck({ isHealthy, isReady } = {}) {
|
3
|
+
return async function healthcheckMiddleware(ctx, next) {
|
4
|
+
if (ctx.path === "/healthz") {
|
5
|
+
if (isHealthy == null || isHealthy()) {
|
6
|
+
ctx.status = 200;
|
7
|
+
ctx.body = "healthy";
|
8
|
+
} else {
|
9
|
+
ctx.status = 503;
|
10
|
+
ctx.body = "not healthy";
|
11
|
+
}
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
if (ctx.path === "/readyz") {
|
15
|
+
if (isReady == null || isReady()) {
|
16
|
+
ctx.status = 200;
|
17
|
+
ctx.body = "ready";
|
18
|
+
} else {
|
19
|
+
ctx.status = 503;
|
20
|
+
ctx.body = "not ready";
|
21
|
+
}
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
await next();
|
25
|
+
};
|
26
|
+
}
|
27
|
+
|
28
|
+
export {
|
29
|
+
healthcheck
|
30
|
+
};
|
31
|
+
//# sourceMappingURL=chunk-SJLOWI5M.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/koa-middleware/healthcheck.ts"],"sourcesContent":["import { Middleware } from \"koa\";\n\ntype HealthcheckOptions = {\n isHealthy?: () => boolean;\n isReady?: () => boolean;\n};\n\n/**\n * Middleware to add Kubernetes healthcheck endpoints\n */\nexport function healthcheck({ isHealthy, isReady }: HealthcheckOptions = {}): Middleware {\n return async function healthcheckMiddleware(ctx, next): Promise<void> {\n if (ctx.path === \"/healthz\") {\n if (isHealthy == null || isHealthy()) {\n ctx.status = 200;\n ctx.body = \"healthy\";\n } else {\n ctx.status = 503;\n ctx.body = \"not healthy\";\n }\n return;\n }\n\n if (ctx.path === \"/readyz\") {\n if (isReady == null || isReady()) {\n ctx.status = 200;\n ctx.body = \"ready\";\n } else {\n ctx.status = 503;\n ctx.body = \"not ready\";\n }\n return;\n }\n\n await next();\n };\n}\n"],"mappings":"AAUO,
|
1
|
+
{"version":3,"sources":["../src/koa-middleware/healthcheck.ts"],"sourcesContent":["import { Middleware } from \"koa\";\n\ntype HealthcheckOptions = {\n isHealthy?: () => boolean;\n isReady?: () => boolean;\n};\n\n/**\n * Middleware to add Kubernetes healthcheck endpoints\n */\nexport function healthcheck({ isHealthy, isReady }: HealthcheckOptions = {}): Middleware {\n return async function healthcheckMiddleware(ctx, next): Promise<void> {\n if (ctx.path === \"/healthz\") {\n if (isHealthy == null || isHealthy()) {\n ctx.status = 200;\n ctx.body = \"healthy\";\n } else {\n ctx.status = 503;\n ctx.body = \"not healthy\";\n }\n return;\n }\n\n if (ctx.path === \"/readyz\") {\n if (isReady == null || isReady()) {\n ctx.status = 200;\n ctx.body = \"ready\";\n } else {\n ctx.status = 503;\n ctx.body = \"not ready\";\n }\n return;\n }\n\n await next();\n };\n}\n"],"mappings":";AAUO,SAAS,YAAY,EAAE,WAAW,QAAQ,IAAwB,CAAC,GAAe;AACvF,SAAO,eAAe,sBAAsB,KAAK,MAAqB;AACpE,QAAI,IAAI,SAAS,YAAY;AAC3B,UAAI,aAAa,QAAQ,UAAU,GAAG;AACpC,YAAI,SAAS;AACb,YAAI,OAAO;AAAA,MACb,OAAO;AACL,YAAI,SAAS;AACb,YAAI,OAAO;AAAA,MACb;AACA;AAAA,IACF;AAEA,QAAI,IAAI,SAAS,WAAW;AAC1B,UAAI,WAAW,QAAQ,QAAQ,GAAG;AAChC,YAAI,SAAS;AACb,YAAI,OAAO;AAAA,MACb,OAAO;AACL,YAAI,SAAS;AACb,YAAI,OAAO;AAAA,MACb;AACA;AAAA,IACF;AAEA,UAAM,KAAK;AAAA,EACb;AACF;","names":[]}
|
package/dist/index.cjs
ADDED
package/dist/index.d.cts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@latticexyz/store-indexer",
|
3
|
-
"version": "2.2.18-
|
3
|
+
"version": "2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2",
|
4
4
|
"description": "Minimal Typescript indexer for Store",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -10,7 +10,16 @@
|
|
10
10
|
"license": "MIT",
|
11
11
|
"type": "module",
|
12
12
|
"exports": {
|
13
|
-
".":
|
13
|
+
".": {
|
14
|
+
"import": {
|
15
|
+
"import": "./dist/index.js",
|
16
|
+
"types": "./dist/index.d.ts"
|
17
|
+
},
|
18
|
+
"require": {
|
19
|
+
"require": "./dist/index.cjs",
|
20
|
+
"types": "./dist/index.d.cts"
|
21
|
+
}
|
22
|
+
}
|
14
23
|
},
|
15
24
|
"typesVersions": {
|
16
25
|
"*": {
|
@@ -50,11 +59,11 @@
|
|
50
59
|
"superjson": "^1.12.4",
|
51
60
|
"trpc-koa-adapter": "^1.1.3",
|
52
61
|
"zod": "3.23.8",
|
53
|
-
"@latticexyz/block-logs-stream": "2.2.18-
|
54
|
-
"@latticexyz/common": "2.2.18-
|
55
|
-
"@latticexyz/protocol-parser": "2.2.18-
|
56
|
-
"@latticexyz/store": "2.2.18-
|
57
|
-
"@latticexyz/store-sync": "2.2.18-
|
62
|
+
"@latticexyz/block-logs-stream": "2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2",
|
63
|
+
"@latticexyz/common": "2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2",
|
64
|
+
"@latticexyz/protocol-parser": "2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2",
|
65
|
+
"@latticexyz/store": "2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2",
|
66
|
+
"@latticexyz/store-sync": "2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2"
|
58
67
|
},
|
59
68
|
"devDependencies": {
|
60
69
|
"@types/accepts": "^1.3.7",
|
@@ -65,8 +74,7 @@
|
|
65
74
|
"@types/koa__cors": "^4.0.3",
|
66
75
|
"@types/koa__router": "^12.0.4",
|
67
76
|
"concurrently": "^8.2.2",
|
68
|
-
"viem": "2.21.19"
|
69
|
-
"vitest": "0.34.6"
|
77
|
+
"viem": "2.21.19"
|
70
78
|
},
|
71
79
|
"peerDependencies": {
|
72
80
|
"viem": "2.x"
|
package/dist/chunk-7O2ZWWUX.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
function l({isHealthy:a,isReady:t}={}){return async function(e,o){if(e.path==="/healthz"){a==null||a()?(e.status=200,e.body="healthy"):(e.status=503,e.body="not healthy");return}if(e.path==="/readyz"){t==null||t()?(e.status=200,e.body="ready"):(e.status=503,e.body="not ready");return}await o()}}export{l as a};
|
2
|
-
//# sourceMappingURL=chunk-7O2ZWWUX.js.map
|
package/dist/chunk-AYPBOJNL.js
DELETED
package/dist/chunk-ED45N3IT.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
import e from"prom-client";function u({isHealthy:i,isReady:a,getLatestStoredBlockNumber:s,getDistanceFromFollowBlock:l,followBlockTag:o}={}){if(e.collectDefaultMetrics(),i!=null&&new e.Gauge({name:"health_status",help:"Health status (0 = unhealthy, 1 = healthy)",collect(){this.set(Number(i()))}}),a!=null&&new e.Gauge({name:"readiness_status",help:"Readiness status (whether the service is ready to receive requests, 0 = not ready, 1 = ready)",collect(){this.set(Number(a()))}}),s!=null&&new e.Gauge({name:"latest_stored_block_number",help:"Latest block number stored in the database",async collect(){this.set(Number(await s()))}}),o!=null){let n=new e.Gauge({name:"follow_block_tag",help:"Block tag the indexer is following (0 = finalized, 1 = safe, 2 = latest)"}),t={finalized:0,safe:1,latest:2};n.set(t[o])}return l!=null&&new e.Gauge({name:"distance_from_follow_block",help:"Block distance from the block tag this the indexer is following",async collect(){this.set(Number(await l()))}}),async function(t,r){if(t.path==="/metrics"){t.status=200,t.body=await e.register.metrics();return}await r()}}export{u as a};
|
2
|
-
//# sourceMappingURL=chunk-ED45N3IT.js.map
|
package/dist/chunk-JDWVOODJ.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
import*as e from"@sentry/node";import{ProfilingIntegration as m}from"@sentry/profiling-node";import{stripUrlQueryAndFragment as l}from"@sentry/utils";import c from"debug";var d=c("mud:store-indexer"),p=c("mud:store-indexer");d.log=console.debug.bind(console);p.log=console.error.bind(console);import f from"koa-compose";function y(){return async function(r,o){try{await o()}catch(t){throw e.withScope(a=>{a.addEventProcessor(n=>e.addRequestDataToEvent(n,r.request)),e.captureException(t)}),t}}}function g(){return async function(r,o){await e.runWithAsyncContext(async()=>{e.getCurrentHub().configureScope(a=>a.addEventProcessor(n=>e.addRequestDataToEvent(n,r.request,{include:{user:!1}}))),await o()})}}function S(){return async function(r,o){let t=(r.method||"").toUpperCase(),a=r.url&&l(r.url),n;r.request.get("sentry-trace")&&(n=e.extractTraceparentData(r.request.get("sentry-trace")));let i=e.startTransaction({name:`${t} ${a}`,op:"http.server",...n});r.__sentry_transaction=i,e.getCurrentHub().configureScope(u=>{u.setSpan(i)}),r.res.on("finish",()=>{setImmediate(()=>{if(r._matchedRoute){let u=r.mountPath||"";i.setName(`${t} ${u}${r._matchedRoute}`)}i.setHttpStatus(r.status),i.finish()})}),await o()}}function v(s){return d("Initializing Sentry"),e.init({dsn:s,integrations:[...e.autoDiscoverNodePerformanceMonitoringIntegrations(),new m],tracesSampleRate:1,profilesSampleRate:1}),f([y(),g(),S()])}export{d as a,p as b,v as c};
|
2
|
-
//# sourceMappingURL=chunk-JDWVOODJ.js.map
|
package/dist/chunk-O2SDU7EQ.js
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
import{isHex as t}from"viem";import{z as e,ZodError as i}from"zod";var _=e.object({HOST:e.string().default("0.0.0.0"),PORT:e.coerce.number().positive().default(3001)}),T=e.intersection(e.object({FOLLOW_BLOCK_TAG:e.enum(["latest","safe","finalized"]).default("safe"),START_BLOCK:e.coerce.bigint().nonnegative().default(0n),MAX_BLOCK_RANGE:e.coerce.bigint().positive().default(1000n),POLLING_INTERVAL:e.coerce.number().positive().default(1e3),STORE_ADDRESS:e.string().optional().transform(n=>n===""?void 0:n).refine(s),INTERNAL__VALIDATE_BLOCK_RANGE:e.string().optional().transform(n=>n==="true"||n==="1")}),e.union([e.object({RPC_HTTP_URL:e.string(),RPC_WS_URL:e.string().optional()}),e.object({RPC_HTTP_URL:e.string().optional(),RPC_WS_URL:e.string()})]));function u(n){try{return n.parse(process.env)}catch(r){if(r instanceof i){let{...o}=r.format();console.error(`
|
2
|
-
Missing or invalid environment variables:
|
3
|
-
|
4
|
-
${Object.keys(o).join(`
|
5
|
-
`)}
|
6
|
-
`),process.exit(1)}throw r}}function s(n){return n===void 0||t(n)}export{_ as a,T as b,u as c};
|
7
|
-
//# sourceMappingURL=chunk-O2SDU7EQ.js.map
|
package/dist/chunk-R7HX5BT2.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
import{Stream as a}from"node:stream";import c from"accepts";import{createBrotliCompress as p,createDeflate as m,createGzip as f}from"node:zlib";import{includes as l}from"@latticexyz/common/utils";var d={br:p,gzip:f,deflate:m},i=Object.keys(d);function b(o,s){let e=0;return o.on("data",n=>{e+=n.length,e>s&&(e=0,o.flush())}),o}function E({flushThreshold:o=1024*4}={}){return async function(e,n){e.vary("Accept-Encoding"),await n();let r=c(e.req).encoding(i);if(!l(i,r))return;let t=b(d[r](),o);e.set("Content-Encoding",r),e.body=e.body instanceof a?e.body.pipe(t):t.end(e.body)}}export{E as a};
|
2
|
-
//# sourceMappingURL=chunk-R7HX5BT2.js.map
|
package/dist/chunk-YQ7E5W26.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
import{createClient as n,fallback as o,http as e,webSocket as a}from"viem";import{isDefined as _}from"@latticexyz/common/utils";import{getChainId as c}from"viem/actions";async function f(t){if(t.INTERNAL__VALIDATE_BLOCK_RANGE){let i=t.RPC_HTTP_URL;if(!i)throw new Error("Must provide RPC_HTTP_URL when using INTERNAL__VALIDATE_BLOCK_RANGE.");return{internal_clientOptions:{chain:{id:await c(n({transport:e(i)})),name:"Unknown",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:[i]}}},pollingInterval:t.POLLING_INTERVAL,validateBlockRange:t.INTERNAL__VALIDATE_BLOCK_RANGE}}}let r=o([t.RPC_WS_URL?a(t.RPC_WS_URL):void 0,t.RPC_HTTP_URL?e(t.RPC_HTTP_URL):void 0].filter(_));return{publicClient:n({transport:r,pollingInterval:t.POLLING_INTERVAL})}}export{f as a};
|
2
|
-
//# sourceMappingURL=chunk-YQ7E5W26.js.map
|
package/dist/metrics-4BMCDEZZ.js
DELETED
File without changes
|
File without changes
|
File without changes
|