mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-15 19:34:25 +01:00
Rework DittoDB to return an object
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user