debug: more modules
This commit is contained in:
parent
2fc9988c06
commit
4e01e8e626
|
@ -6,7 +6,7 @@ import { cidFromUrl } from '@/utils/ipfs.ts';
|
|||
|
||||
/** Delete files that aren't attached to any events. */
|
||||
async function cleanupMedia() {
|
||||
console.log('Deleting orphaned media files...');
|
||||
console.info('Deleting orphaned media files...');
|
||||
|
||||
const until = new Date(Date.now() - Time.minutes(15));
|
||||
const media = await getUnattachedMedia(until);
|
||||
|
@ -22,7 +22,7 @@ async function cleanupMedia() {
|
|||
}
|
||||
}
|
||||
|
||||
console.log(`Removed ${media?.length ?? 0} orphaned media files.`);
|
||||
console.info(`Removed ${media?.length ?? 0} orphaned media files.`);
|
||||
}
|
||||
|
||||
await cleanupMedia();
|
||||
|
|
16
src/db.ts
16
src/db.ts
|
@ -3,7 +3,7 @@ import path from 'node:path';
|
|||
|
||||
import { FileMigrationProvider, Kysely, Migrator, PolySqliteDialect } from '@/deps.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
import { getPragma, setPragma } from '@/pragma.ts';
|
||||
import { setPragma } from '@/pragma.ts';
|
||||
import SqliteWorker from '@/workers/sqlite.ts';
|
||||
|
||||
interface DittoDB {
|
||||
|
@ -89,12 +89,6 @@ await Promise.all([
|
|||
setPragma(db, 'mmap_size', Conf.sqlite.mmapSize),
|
||||
]);
|
||||
|
||||
// Log out PRAGMA values for debugging.
|
||||
['journal_mode', 'synchronous', 'temp_store', 'mmap_size'].forEach(async (pragma) => {
|
||||
const value = await getPragma(db, pragma);
|
||||
console.log(`PRAGMA ${pragma} = ${value};`);
|
||||
});
|
||||
|
||||
const migrator = new Migrator({
|
||||
db,
|
||||
provider: new FileMigrationProvider({
|
||||
|
@ -106,7 +100,7 @@ const migrator = new Migrator({
|
|||
|
||||
/** Migrate the database to the latest version. */
|
||||
async function migrate() {
|
||||
console.log('Running migrations...');
|
||||
console.info('Running migrations...');
|
||||
const results = await migrator.migrateToLatest();
|
||||
|
||||
if (results.error) {
|
||||
|
@ -114,11 +108,11 @@ async function migrate() {
|
|||
Deno.exit(1);
|
||||
} else {
|
||||
if (!results.results?.length) {
|
||||
console.log('Everything up-to-date.');
|
||||
console.info('Everything up-to-date.');
|
||||
} else {
|
||||
console.log('Migrations finished!');
|
||||
console.info('Migrations finished!');
|
||||
for (const { migrationName, status } of results.results!) {
|
||||
console.log(` - ${migrationName}: ${status}`);
|
||||
console.info(` - ${migrationName}: ${status}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,8 +82,8 @@ async function storeEvent(event: Event, data: EventData, opts: StoreEventOpts =
|
|||
return Promise.reject(new RelayError('blocked', 'event was deleted'));
|
||||
} else {
|
||||
await Promise.all([
|
||||
eventsDB.insertEvent(event, data).catch(console.warn),
|
||||
updateStats(event).catch(console.warn),
|
||||
eventsDB.insertEvent(event, data).catch(debug),
|
||||
updateStats(event).catch(debug),
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import { type AppContext } from '@/app.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
import { decryptAdmin, encryptAdmin } from '@/crypto.ts';
|
||||
import { type Event, type EventTemplate, finishEvent, HTTPException } from '@/deps.ts';
|
||||
import { Debug, type Event, type EventTemplate, finishEvent, HTTPException } from '@/deps.ts';
|
||||
import { connectResponseSchema } from '@/schemas/nostr.ts';
|
||||
import { jsonSchema } from '@/schema.ts';
|
||||
import { Sub } from '@/subs.ts';
|
||||
import { eventMatchesTemplate, Time } from '@/utils.ts';
|
||||
import { createAdminEvent } from '@/utils/web.ts';
|
||||
|
||||
const debug = Debug('ditto:sign');
|
||||
|
||||
interface SignEventOpts {
|
||||
/** Target proof-of-work difficulty for the signed event. */
|
||||
pow?: number;
|
||||
|
@ -28,10 +30,12 @@ async function signEvent<K extends number = number>(
|
|||
const header = c.req.header('x-nostr-sign');
|
||||
|
||||
if (seckey) {
|
||||
debug(`Signing Event<${event.kind}> with secret key`);
|
||||
return finishEvent(event, seckey);
|
||||
}
|
||||
|
||||
if (header) {
|
||||
debug(`Signing Event<${event.kind}> with NIP-46`);
|
||||
return await signNostrConnect(event, c, opts);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue