From 51e3945f34e750aaa04afe6e8497d5c1c8f486c1 Mon Sep 17 00:00:00 2001 From: Kaspar Kallas Date: Thu, 26 Oct 2023 19:34:11 +0000 Subject: [PATCH] rename tracker to verification --- apps/backend/src/app.module.ts | 4 ++-- .../payment-tracker.processor.spec.ts | 18 ------------------ .../payment-tracker.service.spec.ts | 18 ------------------ .../payment-verification.module.ts} | 12 ++++++------ .../payment-verification.processor.spec.ts | 18 ++++++++++++++++++ .../payment-verification.processor.ts} | 12 ++++++------ .../payment-verification.queue.ts} | 4 ++-- .../payment-verification.service.spec.ts | 18 ++++++++++++++++++ .../payment-verification.service.ts} | 10 +++++----- .../queue-dashboard/queue-dashboard.module.ts | 10 +++++----- .../stripe-listener/stripe-listener.module.ts | 4 ++-- .../stripe-listener.processor.ts | 8 ++++---- 12 files changed, 68 insertions(+), 68 deletions(-) delete mode 100644 apps/backend/src/payment-tracker/payment-tracker.processor.spec.ts delete mode 100644 apps/backend/src/payment-tracker/payment-tracker.service.spec.ts rename apps/backend/src/{payment-tracker/payment-tracker.module.ts => payment-verification/payment-verification.module.ts} (54%) create mode 100644 apps/backend/src/payment-verification/payment-verification.processor.spec.ts rename apps/backend/src/{payment-tracker/payment-tracker.processor.ts => payment-verification/payment-verification.processor.ts} (94%) rename apps/backend/src/{payment-tracker/payment-tracker.queue.ts => payment-verification/payment-verification.queue.ts} (64%) create mode 100644 apps/backend/src/payment-verification/payment-verification.service.spec.ts rename apps/backend/src/{payment-tracker/payment-tracker.service.ts => payment-verification/payment-verification.service.ts} (76%) diff --git a/apps/backend/src/app.module.ts b/apps/backend/src/app.module.ts index 9c68845..25ff5a4 100644 --- a/apps/backend/src/app.module.ts +++ b/apps/backend/src/app.module.ts @@ -5,7 +5,7 @@ import { BullModule } from '@nestjs/bullmq'; import { QueueDashboardModule } from './queue-dashboard/queue-dashboard.module'; import { CheckoutSessionModule } from './checkout-session/checkout-session.module'; import { StripeListenerModule } from './stripe-listener/stripe-listener.module'; -import { PaymentTrackerModule } from './payment-tracker/payment-tracker.module'; +import { PaymentVerificationModule } from './payment-verification/payment-verification.module'; import { SuperTokenAccountingModule } from './super-token-accounting/super-token-accounting.module'; import { StripeToSuperfluidModule } from './stripe-to-superfluid/stripe-to-superfluid.module'; import { HealthModule } from './health/health.module'; @@ -44,7 +44,7 @@ const registerBullModule = () => QueueDashboardModule, CheckoutSessionModule, StripeListenerModule, - PaymentTrackerModule, + PaymentVerificationModule, SuperTokenAccountingModule, StripeToSuperfluidModule, HealthModule, diff --git a/apps/backend/src/payment-tracker/payment-tracker.processor.spec.ts b/apps/backend/src/payment-tracker/payment-tracker.processor.spec.ts deleted file mode 100644 index 98d0d52..0000000 --- a/apps/backend/src/payment-tracker/payment-tracker.processor.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { PaymentTrackerProcessor } from './payment-tracker.processor'; - -describe('InvoicePaymentTrackerService', () => { - let service: PaymentTrackerProcessor; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - providers: [PaymentTrackerProcessor], - }).compile(); - - service = module.get(PaymentTrackerProcessor); - }); - - it('should be defined', () => { - expect(service).toBeDefined(); - }); -}); diff --git a/apps/backend/src/payment-tracker/payment-tracker.service.spec.ts b/apps/backend/src/payment-tracker/payment-tracker.service.spec.ts deleted file mode 100644 index 0b75ea8..0000000 --- a/apps/backend/src/payment-tracker/payment-tracker.service.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { PaymentTrackerService as PaymentTrackerService } from './payment-tracker.service'; - -describe('InvoicePaymentTrackerService', () => { - let service: PaymentTrackerService; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - providers: [PaymentTrackerService], - }).compile(); - - service = module.get(PaymentTrackerService); - }); - - it('should be defined', () => { - expect(service).toBeDefined(); - }); -}); diff --git a/apps/backend/src/payment-tracker/payment-tracker.module.ts b/apps/backend/src/payment-verification/payment-verification.module.ts similarity index 54% rename from apps/backend/src/payment-tracker/payment-tracker.module.ts rename to apps/backend/src/payment-verification/payment-verification.module.ts index 741f9b0..8095a8d 100644 --- a/apps/backend/src/payment-tracker/payment-tracker.module.ts +++ b/apps/backend/src/payment-verification/payment-verification.module.ts @@ -1,7 +1,7 @@ import { Module } from '@nestjs/common'; -import { PaymentTrackerProcessor } from './payment-tracker.processor'; -import { PaymentTrackerService } from './payment-tracker.service'; -import { registerQueueModules } from './payment-tracker.queue'; +import { PaymentVerificationProcessor } from './payment-verification.processor'; +import { PaymentVerificationService } from './payment-verification.service'; +import { registerQueueModules } from './payment-verification.queue'; import { registerStripeModule } from 'src/stripeModuleConfig'; import { SuperTokenAccountingModule } from 'src/super-token-accounting/super-token-accounting.module'; import { StripeToSuperfluidModule } from 'src/stripe-to-superfluid/stripe-to-superfluid.module'; @@ -13,7 +13,7 @@ import { StripeToSuperfluidModule } from 'src/stripe-to-superfluid/stripe-to-sup SuperTokenAccountingModule, StripeToSuperfluidModule, ], - providers: [PaymentTrackerProcessor, PaymentTrackerService], - exports: [PaymentTrackerService], + providers: [PaymentVerificationProcessor, PaymentVerificationService], + exports: [PaymentVerificationService], }) -export class PaymentTrackerModule {} +export class PaymentVerificationModule {} diff --git a/apps/backend/src/payment-verification/payment-verification.processor.spec.ts b/apps/backend/src/payment-verification/payment-verification.processor.spec.ts new file mode 100644 index 0000000..0036001 --- /dev/null +++ b/apps/backend/src/payment-verification/payment-verification.processor.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { PaymentVerificationProcessor } from './payment-verification.processor'; + +describe('InvoicePaymentVerificationService', () => { + let service: PaymentVerificationProcessor; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [PaymentVerificationProcessor], + }).compile(); + + service = module.get(PaymentVerificationProcessor); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/apps/backend/src/payment-tracker/payment-tracker.processor.ts b/apps/backend/src/payment-verification/payment-verification.processor.ts similarity index 94% rename from apps/backend/src/payment-tracker/payment-tracker.processor.ts rename to apps/backend/src/payment-verification/payment-verification.processor.ts index 82d7aef..1228ddb 100644 --- a/apps/backend/src/payment-tracker/payment-tracker.processor.ts +++ b/apps/backend/src/payment-verification/payment-verification.processor.ts @@ -1,6 +1,6 @@ import { InjectFlowProducer, InjectQueue, Processor, WorkerHost } from '@nestjs/bullmq'; import { FlowProducer, Job } from 'bullmq'; -import { FLOW_PRODUCER_NAME, QUEUE_NAME } from './payment-tracker.queue'; +import { FLOW_PRODUCER_NAME, QUEUE_NAME } from './payment-verification.queue'; import { InjectStripeClient } from '@golevelup/nestjs-stripe'; import Stripe from 'stripe'; import _ from 'lodash'; @@ -15,14 +15,14 @@ import stringify from 'safe-stable-stringify'; import { currencyDecimalMapping } from 'src/currencies'; import { formatUnits } from 'viem'; -export const PAYMENT_TRACKER_JOB_NAME = 'verify-customer-invoice-payments-by-super-token'; +export const PAYMENT_VERIFICATION_JOB_NAME = 'verify-customer-invoice-payments-by-super-token'; -type PaymentTrackerJob = Job< +type PaymentVerificationJob = Job< { stripeCustomerId: string; }, any, - typeof PAYMENT_TRACKER_JOB_NAME + typeof PAYMENT_VERIFICATION_JOB_NAME >; type TRACKED_INVOICE_GROUP_KEY = `${number}:${string}:${string}:${string}`; @@ -32,7 +32,7 @@ const NOT_TRACKED_INVOICE_GROUP_KEY = null; * */ @Processor(QUEUE_NAME) -export class PaymentTrackerProcessor extends WorkerHost { +export class PaymentVerificationProcessor extends WorkerHost { constructor( @InjectQueue(QUEUE_NAME) private readonly queue, @InjectFlowProducer(FLOW_PRODUCER_NAME) @@ -44,7 +44,7 @@ export class PaymentTrackerProcessor extends WorkerHost { super(); } - async process(job: PaymentTrackerJob, token?: string): Promise { + async process(job: PaymentVerificationJob, token?: string): Promise { const customer = await this.stripeClient.customers.retrieve(job.data.stripeCustomerId); // Is stripe already ensuring the customer exists? Should I check for .deleted? if (!customer) { diff --git a/apps/backend/src/payment-tracker/payment-tracker.queue.ts b/apps/backend/src/payment-verification/payment-verification.queue.ts similarity index 64% rename from apps/backend/src/payment-tracker/payment-tracker.queue.ts rename to apps/backend/src/payment-verification/payment-verification.queue.ts index 45d0afc..fe119b4 100644 --- a/apps/backend/src/payment-tracker/payment-tracker.queue.ts +++ b/apps/backend/src/payment-verification/payment-verification.queue.ts @@ -1,7 +1,7 @@ import { BullModule } from '@nestjs/bullmq'; -export const QUEUE_NAME = 'payment-tracker'; -export const FLOW_PRODUCER_NAME = 'payment-tracker-flow-producer'; +export const QUEUE_NAME = 'payment-verification'; +export const FLOW_PRODUCER_NAME = 'payment-verification-flow-producer'; export const registerQueueModules = () => [ BullModule.registerQueue({ diff --git a/apps/backend/src/payment-verification/payment-verification.service.spec.ts b/apps/backend/src/payment-verification/payment-verification.service.spec.ts new file mode 100644 index 0000000..6666758 --- /dev/null +++ b/apps/backend/src/payment-verification/payment-verification.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { PaymentVerificationService as PaymentVerificationService } from './payment-verification.service'; + +describe('InvoicePaymentVerificationService', () => { + let service: PaymentVerificationService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [PaymentVerificationService], + }).compile(); + + service = module.get(PaymentVerificationService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/apps/backend/src/payment-tracker/payment-tracker.service.ts b/apps/backend/src/payment-verification/payment-verification.service.ts similarity index 76% rename from apps/backend/src/payment-tracker/payment-tracker.service.ts rename to apps/backend/src/payment-verification/payment-verification.service.ts index e32196f..ce0f959 100644 --- a/apps/backend/src/payment-tracker/payment-tracker.service.ts +++ b/apps/backend/src/payment-verification/payment-verification.service.ts @@ -1,9 +1,9 @@ import { Injectable, Logger } from '@nestjs/common'; import { Queue } from 'bullmq'; import Stripe from 'stripe'; -import { QUEUE_NAME } from './payment-tracker.queue'; +import { QUEUE_NAME } from './payment-verification.queue'; import { InjectQueue } from '@nestjs/bullmq'; -import { PAYMENT_TRACKER_JOB_NAME } from './payment-tracker.processor'; +import { PAYMENT_VERIFICATION_JOB_NAME } from './payment-verification.processor'; /** * Handles Stripe invoices: @@ -11,7 +11,7 @@ import { PAYMENT_TRACKER_JOB_NAME } from './payment-tracker.processor'; * - produces payment marking jobs */ @Injectable() -export class PaymentTrackerService { +export class PaymentVerificationService { constructor(@InjectQueue(QUEUE_NAME) private readonly queue: Queue) {} /** @@ -26,7 +26,7 @@ export class PaymentTrackerService { const jobs = await this.queue.addBulk( invoices.map((invoice) => ({ - name: PAYMENT_TRACKER_JOB_NAME, + name: PAYMENT_VERIFICATION_JOB_NAME, data: {}, // TODO: Storing the whole invoice seems totally excessive opts: { jobId: invoice.customer as string, // TODO(KK): not quite right @@ -38,4 +38,4 @@ export class PaymentTrackerService { } } -const logger = new Logger(PaymentTrackerService.name); +const logger = new Logger(PaymentVerificationService.name); diff --git a/apps/backend/src/queue-dashboard/queue-dashboard.module.ts b/apps/backend/src/queue-dashboard/queue-dashboard.module.ts index 21489fd..d08ce88 100644 --- a/apps/backend/src/queue-dashboard/queue-dashboard.module.ts +++ b/apps/backend/src/queue-dashboard/queue-dashboard.module.ts @@ -6,13 +6,13 @@ import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common'; import { Queue } from 'bullmq'; import { BasicAuthMiddleware } from './basic-auth.middleware'; import * as CheckoutSession from 'src/checkout-session/checkout-session.queue'; -import * as PaymentTracker from 'src/payment-tracker/payment-tracker.queue'; +import * as PaymentVerification from 'src/payment-verification/payment-verification.queue'; import * as StripeListener from 'src/stripe-listener/stripe-listener.queue'; @Module({ imports: [ CheckoutSession.registerQueueModule(), - ...PaymentTracker.registerQueueModules(), + ...PaymentVerification.registerQueueModules(), StripeListener.registerQueueModule(), ], }) @@ -20,8 +20,8 @@ export class QueueDashboardModule implements NestModule { constructor( @InjectQueue(CheckoutSession.QUEUE_NAME) private readonly checkoutSessionQueue: Queue, - @InjectQueue(PaymentTracker.QUEUE_NAME) - private readonly paymentTrackerQueue: Queue, + @InjectQueue(PaymentVerification.QUEUE_NAME) + private readonly paymentVerificationQueue: Queue, @InjectQueue(StripeListener.QUEUE_NAME) private readonly stripeListenerQueue: Queue, ) {} @@ -34,7 +34,7 @@ export class QueueDashboardModule implements NestModule { serverAdapter, queues: [ new BullMQAdapter(this.checkoutSessionQueue), - new BullMQAdapter(this.paymentTrackerQueue), + new BullMQAdapter(this.paymentVerificationQueue), new BullMQAdapter(this.stripeListenerQueue), ], }); diff --git a/apps/backend/src/stripe-listener/stripe-listener.module.ts b/apps/backend/src/stripe-listener/stripe-listener.module.ts index cec3588..8359db0 100644 --- a/apps/backend/src/stripe-listener/stripe-listener.module.ts +++ b/apps/backend/src/stripe-listener/stripe-listener.module.ts @@ -5,11 +5,11 @@ import { QUEUE_NAME, registerQueueModule } from './stripe-listener.queue'; import { InjectQueue } from '@nestjs/bullmq'; import { Queue } from 'bullmq'; import { StripeModule } from '@golevelup/nestjs-stripe'; -import { PaymentTrackerModule } from 'src/payment-tracker/payment-tracker.module'; +import { PaymentVerificationModule } from 'src/payment-verification/payment-verification.module'; import { registerStripeModule } from 'src/stripeModuleConfig'; @Module({ - imports: [registerQueueModule(), registerStripeModule(), PaymentTrackerModule], + imports: [registerQueueModule(), registerStripeModule(), PaymentVerificationModule], providers: [StripeListenerProcessor], controllers: [StripeListenerController], }) diff --git a/apps/backend/src/stripe-listener/stripe-listener.processor.ts b/apps/backend/src/stripe-listener/stripe-listener.processor.ts index 521c09c..dad7a0e 100644 --- a/apps/backend/src/stripe-listener/stripe-listener.processor.ts +++ b/apps/backend/src/stripe-listener/stripe-listener.processor.ts @@ -4,8 +4,8 @@ import { Job, Queue } from 'bullmq'; import { QUEUE_NAME } from './stripe-listener.queue'; import { InjectStripeClient } from '@golevelup/nestjs-stripe'; import Stripe from 'stripe'; -import { PAYMENT_TRACKER_JOB_NAME } from 'src/payment-tracker/payment-tracker.processor'; -import { PaymentTrackerService } from 'src/payment-tracker/payment-tracker.service'; +import { PAYMENT_VERIFICATION_JOB_NAME } from 'src/payment-verification/payment-verification.processor'; +import { PaymentVerificationService } from 'src/payment-verification/payment-verification.service'; import { DEFAULT_PAGING } from 'src/stripeModuleConfig'; export const STRIPE_LISTENER_JOB_NAME = 'poll-new-invoices'; @@ -25,7 +25,7 @@ type StripeListenerJob = Job< export class StripeListenerProcessor extends WorkerHost { constructor( @InjectStripeClient() private readonly stripeClient: Stripe, - private readonly paymentTrackerService: PaymentTrackerService, + private readonly paymentVerificationService: PaymentVerificationService, ) { super(); } @@ -39,7 +39,7 @@ export class StripeListenerProcessor extends WorkerHost { }) .autoPagingToArray(DEFAULT_PAGING); - await this.paymentTrackerService.handleOpenStripeInvoices(invoices); + await this.paymentVerificationService.handleOpenStripeInvoices(invoices); } }