Rework DittoDB to return an object

This commit is contained in:
Alex Gleason
2024-08-11 19:02:27 -05:00
parent f830271ce2
commit 552de01a17
13 changed files with 86 additions and 74 deletions

View File

@@ -82,7 +82,7 @@ const createTokenController: AppController = async (c) => {
async function getToken(
{ pubkey, secret, relays = [] }: { pubkey: string; secret?: string; relays?: string[] },
): Promise<`token1${string}`> {
const kysely = await DittoDB.getInstance();
const { kysely } = await DittoDB.getInstance();
const token = generateToken();
const serverSeckey = generateSecretKey();

View File

@@ -63,7 +63,7 @@ const statusController: AppController = async (c) => {
const createStatusController: AppController = async (c) => {
const body = await parseBody(c.req.raw);
const result = createStatusSchema.safeParse(body);
const kysely = await DittoDB.getInstance();
const { kysely } = await DittoDB.getInstance();
const store = c.get('store');
if (!result.success) {
@@ -565,9 +565,9 @@ const zappedByController: AppController = async (c) => {
const id = c.req.param('id');
const params = c.get('listPagination');
const store = await Storages.db();
const db = await DittoDB.getInstance();
const { kysely } = await DittoDB.getInstance();
const zaps = await db.selectFrom('event_zaps')
const zaps = await kysely.selectFrom('event_zaps')
.selectAll()
.where('target_event_id', '=', id)
.orderBy('amount_millisats', 'desc')

View File

@@ -189,7 +189,7 @@ async function topicToFilter(
async function getTokenPubkey(token: string): Promise<string | undefined> {
if (token.startsWith('token1')) {
const kysely = await DittoDB.getInstance();
const { kysely } = await DittoDB.getInstance();
const { user_pubkey } = await kysely
.selectFrom('nip46_tokens')