service refactor to namespaces

This commit is contained in:
Michael Dausmann
2024-02-17 10:49:23 +11:00
parent d8f20d9896
commit 23c248a08b
10 changed files with 80 additions and 90 deletions

View File

@@ -1,6 +1,6 @@
import { ACCOUNT_ACCESS } from '~~/prisma/account-access-enum';
import Stripe from 'stripe';
import AccountService from '~~/lib/services/account.service';
import { AccountService } from '~~/lib/services/account.service';
import { AccountWithMembers } from '~~/lib/services/service.types';
const config = useRuntimeConfig();
@@ -14,8 +14,7 @@ export default defineEventHandler(async event => {
`session.post.ts recieved price_id:${price_id}, account_id:${account_id}`
);
const accountService = new AccountService();
const account: AccountWithMembers = await accountService.getAccountById(
const account: AccountWithMembers = await AccountService.getAccountById(
account_id
);
let customer_id: string;
@@ -32,7 +31,7 @@ export default defineEventHandler(async event => {
email: owner?.user.email
});
customer_id = customer.id;
accountService.updateAccountStipeCustomerId(account_id, customer.id);
AccountService.updateAccountStipeCustomerId(account_id, customer.id);
} else {
customer_id = account.stripe_customer_id;
}

View File

@@ -1,5 +1,5 @@
import Stripe from 'stripe';
import AccountService from '~~/lib/services/account.service';
import { AccountService } from '~~/lib/services/account.service';
const config = useRuntimeConfig();
const stripe = new Stripe(config.stripeSecretKey, { apiVersion: '2022-11-15' });
@@ -56,8 +56,6 @@ export default defineEventHandler(async event => {
});
}
const accountService = new AccountService();
let current_period_ends: Date = new Date(
subscription.current_period_end * 1000
);
@@ -68,7 +66,7 @@ export default defineEventHandler(async event => {
console.log(
`updating stripe sub details subscription.current_period_end:${subscription.current_period_end}, subscription.id:${subscription.id}, stripe_product_id:${stripe_product_id}`
);
accountService.updateStripeSubscriptionDetailsForAccount(
AccountService.updateStripeSubscriptionDetailsForAccount(
subscription.customer.toString(),
subscription.id,
current_period_ends,