mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Merge branch 'ditto-metrics' into 'main'
Add @ditto/metrics package See merge request soapbox-pub/ditto!668
This commit is contained in:
commit
561efeffde
38 changed files with 221 additions and 228 deletions
|
|
@ -10,7 +10,7 @@ test:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- deno fmt --check
|
- deno fmt --check
|
||||||
- deno lint --allow-import
|
- deno task lint
|
||||||
- deno task check
|
- deno task check
|
||||||
- deno task test --coverage=cov_profile
|
- deno task test --coverage=cov_profile
|
||||||
- deno coverage cov_profile
|
- deno coverage cov_profile
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
{
|
{
|
||||||
|
"version": "1.1.0",
|
||||||
"workspace": [
|
"workspace": [
|
||||||
"./packages/api",
|
"./packages/api",
|
||||||
"./packages/conf",
|
"./packages/conf",
|
||||||
"./packages/db",
|
"./packages/db",
|
||||||
"./packages/ditto"
|
"./packages/ditto",
|
||||||
|
"./packages/metrics"
|
||||||
],
|
],
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"start": "deno run -A --env-file --deny-read=.env packages/ditto/server.ts",
|
"start": "deno run -A --env-file --deny-read=.env packages/ditto/server.ts",
|
||||||
|
|
@ -17,6 +19,7 @@
|
||||||
"debug": "deno run -A --env-file --deny-read=.env --inspect packages/ditto/server.ts",
|
"debug": "deno run -A --env-file --deny-read=.env --inspect packages/ditto/server.ts",
|
||||||
"test": "deno test -A --env-file=.env.test --deny-read=.env --junit-path=./deno-test.xml",
|
"test": "deno test -A --env-file=.env.test --deny-read=.env --junit-path=./deno-test.xml",
|
||||||
"check": "deno check --allow-import .",
|
"check": "deno check --allow-import .",
|
||||||
|
"lint": "deno lint --allow-import",
|
||||||
"nsec": "deno run scripts/nsec.ts",
|
"nsec": "deno run scripts/nsec.ts",
|
||||||
"admin:event": "deno run -A --env-file --deny-read=.env scripts/admin-event.ts",
|
"admin:event": "deno run -A --env-file --deny-read=.env scripts/admin-event.ts",
|
||||||
"admin:role": "deno run -A --env-file --deny-read=.env scripts/admin-role.ts",
|
"admin:role": "deno run -A --env-file --deny-read=.env scripts/admin-role.ts",
|
||||||
|
|
@ -42,7 +45,6 @@
|
||||||
"./public"
|
"./public"
|
||||||
],
|
],
|
||||||
"imports": {
|
"imports": {
|
||||||
"@/": "./packages/ditto/",
|
|
||||||
"@b-fuze/deno-dom": "jsr:@b-fuze/deno-dom@^0.1.47",
|
"@b-fuze/deno-dom": "jsr:@b-fuze/deno-dom@^0.1.47",
|
||||||
"@bradenmacdonald/s3-lite-client": "jsr:@bradenmacdonald/s3-lite-client@^0.7.4",
|
"@bradenmacdonald/s3-lite-client": "jsr:@bradenmacdonald/s3-lite-client@^0.7.4",
|
||||||
"@cashu/cashu-ts": "npm:@cashu/cashu-ts@^2.2.0",
|
"@cashu/cashu-ts": "npm:@cashu/cashu-ts@^2.2.0",
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ import path from 'node:path';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
import { FileMigrationProvider, type Kysely, Migrator } from 'kysely';
|
import { FileMigrationProvider, type Kysely, Migrator } from 'kysely';
|
||||||
|
|
||||||
import { errorJson } from '@/utils/log.ts';
|
|
||||||
|
|
||||||
import { DittoPglite } from './adapters/DittoPglite.ts';
|
import { DittoPglite } from './adapters/DittoPglite.ts';
|
||||||
import { DittoPostgres } from './adapters/DittoPostgres.ts';
|
import { DittoPostgres } from './adapters/DittoPostgres.ts';
|
||||||
|
|
||||||
|
|
@ -51,7 +49,7 @@ export class DittoDB {
|
||||||
msg: 'Migration failed.',
|
msg: 'Migration failed.',
|
||||||
state: 'failed',
|
state: 'failed',
|
||||||
results: results as unknown as JsonValue,
|
results: results as unknown as JsonValue,
|
||||||
error: errorJson(error),
|
error: error instanceof Error ? error : null,
|
||||||
});
|
});
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
|
import { dbQueriesCounter, dbQueryDurationHistogram } from '@ditto/metrics';
|
||||||
import { logi, type LogiValue } from '@soapbox/logi';
|
import { logi, type LogiValue } from '@soapbox/logi';
|
||||||
|
|
||||||
import { dbQueriesCounter, dbQueryDurationHistogram } from '@/metrics.ts';
|
|
||||||
|
|
||||||
import type { Logger } from 'kysely';
|
import type { Logger } from 'kysely';
|
||||||
|
|
||||||
/** Log the SQL for queries. */
|
/** Log the SQL for queries. */
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
import { type Kysely, sql } from 'kysely';
|
import { type Kysely, sql } from 'kysely';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
|
||||||
import { aesEncrypt } from '@/utils/aes.ts';
|
|
||||||
import { getTokenHash } from '@/utils/auth.ts';
|
|
||||||
|
|
||||||
interface DB {
|
interface DB {
|
||||||
nip46_tokens: {
|
nip46_tokens: {
|
||||||
api_token: `token1${string}`;
|
api_token: `token1${string}`;
|
||||||
|
|
@ -32,19 +28,6 @@ export async function up(db: Kysely<DB>): Promise<void> {
|
||||||
.addColumn('created_at', 'timestamp', (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`))
|
.addColumn('created_at', 'timestamp', (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`))
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
// There are probably not that many tokens in the database yet, so this should be fine.
|
|
||||||
const tokens = await db.selectFrom('nip46_tokens').selectAll().execute();
|
|
||||||
|
|
||||||
for (const token of tokens) {
|
|
||||||
await db.insertInto('auth_tokens').values({
|
|
||||||
token_hash: await getTokenHash(token.api_token),
|
|
||||||
pubkey: token.user_pubkey,
|
|
||||||
nip46_sk_enc: await aesEncrypt(Conf.seckey, token.server_seckey),
|
|
||||||
nip46_relays: JSON.parse(token.relays),
|
|
||||||
created_at: token.connected_at,
|
|
||||||
}).execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.schema.dropTable('nip46_tokens').execute();
|
await db.schema.dropTable('nip46_tokens').execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
|
import {
|
||||||
|
streamingClientMessagesCounter,
|
||||||
|
streamingConnectionsGauge,
|
||||||
|
streamingServerMessagesCounter,
|
||||||
|
} from '@ditto/metrics';
|
||||||
import TTLCache from '@isaacs/ttlcache';
|
import TTLCache from '@isaacs/ttlcache';
|
||||||
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import {
|
|
||||||
streamingClientMessagesCounter,
|
|
||||||
streamingConnectionsGauge,
|
|
||||||
streamingServerMessagesCounter,
|
|
||||||
} from '@/metrics.ts';
|
|
||||||
import { MuteListPolicy } from '@/policies/MuteListPolicy.ts';
|
import { MuteListPolicy } from '@/policies/MuteListPolicy.ts';
|
||||||
import { getFeedPubkeys } from '@/queries.ts';
|
import { getFeedPubkeys } from '@/queries.ts';
|
||||||
import { hydrateEvents } from '@/storages/hydrate.ts';
|
import { hydrateEvents } from '@/storages/hydrate.ts';
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
|
import { cachedTranslationsSizeGauge } from '@ditto/metrics';
|
||||||
import { LanguageCode } from 'iso-639-1';
|
import { LanguageCode } from 'iso-639-1';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { AppController } from '@/app.ts';
|
import { AppController } from '@/app.ts';
|
||||||
import { translationCache } from '@/caches/translationCache.ts';
|
import { translationCache } from '@/caches/translationCache.ts';
|
||||||
import { MastodonTranslation } from '@/entities/MastodonTranslation.ts';
|
import { MastodonTranslation } from '@/entities/MastodonTranslation.ts';
|
||||||
import { cachedTranslationsSizeGauge } from '@/metrics.ts';
|
|
||||||
import { getEvent } from '@/queries.ts';
|
import { getEvent } from '@/queries.ts';
|
||||||
import { localeSchema } from '@/schema.ts';
|
import { localeSchema } from '@/schema.ts';
|
||||||
import { parseBody } from '@/utils/api.ts';
|
import { parseBody } from '@/utils/api.ts';
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { register } from 'prom-client';
|
|
||||||
|
|
||||||
import { AppController } from '@/app.ts';
|
|
||||||
import {
|
import {
|
||||||
dbAvailableConnectionsGauge,
|
dbAvailableConnectionsGauge,
|
||||||
dbPoolSizeGauge,
|
dbPoolSizeGauge,
|
||||||
relayPoolRelaysSizeGauge,
|
relayPoolRelaysSizeGauge,
|
||||||
relayPoolSubscriptionsSizeGauge,
|
relayPoolSubscriptionsSizeGauge,
|
||||||
} from '@/metrics.ts';
|
} from '@ditto/metrics';
|
||||||
|
import { register } from 'prom-client';
|
||||||
|
|
||||||
|
import { AppController } from '@/app.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '@/storages.ts';
|
||||||
|
|
||||||
/** Prometheus/OpenMetrics controller. */
|
/** Prometheus/OpenMetrics controller. */
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { type DittoConf } from '@ditto/conf';
|
import { type DittoConf } from '@ditto/conf';
|
||||||
|
import { relayConnectionsGauge, relayEventsCounter, relayMessagesCounter } from '@ditto/metrics';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
import { JsonValue } from '@std/json';
|
import { JsonValue } from '@std/json';
|
||||||
import {
|
import {
|
||||||
|
|
@ -14,7 +15,6 @@ import {
|
||||||
|
|
||||||
import { AppController } from '@/app.ts';
|
import { AppController } from '@/app.ts';
|
||||||
import { relayInfoController } from '@/controllers/nostr/relay-info.ts';
|
import { relayInfoController } from '@/controllers/nostr/relay-info.ts';
|
||||||
import { relayConnectionsGauge, relayEventsCounter, relayMessagesCounter } from '@/metrics.ts';
|
|
||||||
import * as pipeline from '@/pipeline.ts';
|
import * as pipeline from '@/pipeline.ts';
|
||||||
import { RelayError } from '@/RelayError.ts';
|
import { RelayError } from '@/RelayError.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '@/storages.ts';
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "@ditto/ditto",
|
"name": "@ditto/ditto",
|
||||||
"version": "1.1.0",
|
|
||||||
"exports": {},
|
"exports": {},
|
||||||
"imports": {
|
"imports": {
|
||||||
"deno.json": "./deno.json"
|
"@/": "./",
|
||||||
|
"deno.json": "../../deno.json"
|
||||||
},
|
},
|
||||||
"lint": {
|
"lint": {
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
|
import { firehoseEventsCounter } from '@ditto/metrics';
|
||||||
import { Semaphore } from '@core/asyncutil';
|
import { Semaphore } from '@core/asyncutil';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { firehoseEventsCounter } from '@/metrics.ts';
|
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '@/storages.ts';
|
||||||
import { nostrNow } from '@/utils.ts';
|
import { nostrNow } from '@/utils.ts';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,149 +0,0 @@
|
||||||
import { Counter, Gauge, Histogram } from 'prom-client';
|
|
||||||
|
|
||||||
export const httpRequestsCounter = new Counter({
|
|
||||||
name: 'ditto_http_requests_total',
|
|
||||||
help: 'Total number of HTTP requests',
|
|
||||||
labelNames: ['method'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const httpResponsesCounter = new Counter({
|
|
||||||
name: 'ditto_http_responses_total',
|
|
||||||
help: 'Total number of HTTP responses',
|
|
||||||
labelNames: ['method', 'path', 'status'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const httpResponseDurationHistogram = new Histogram({
|
|
||||||
name: 'ditto_http_response_duration_seconds',
|
|
||||||
help: 'Histogram of HTTP response times in seconds',
|
|
||||||
labelNames: ['method', 'path', 'status'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const streamingConnectionsGauge = new Gauge({
|
|
||||||
name: 'ditto_streaming_connections',
|
|
||||||
help: 'Number of active connections to the streaming API',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const streamingServerMessagesCounter = new Counter({
|
|
||||||
name: 'ditto_streaming_server_messages_total',
|
|
||||||
help: 'Total number of messages sent from the streaming API',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const streamingClientMessagesCounter = new Counter({
|
|
||||||
name: 'ditto_streaming_client_messages_total',
|
|
||||||
help: 'Total number of messages received by the streaming API',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const fetchResponsesCounter = new Counter({
|
|
||||||
name: 'ditto_fetch_responses_total',
|
|
||||||
help: 'Total number of fetch requests',
|
|
||||||
labelNames: ['method', 'status'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const firehoseEventsCounter = new Counter({
|
|
||||||
name: 'ditto_firehose_events_total',
|
|
||||||
help: 'Total number of Nostr events processed by the firehose',
|
|
||||||
labelNames: ['kind'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const pipelineEventsCounter = new Counter({
|
|
||||||
name: 'ditto_pipeline_events_total',
|
|
||||||
help: 'Total number of Nostr events processed by the pipeline',
|
|
||||||
labelNames: ['kind'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const policyEventsCounter = new Counter({
|
|
||||||
name: 'ditto_policy_events_total',
|
|
||||||
help: 'Total number of policy OK responses',
|
|
||||||
labelNames: ['ok'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const relayEventsCounter = new Counter({
|
|
||||||
name: 'ditto_relay_events_total',
|
|
||||||
help: 'Total number of EVENT messages processed by the relay',
|
|
||||||
labelNames: ['kind'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const relayMessagesCounter = new Counter({
|
|
||||||
name: 'ditto_relay_messages_total',
|
|
||||||
help: 'Total number of Nostr messages processed by the relay',
|
|
||||||
labelNames: ['verb'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const relayConnectionsGauge = new Gauge({
|
|
||||||
name: 'ditto_relay_connections',
|
|
||||||
help: 'Number of active connections to the relay',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const dbQueriesCounter = new Counter({
|
|
||||||
name: 'ditto_db_queries_total',
|
|
||||||
help: 'Total number of database queries',
|
|
||||||
labelNames: ['kind'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const dbEventsCounter = new Counter({
|
|
||||||
name: 'ditto_db_events_total',
|
|
||||||
help: 'Total number of database inserts',
|
|
||||||
labelNames: ['kind'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const dbPoolSizeGauge = new Gauge({
|
|
||||||
name: 'ditto_db_pool_size',
|
|
||||||
help: 'Number of connections in the database pool',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const dbAvailableConnectionsGauge = new Gauge({
|
|
||||||
name: 'ditto_db_available_connections',
|
|
||||||
help: 'Number of available connections in the database pool',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const dbQueryDurationHistogram = new Histogram({
|
|
||||||
name: 'ditto_db_query_duration_seconds',
|
|
||||||
help: 'Duration of database queries',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const cachedFaviconsSizeGauge = new Gauge({
|
|
||||||
name: 'ditto_cached_favicons_size',
|
|
||||||
help: 'Number of domain favicons in cache',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const cachedLnurlsSizeGauge = new Gauge({
|
|
||||||
name: 'ditto_cached_lnurls_size',
|
|
||||||
help: 'Number of LNURL details in cache',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const cachedNip05sSizeGauge = new Gauge({
|
|
||||||
name: 'ditto_cached_nip05s_size',
|
|
||||||
help: 'Number of NIP-05 results in cache',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const cachedLinkPreviewSizeGauge = new Gauge({
|
|
||||||
name: 'ditto_cached_link_previews_size',
|
|
||||||
help: 'Number of link previews in cache',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const cachedTranslationsSizeGauge = new Gauge({
|
|
||||||
name: 'ditto_cached_translations_size',
|
|
||||||
help: 'Number of translated statuses in cache',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const internalSubscriptionsSizeGauge = new Gauge({
|
|
||||||
name: 'ditto_internal_subscriptions_size',
|
|
||||||
help: "Number of active subscriptions to Ditto's internal relay",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const relayPoolRelaysSizeGauge = new Gauge({
|
|
||||||
name: 'ditto_relay_pool_relays_size',
|
|
||||||
help: 'Number of relays in the relay pool',
|
|
||||||
labelNames: ['ready_state'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const relayPoolSubscriptionsSizeGauge = new Gauge({
|
|
||||||
name: 'ditto_relay_pool_subscriptions_size',
|
|
||||||
help: 'Number of active subscriptions to the relay pool',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const webPushNotificationsCounter = new Counter({
|
|
||||||
name: 'ditto_web_push_notifications_total',
|
|
||||||
help: 'Total number of Web Push notifications sent',
|
|
||||||
labelNames: ['type'],
|
|
||||||
});
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
|
import { httpRequestsCounter, httpResponseDurationHistogram, httpResponsesCounter } from '@ditto/metrics';
|
||||||
import { ScopedPerformance } from '@esroyo/scoped-performance';
|
import { ScopedPerformance } from '@esroyo/scoped-performance';
|
||||||
import { MiddlewareHandler } from '@hono/hono';
|
import { MiddlewareHandler } from '@hono/hono';
|
||||||
|
|
||||||
import { httpRequestsCounter, httpResponseDurationHistogram, httpResponsesCounter } from '@/metrics.ts';
|
|
||||||
|
|
||||||
/** Prometheus metrics middleware that tracks HTTP requests by methods and responses by status code. */
|
/** Prometheus metrics middleware that tracks HTTP requests by methods and responses by status code. */
|
||||||
export const metricsMiddleware: MiddlewareHandler = async (c, next) => {
|
export const metricsMiddleware: MiddlewareHandler = async (c, next) => {
|
||||||
// Start a timer to measure the duration of the response.
|
// Start a timer to measure the duration of the response.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { DittoTables } from '@ditto/db';
|
import { DittoTables } from '@ditto/db';
|
||||||
|
import { pipelineEventsCounter, policyEventsCounter, webPushNotificationsCounter } from '@ditto/metrics';
|
||||||
import { NKinds, NostrEvent, NSchema as n } from '@nostrify/nostrify';
|
import { NKinds, NostrEvent, NSchema as n } from '@nostrify/nostrify';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
import { Kysely, UpdateObject } from 'kysely';
|
import { Kysely, UpdateObject } from 'kysely';
|
||||||
|
|
@ -9,7 +10,6 @@ import { pipelineEncounters } from '@/caches/pipelineEncounters.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { DittoPush } from '@/DittoPush.ts';
|
import { DittoPush } from '@/DittoPush.ts';
|
||||||
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
import { pipelineEventsCounter, policyEventsCounter, webPushNotificationsCounter } from '@/metrics.ts';
|
|
||||||
import { RelayError } from '@/RelayError.ts';
|
import { RelayError } from '@/RelayError.ts';
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||||
import { hydrateEvents } from '@/storages/hydrate.ts';
|
import { hydrateEvents } from '@/storages/hydrate.ts';
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
// deno-lint-ignore-file require-await
|
// deno-lint-ignore-file require-await
|
||||||
import { type DittoDatabase, DittoDB } from '@ditto/db';
|
import { type DittoDatabase, DittoDB } from '@ditto/db';
|
||||||
|
import { internalSubscriptionsSizeGauge } from '@ditto/metrics';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { internalSubscriptionsSizeGauge } from '@/metrics.ts';
|
|
||||||
import { wsUrlSchema } from '@/schema.ts';
|
import { wsUrlSchema } from '@/schema.ts';
|
||||||
import { AdminStore } from '@/storages/AdminStore.ts';
|
import { AdminStore } from '@/storages/AdminStore.ts';
|
||||||
import { EventsDB } from '@/storages/EventsDB.ts';
|
import { EventsDB } from '@/storages/EventsDB.ts';
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import { DittoTables } from '@ditto/db';
|
import { DittoTables } from '@ditto/db';
|
||||||
import { NPostgres, NPostgresSchema } from '@nostrify/db';
|
import { NPostgres, NPostgresSchema } from '@nostrify/db';
|
||||||
|
import { dbEventsCounter } from '@ditto/metrics';
|
||||||
import { NIP50, NKinds, NostrEvent, NostrFilter, NSchema as n } from '@nostrify/nostrify';
|
import { NIP50, NKinds, NostrEvent, NostrFilter, NSchema as n } from '@nostrify/nostrify';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
import { JsonValue } from '@std/json';
|
import { JsonValue } from '@std/json';
|
||||||
|
|
@ -12,7 +13,6 @@ import { nip27 } from 'nostr-tools';
|
||||||
import tldts from 'tldts';
|
import tldts from 'tldts';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { dbEventsCounter } from '@/metrics.ts';
|
|
||||||
import { RelayError } from '@/RelayError.ts';
|
import { RelayError } from '@/RelayError.ts';
|
||||||
import { isNostrId } from '@/utils.ts';
|
import { isNostrId } from '@/utils.ts';
|
||||||
import { abortError } from '@/utils/abort.ts';
|
import { abortError } from '@/utils/abort.ts';
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { DOMParser } from '@b-fuze/deno-dom';
|
import { DOMParser } from '@b-fuze/deno-dom';
|
||||||
import { DittoTables } from '@ditto/db';
|
import { DittoTables } from '@ditto/db';
|
||||||
|
import { cachedFaviconsSizeGauge } from '@ditto/metrics';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
import { safeFetch } from '@soapbox/safe-fetch';
|
import { safeFetch } from '@soapbox/safe-fetch';
|
||||||
import { Kysely } from 'kysely';
|
import { Kysely } from 'kysely';
|
||||||
import tldts from 'tldts';
|
import tldts from 'tldts';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { cachedFaviconsSizeGauge } from '@/metrics.ts';
|
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '@/storages.ts';
|
||||||
import { nostrNow } from '@/utils.ts';
|
import { nostrNow } from '@/utils.ts';
|
||||||
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
|
import { cachedLnurlsSizeGauge } from '@ditto/metrics';
|
||||||
import { NostrEvent } from '@nostrify/nostrify';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
import { LNURL, LNURLDetails } from '@nostrify/nostrify/ln';
|
import { LNURL, LNURLDetails } from '@nostrify/nostrify/ln';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
import { safeFetch } from '@soapbox/safe-fetch';
|
import { safeFetch } from '@soapbox/safe-fetch';
|
||||||
import { JsonValue } from '@std/json';
|
import { JsonValue } from '@std/json';
|
||||||
|
|
||||||
import { cachedLnurlsSizeGauge } from '@/metrics.ts';
|
|
||||||
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
||||||
import { errorJson } from '@/utils/log.ts';
|
import { errorJson } from '@/utils/log.ts';
|
||||||
import { Time } from '@/utils/time.ts';
|
import { Time } from '@/utils/time.ts';
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { nip19 } from 'nostr-tools';
|
import { cachedNip05sSizeGauge } from '@ditto/metrics';
|
||||||
import { NIP05, NStore } from '@nostrify/nostrify';
|
import { NIP05, NStore } from '@nostrify/nostrify';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
import { safeFetch } from '@soapbox/safe-fetch';
|
import { safeFetch } from '@soapbox/safe-fetch';
|
||||||
|
import { nip19 } from 'nostr-tools';
|
||||||
import tldts from 'tldts';
|
import tldts from 'tldts';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { cachedNip05sSizeGauge } from '@/metrics.ts';
|
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '@/storages.ts';
|
||||||
import { errorJson } from '@/utils/log.ts';
|
import { errorJson } from '@/utils/log.ts';
|
||||||
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { cachedLinkPreviewSizeGauge } from '@ditto/metrics';
|
||||||
import TTLCache from '@isaacs/ttlcache';
|
import TTLCache from '@isaacs/ttlcache';
|
||||||
import { logi } from '@soapbox/logi';
|
import { logi } from '@soapbox/logi';
|
||||||
import { safeFetch } from '@soapbox/safe-fetch';
|
import { safeFetch } from '@soapbox/safe-fetch';
|
||||||
|
|
@ -6,7 +7,6 @@ import { unfurl } from 'unfurl.js';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { PreviewCard } from '@/entities/PreviewCard.ts';
|
import { PreviewCard } from '@/entities/PreviewCard.ts';
|
||||||
import { cachedLinkPreviewSizeGauge } from '@/metrics.ts';
|
|
||||||
import { errorJson } from '@/utils/log.ts';
|
import { errorJson } from '@/utils/log.ts';
|
||||||
|
|
||||||
async function unfurlCard(url: string, signal: AbortSignal): Promise<PreviewCard | null> {
|
async function unfurlCard(url: string, signal: AbortSignal): Promise<PreviewCard | null> {
|
||||||
|
|
|
||||||
6
packages/metrics/deno.json
Normal file
6
packages/metrics/deno.json
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name": "@ditto/metrics",
|
||||||
|
"exports": {
|
||||||
|
".": "./metrics.ts"
|
||||||
|
}
|
||||||
|
}
|
||||||
151
packages/metrics/metrics.ts
Normal file
151
packages/metrics/metrics.ts
Normal file
|
|
@ -0,0 +1,151 @@
|
||||||
|
import { Counter, Gauge, Histogram } from 'prom-client';
|
||||||
|
|
||||||
|
const prefix = 'ditto';
|
||||||
|
|
||||||
|
export const httpRequestsCounter: Counter<'method'> = new Counter({
|
||||||
|
name: `${prefix}_http_requests_total`,
|
||||||
|
help: 'Total number of HTTP requests',
|
||||||
|
labelNames: ['method'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const httpResponsesCounter: Counter<'method' | 'path' | 'status'> = new Counter({
|
||||||
|
name: `${prefix}_http_responses_total`,
|
||||||
|
help: 'Total number of HTTP responses',
|
||||||
|
labelNames: ['method', 'path', 'status'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const httpResponseDurationHistogram: Histogram<'method' | 'path' | 'status'> = new Histogram({
|
||||||
|
name: `${prefix}_http_response_duration_seconds`,
|
||||||
|
help: 'Histogram of HTTP response times in seconds',
|
||||||
|
labelNames: ['method', 'path', 'status'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const streamingConnectionsGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_streaming_connections`,
|
||||||
|
help: 'Number of active connections to the streaming API',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const streamingServerMessagesCounter: Counter = new Counter({
|
||||||
|
name: `${prefix}_streaming_server_messages_total`,
|
||||||
|
help: 'Total number of messages sent from the streaming API',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const streamingClientMessagesCounter: Counter = new Counter({
|
||||||
|
name: `${prefix}_streaming_client_messages_total`,
|
||||||
|
help: 'Total number of messages received by the streaming API',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchResponsesCounter: Counter<'method' | 'status'> = new Counter({
|
||||||
|
name: `${prefix}_fetch_responses_total`,
|
||||||
|
help: 'Total number of fetch requests',
|
||||||
|
labelNames: ['method', 'status'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const firehoseEventsCounter: Counter<'kind'> = new Counter({
|
||||||
|
name: `${prefix}_firehose_events_total`,
|
||||||
|
help: 'Total number of Nostr events processed by the firehose',
|
||||||
|
labelNames: ['kind'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const pipelineEventsCounter: Counter<'kind'> = new Counter({
|
||||||
|
name: `${prefix}_pipeline_events_total`,
|
||||||
|
help: 'Total number of Nostr events processed by the pipeline',
|
||||||
|
labelNames: ['kind'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const policyEventsCounter: Counter<'ok'> = new Counter({
|
||||||
|
name: `${prefix}_policy_events_total`,
|
||||||
|
help: 'Total number of policy OK responses',
|
||||||
|
labelNames: ['ok'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const relayEventsCounter: Counter<'kind'> = new Counter({
|
||||||
|
name: `${prefix}_relay_events_total`,
|
||||||
|
help: 'Total number of EVENT messages processed by the relay',
|
||||||
|
labelNames: ['kind'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const relayMessagesCounter: Counter<'verb'> = new Counter({
|
||||||
|
name: `${prefix}_relay_messages_total`,
|
||||||
|
help: 'Total number of Nostr messages processed by the relay',
|
||||||
|
labelNames: ['verb'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const relayConnectionsGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_relay_connections`,
|
||||||
|
help: 'Number of active connections to the relay',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const dbQueriesCounter: Counter<'kind'> = new Counter({
|
||||||
|
name: `${prefix}_db_queries_total`,
|
||||||
|
help: 'Total number of database queries',
|
||||||
|
labelNames: ['kind'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const dbEventsCounter: Counter<'kind'> = new Counter({
|
||||||
|
name: `${prefix}_db_events_total`,
|
||||||
|
help: 'Total number of database inserts',
|
||||||
|
labelNames: ['kind'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const dbPoolSizeGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_db_pool_size`,
|
||||||
|
help: 'Number of connections in the database pool',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const dbAvailableConnectionsGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_db_available_connections`,
|
||||||
|
help: 'Number of available connections in the database pool',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const dbQueryDurationHistogram: Histogram = new Histogram({
|
||||||
|
name: `${prefix}_db_query_duration_seconds`,
|
||||||
|
help: 'Duration of database queries',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const cachedFaviconsSizeGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_cached_favicons_size`,
|
||||||
|
help: 'Number of domain favicons in cache',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const cachedLnurlsSizeGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_cached_lnurls_size`,
|
||||||
|
help: 'Number of LNURL details in cache',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const cachedNip05sSizeGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_cached_nip05s_size`,
|
||||||
|
help: 'Number of NIP-05 results in cache',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const cachedLinkPreviewSizeGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_cached_link_previews_size`,
|
||||||
|
help: 'Number of link previews in cache',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const cachedTranslationsSizeGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_cached_translations_size`,
|
||||||
|
help: 'Number of translated statuses in cache',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const internalSubscriptionsSizeGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_internal_subscriptions_size`,
|
||||||
|
help: "Number of active subscriptions to Ditto's internal relay",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const relayPoolRelaysSizeGauge: Gauge<'ready_state'> = new Gauge({
|
||||||
|
name: `${prefix}_relay_pool_relays_size`,
|
||||||
|
help: 'Number of relays in the relay pool',
|
||||||
|
labelNames: ['ready_state'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const relayPoolSubscriptionsSizeGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_relay_pool_subscriptions_size`,
|
||||||
|
help: 'Number of active subscriptions to the relay pool',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const webPushNotificationsCounter: Counter<'type'> = new Counter({
|
||||||
|
name: `${prefix}_web_push_notifications_total`,
|
||||||
|
help: 'Total number of Web Push notifications sent',
|
||||||
|
labelNames: ['type'],
|
||||||
|
});
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import { JsonParseStream } from '@std/json/json-parse-stream';
|
import { JsonParseStream } from '@std/json/json-parse-stream';
|
||||||
import { TextLineStream } from '@std/streams/text-line-stream';
|
import { TextLineStream } from '@std/streams/text-line-stream';
|
||||||
|
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
import { AdminSigner } from '../packages/ditto/signers/AdminSigner.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
import { type EventStub } from '@/utils/api.ts';
|
import { type EventStub } from '../packages/ditto/utils/api.ts';
|
||||||
import { nostrNow } from '@/utils.ts';
|
import { nostrNow } from '../packages/ditto/utils.ts';
|
||||||
|
|
||||||
const signer = new AdminSigner();
|
const signer = new AdminSigner();
|
||||||
const store = await Storages.db();
|
const store = await Storages.db();
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { NSchema } from '@nostrify/nostrify';
|
import { NSchema } from '@nostrify/nostrify';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
|
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
import { AdminSigner } from '../packages/ditto/signers/AdminSigner.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
import { nostrNow } from '@/utils.ts';
|
import { nostrNow } from '../packages/ditto/utils.ts';
|
||||||
|
|
||||||
const store = await Storages.db();
|
const store = await Storages.db();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { assertEquals, assertThrows } from '@std/assert';
|
import { assertEquals, assertThrows } from '@std/assert';
|
||||||
|
|
||||||
import { buildFilter } from './db-export.ts';
|
import { buildFilter } from './db-export.ts';
|
||||||
|
|
||||||
Deno.test('buildFilter should return an empty filter when no arguments are provided', () => {
|
Deno.test('buildFilter should return an empty filter when no arguments are provided', () => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { Storages } from '@/storages.ts';
|
|
||||||
import { NostrFilter } from '@nostrify/nostrify';
|
import { NostrFilter } from '@nostrify/nostrify';
|
||||||
import { Command, InvalidOptionArgumentError } from 'commander';
|
import { Command, InvalidOptionArgumentError } from 'commander';
|
||||||
|
|
||||||
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
|
|
||||||
interface ExportFilter {
|
interface ExportFilter {
|
||||||
authors?: string[];
|
authors?: string[];
|
||||||
ids?: string[];
|
ids?: string[];
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ import { NostrEvent } from '@nostrify/nostrify';
|
||||||
import { JsonParseStream } from '@std/json/json-parse-stream';
|
import { JsonParseStream } from '@std/json/json-parse-stream';
|
||||||
import { TextLineStream } from '@std/streams/text-line-stream';
|
import { TextLineStream } from '@std/streams/text-line-stream';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '../packages/ditto/config.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
|
|
||||||
const store = await Storages.db();
|
const store = await Storages.db();
|
||||||
const sem = new Semaphore(Conf.pg.poolSize);
|
const sem = new Semaphore(Conf.pg.poolSize);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
|
|
||||||
// This migrates kysely internally.
|
// This migrates kysely internally.
|
||||||
const kysely = await Storages.kysely();
|
const kysely = await Storages.kysely();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { policyWorker } from '@/workers/policy.ts';
|
import { policyWorker } from '../packages/ditto/workers/policy.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
|
|
||||||
const db = await Storages.db();
|
const db = await Storages.db();
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { NostrEvent } from '@nostrify/nostrify';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
import { EventsDB } from '@/storages/EventsDB.ts';
|
import { EventsDB } from '../packages/ditto/storages/EventsDB.ts';
|
||||||
|
|
||||||
const kysely = await Storages.kysely();
|
const kysely = await Storages.kysely();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { Semaphore } from '@core/asyncutil';
|
import { Semaphore } from '@core/asyncutil';
|
||||||
|
|
||||||
import { updateAuthorData } from '@/pipeline.ts';
|
|
||||||
import { Storages } from '@/storages.ts';
|
|
||||||
import { NostrEvent } from '@nostrify/nostrify';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
|
||||||
|
import { updateAuthorData } from '../packages/ditto/pipeline.ts';
|
||||||
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
|
|
||||||
const kysely = await Storages.kysely();
|
const kysely = await Storages.kysely();
|
||||||
const sem = new Semaphore(5);
|
const sem = new Semaphore(5);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { NSchema as n } from '@nostrify/nostrify';
|
import { NSchema as n } from '@nostrify/nostrify';
|
||||||
import { Storages } from '@/storages.ts';
|
|
||||||
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
|
|
||||||
const store = await Storages.db();
|
const store = await Storages.db();
|
||||||
const kysely = await Storages.kysely();
|
const kysely = await Storages.kysely();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '../packages/ditto/config.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
|
|
||||||
const kysely = await Storages.kysely();
|
const kysely = await Storages.kysely();
|
||||||
const statsQuery = kysely.selectFrom('author_stats').select('pubkey');
|
const statsQuery = kysely.selectFrom('author_stats').select('pubkey');
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
import { NostrEvent, NRelay1, NSchema } from '@nostrify/nostrify';
|
import { NostrEvent, NRelay1, NSchema } from '@nostrify/nostrify';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
|
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
|
|
||||||
const store = await Storages.db();
|
const store = await Storages.db();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
|
||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { NostrEvent } from 'nostr-tools';
|
import { NostrEvent } from 'nostr-tools';
|
||||||
import { nostrNow } from '@/utils.ts';
|
|
||||||
import { Conf } from '@/config.ts';
|
import { AdminSigner } from '../packages/ditto/signers/AdminSigner.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
import { nostrNow } from '../packages/ditto/utils.ts';
|
||||||
|
import { Conf } from '../packages/ditto/config.ts';
|
||||||
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
|
|
||||||
function die(code: number, ...args: unknown[]) {
|
function die(code: number, ...args: unknown[]) {
|
||||||
console.error(...args);
|
console.error(...args);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { exists } from '@std/fs/exists';
|
||||||
import { generateSecretKey, nip19 } from 'nostr-tools';
|
import { generateSecretKey, nip19 } from 'nostr-tools';
|
||||||
import question from 'question-deno';
|
import question from 'question-deno';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '../packages/ditto/config.ts';
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log('Hello! Welcome to the Ditto setup tool. We will ask you a few questions to generate a .env file for you.');
|
console.log('Hello! Welcome to the Ditto setup tool. We will ask you a few questions to generate a .env file for you.');
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
|
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '../packages/ditto/storages.ts';
|
||||||
import { refreshAuthorStats } from '@/utils/stats.ts';
|
import { refreshAuthorStats } from '../packages/ditto/utils/stats.ts';
|
||||||
|
|
||||||
let pubkey: string;
|
let pubkey: string;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import {
|
||||||
updateTrendingLinks,
|
updateTrendingLinks,
|
||||||
updateTrendingPubkeys,
|
updateTrendingPubkeys,
|
||||||
updateTrendingZappedEvents,
|
updateTrendingZappedEvents,
|
||||||
} from '@/trends.ts';
|
} from '../packages/ditto/trends.ts';
|
||||||
|
|
||||||
const trendSchema = z.enum(['pubkeys', 'zapped_events', 'events', 'hashtags', 'links']);
|
const trendSchema = z.enum(['pubkeys', 'zapped_events', 'events', 'hashtags', 'links']);
|
||||||
const trends = trendSchema.array().parse(Deno.args);
|
const trends = trendSchema.array().parse(Deno.args);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue