diff --git a/src/app.ts b/src/app.ts index f9dad138..690862eb 100644 --- a/src/app.ts +++ b/src/app.ts @@ -5,9 +5,6 @@ import { logger } from '@hono/hono/logger'; import { NostrEvent, NostrSigner, NStore, NUploader } from '@nostrify/nostrify'; import Debug from '@soapbox/stickynotes/debug'; -import { Conf } from '@/config.ts'; -import { cron } from '@/cron.ts'; -import { startFirehose } from '@/firehose.ts'; import { Time } from '@/utils/time.ts'; import { @@ -145,13 +142,6 @@ const app = new Hono({ strict: false }); const debug = Debug('ditto:http'); -if (Conf.firehoseEnabled) { - startFirehose(); -} -if (Conf.cronEnabled) { - cron(); -} - app.use('*', rateLimitMiddleware(300, Time.minutes(5))); app.use('/api/*', metricsMiddleware, logger(debug)); diff --git a/src/startup.ts b/src/startup.ts new file mode 100644 index 00000000..4ec75e03 --- /dev/null +++ b/src/startup.ts @@ -0,0 +1,16 @@ +// Starts up applications required to run before the HTTP server is on. + +import { Conf } from '@/config.ts'; +import { createZapSplitsIfNotExists } from '@/utils/zap-split.ts'; +import { cron } from '@/cron.ts'; +import { startFirehose } from '@/firehose.ts'; + +if (Conf.firehoseEnabled) { + startFirehose(); +} + +if (Conf.cronEnabled) { + cron(); +} + +await createZapSplitsIfNotExists();