Skip to content

Commit

Permalink
chore: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
flxxyz committed Jun 4, 2023
1 parent 48daa30 commit 7676803
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
networks:
default:
denostr-maintenance:
image: ghcr.io/denostr-protocol/denostr:v0.1.1-maintenance
image: ghcr.io/denostr-protocol/denostr:v0.2.0-maintenance
container_name: denostr-maintenance
environment:
RELAY_PORT: 8008
Expand Down
7 changes: 3 additions & 4 deletions src/@types/repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PassThrough, Stream } from 'stream'

import mongoose from 'mongoose'

import { DatabaseClient, DatabaseTransaction, EventId, Pubkey } from './base.ts'
import { DatabaseTransaction, EventId, Pubkey } from './base.ts'
import { DBEvent, Event } from './event.ts'
import { Invoice } from './invoice.ts'
import { SubscriptionFilter } from './subscription.ts'
Expand All @@ -23,8 +23,8 @@ export interface IEventRepository {
}

export interface IInvoiceRepository {
findById(id: string, client?: DatabaseClient): Promise<Invoice | undefined>
upsert(invoice: Partial<Invoice>, session?: DatabaseTransaction): Promise<number>
findById(id: string): Promise<Invoice | undefined>
upsert(invoice: Partial<Invoice>): Promise<number>
updateStatus(
invoice: Pick<Invoice, 'id' | 'status'>,
session?: DatabaseTransaction,
Expand All @@ -38,7 +38,6 @@ export interface IInvoiceRepository {
findPendingInvoices(
offset?: number,
limit?: number,
client?: DatabaseClient,
): Promise<Invoice[]>
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { GetInvoiceStatusController } from '@/controllers/invoices/get-invoice-status-controller.ts'
import { getReadReplicaDbClient } from '@/database/client.ts'
import { InvoiceRepository } from '@/repositories/invoice-repository.ts'

export const createGetInvoiceStatusController = () => {
const rrDbClient = getReadReplicaDbClient()

const invoiceRepository = new InvoiceRepository(rrDbClient)
const invoiceRepository = new InvoiceRepository()

return new GetInvoiceStatusController(invoiceRepository)
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { createPaymentsService } from '@/factories/payments-service-factory.ts'
import { getMasterDbClient } from '@/database/client.ts'
import { IController } from '@/@types/controllers.ts'
import { InvoiceRepository } from '@/repositories/invoice-repository.ts'
import { LNbitsCallbackController } from '@/controllers/callbacks/lnbits-callback-controller.ts'

export const createLNbitsCallbackController = (): IController => {
return new LNbitsCallbackController(
createPaymentsService(),
new InvoiceRepository(getMasterDbClient()),
new InvoiceRepository(),
)
}
2 changes: 1 addition & 1 deletion src/factories/payments-service-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createSettings } from './settings-factory.ts'

export const createPaymentsService = () => {
const dbClient = getMasterDbClient()
const invoiceRepository = new InvoiceRepository(dbClient)
const invoiceRepository = new InvoiceRepository()
const userRepository = new UserRepository(createSettings)
const paymentsProcessor = createPaymentsProcessor()
const eventRepository = new EventRepository(createSettings)
Expand Down
3 changes: 0 additions & 3 deletions src/repositories/invoice-repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { always, applySpec, ifElse, is, pipe, prop, propSatisfies, toString } from 'ramda'

import { DatabaseClient } from '@/@types/base.ts'
import { DBInvoice, Invoice, InvoiceStatus } from '@/@types/invoice.ts'
import { IInvoiceRepository } from '@/@types/repositories.ts'
import { createLogger } from '@/factories/logger-factory.ts'
Expand All @@ -12,8 +11,6 @@ import { DatabaseTransaction } from '@/@types/base.ts'
const debug = createLogger('invoice-repository')

export class InvoiceRepository implements IInvoiceRepository {
public constructor(private readonly dbClient: DatabaseClient) {}

public async confirmInvoice(
invoiceId: string,
amountPaid: bigint,
Expand Down

0 comments on commit 7676803

Please sign in to comment.