mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor(app.ts): move cron function and startFirehose function to startup.ts
This commit is contained in:
parent
86874e3a08
commit
e8a90c90cb
2 changed files with 16 additions and 10 deletions
10
src/app.ts
10
src/app.ts
|
|
@ -5,9 +5,6 @@ import { logger } from '@hono/hono/logger';
|
||||||
import { NostrEvent, NostrSigner, NStore, NUploader } from '@nostrify/nostrify';
|
import { NostrEvent, NostrSigner, NStore, NUploader } from '@nostrify/nostrify';
|
||||||
import Debug from '@soapbox/stickynotes/debug';
|
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 { Time } from '@/utils/time.ts';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
@ -145,13 +142,6 @@ const app = new Hono<AppEnv>({ strict: false });
|
||||||
|
|
||||||
const debug = Debug('ditto:http');
|
const debug = Debug('ditto:http');
|
||||||
|
|
||||||
if (Conf.firehoseEnabled) {
|
|
||||||
startFirehose();
|
|
||||||
}
|
|
||||||
if (Conf.cronEnabled) {
|
|
||||||
cron();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.use('*', rateLimitMiddleware(300, Time.minutes(5)));
|
app.use('*', rateLimitMiddleware(300, Time.minutes(5)));
|
||||||
|
|
||||||
app.use('/api/*', metricsMiddleware, logger(debug));
|
app.use('/api/*', metricsMiddleware, logger(debug));
|
||||||
|
|
|
||||||
16
src/startup.ts
Normal file
16
src/startup.ts
Normal file
|
|
@ -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();
|
||||||
Loading…
Add table
Reference in a new issue