From a7f8c37f9956cff02d17ce5978fe1d8f3e89956d Mon Sep 17 00:00:00 2001 From: Michael Dausmann Date: Tue, 24 Oct 2023 21:18:03 +1100 Subject: [PATCH] prettier fixes #16 --- .prettierignore | 16 ++ .prettierrc.json | 7 + .vscode/settings.json | 6 + components/AppFooter.vue | 8 +- components/AppHeader.vue | 33 ++- components/Modal.vue | 22 +- components/Notifications.client.vue | 36 +-- components/UserAccount/UserAccount.vue | 24 +- .../UserAccount/UserAccountSignout.client.vue | 9 +- .../UserAccount/UserAccountSwitch.client.vue | 18 +- components/modal.type.ts | 2 +- lib/services/account.service.ts | 214 +++++++++++------- lib/services/auth.service.ts | 37 +-- lib/services/errors.ts | 6 +- lib/services/notes.service.ts | 24 +- lib/services/openai.client.ts | 6 +- lib/services/service.types.ts | 44 ++-- lib/services/util.service.ts | 12 +- middleware/auth.ts | 6 +- nuxt.config.ts | 23 +- pages/account.vue | 160 ++++++++++--- pages/cancel.vue | 6 +- pages/dashboard.vue | 70 ++++-- pages/fail.vue | 6 +- pages/forgotpassword.vue | 44 ++-- pages/index.vue | 169 +++++++++----- pages/join/[join_password].vue | 50 ++-- pages/notes/[note_id].vue | 9 +- pages/pricing.vue | 126 +++++++---- pages/privacy.vue | 88 ++++--- pages/resetpassword.vue | 52 +++-- pages/signin.vue | 80 ++++--- pages/signup.vue | 86 ++++--- pages/success.vue | 36 +-- pages/terms.vue | 98 +++++--- plugins/cookieconsent.client.ts | 106 ++++----- plugins/trpcClient.ts | 16 +- prisma/account-access-enum.ts | 8 +- prisma/prisma.client.ts | 6 +- prisma/seed.ts | 34 +-- server/api/note.ts | 14 +- server/api/trpc/[trpc].ts | 8 +- server/defineProtectedEventHandler.ts | 4 +- server/middleware/authContext.ts | 52 +++-- server/routes/create-checkout-session.post.ts | 41 ++-- server/routes/webhook.post.ts | 81 +++++-- server/trpc/context.ts | 16 +- server/trpc/routers/account.router.ts | 182 +++++++++------ server/trpc/routers/app.router.ts | 10 +- server/trpc/routers/auth.router.ts | 15 +- server/trpc/routers/notes.router.ts | 64 ++++-- server/trpc/trpc.ts | 119 ++++++---- stores/account.store.ts | 154 ++++++++----- stores/notes.store.ts | 38 ++-- stores/notify.store.ts | 36 +-- tailwind.config.js | 4 +- 56 files changed, 1706 insertions(+), 935 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc.json create mode 100644 .vscode/settings.json diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..d1fd838 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,16 @@ +CHANGELOG.md +LICENSE +package.json +package-lock.json +node_modules +*.log* +.nuxt +.nitro +.cache +.output +.env +.env_example +dist +junk +prisma/schema.prisma +assets diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..e7d9497 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,7 @@ +{ + "singleQuote": true, + "bracketSameLine": true, + "vueIndentScriptAndStyle": true, + "arrowParens": "avoid", + "trailingComma": "none" +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d4eeef7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[vue]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } +} diff --git a/components/AppFooter.vue b/components/AppFooter.vue index cbd7485..5903f86 100644 --- a/components/AppFooter.vue +++ b/components/AppFooter.vue @@ -1,7 +1,9 @@ diff --git a/components/AppHeader.vue b/components/AppHeader.vue index 48266bb..44a81e2 100644 --- a/components/AppHeader.vue +++ b/components/AppHeader.vue @@ -4,19 +4,34 @@ diff --git a/components/Modal.vue b/components/Modal.vue index f60ade4..dc383ac 100644 --- a/components/Modal.vue +++ b/components/Modal.vue @@ -21,18 +21,18 @@ // props for which buttons to show interface Props { - showOk?: boolean - showCancel?: boolean + showOk?: boolean; + showCancel?: boolean; } const props = withDefaults(defineProps(), { showOk: true, - showCancel: false, - }) + showCancel: false + }); // open event (exposed to parent) const open = () => { modalIsVisible.value = true; - } + }; defineExpose({ open }); // close events emitted on modal close @@ -40,16 +40,20 @@ const closeOk = () => { emit('closeOk'); modalIsVisible.value = false; - } + }; const closeCancel = () => { emit('closeCancel'); modalIsVisible.value = false; - } + }; \ No newline at end of file + diff --git a/components/Notifications.client.vue b/components/Notifications.client.vue index face861..32795e6 100644 --- a/components/Notifications.client.vue +++ b/components/Notifications.client.vue @@ -1,4 +1,3 @@ - \ No newline at end of file + diff --git a/components/UserAccount/UserAccount.vue b/components/UserAccount/UserAccount.vue index 2bfaef3..34cee75 100644 --- a/components/UserAccount/UserAccount.vue +++ b/components/UserAccount/UserAccount.vue @@ -2,8 +2,8 @@ const props = defineProps({ user: { type: Object, - required: true, - }, + required: true + } }); const { user } = props; @@ -13,16 +13,24 @@ - \ No newline at end of file + diff --git a/components/UserAccount/UserAccountSignout.client.vue b/components/UserAccount/UserAccountSignout.client.vue index 509133b..aaa9fdf 100644 --- a/components/UserAccount/UserAccountSignout.client.vue +++ b/components/UserAccount/UserAccountSignout.client.vue @@ -1,20 +1,19 @@ - \ No newline at end of file + diff --git a/components/UserAccount/UserAccountSwitch.client.vue b/components/UserAccount/UserAccountSwitch.client.vue index 2046b8d..32d2aa2 100644 --- a/components/UserAccount/UserAccountSwitch.client.vue +++ b/components/UserAccount/UserAccountSwitch.client.vue @@ -1,21 +1,27 @@ \ No newline at end of file + diff --git a/components/modal.type.ts b/components/modal.type.ts index 2b3d7b2..8a0cfc7 100644 --- a/components/modal.type.ts +++ b/components/modal.type.ts @@ -1,4 +1,4 @@ import { Modal } from '#components'; // seems pretty stoopid that I need to do this in a seperate file but it seems to work -export type ModalType = typeof Modal extends new () => infer T ? T : never; \ No newline at end of file +export type ModalType = typeof Modal extends new () => infer T ? T : never; diff --git a/lib/services/account.service.ts b/lib/services/account.service.ts index d215a6d..f60c15a 100644 --- a/lib/services/account.service.ts +++ b/lib/services/account.service.ts @@ -1,6 +1,13 @@ import { ACCOUNT_ACCESS } from '~~/prisma/account-access-enum'; import prisma_client from '~~/prisma/prisma.client'; -import { accountWithMembers, AccountWithMembers, membershipWithAccount, MembershipWithAccount, membershipWithUser, MembershipWithUser } from './service.types'; +import { + accountWithMembers, + AccountWithMembers, + membershipWithAccount, + MembershipWithAccount, + membershipWithUser, + MembershipWithUser +} from './service.types'; import generator from 'generate-password-ts'; import { UtilService } from './util.service'; import { AccountLimitError } from './errors'; @@ -9,52 +16,62 @@ const config = useRuntimeConfig(); export default class AccountService { async getAccountById(account_id: number): Promise { - return prisma_client.account.findFirstOrThrow({ + return prisma_client.account.findFirstOrThrow({ where: { id: account_id }, ...accountWithMembers }); } - async getAccountByJoinPassword(join_password: string): Promise { - return prisma_client.account.findFirstOrThrow({ + async getAccountByJoinPassword( + join_password: string + ): Promise { + return prisma_client.account.findFirstOrThrow({ where: { join_password }, ...accountWithMembers }); } async getAccountMembers(account_id: number): Promise { - return prisma_client.membership.findMany({ + return prisma_client.membership.findMany({ where: { account_id }, ...membershipWithUser }); - } + } - async updateAccountStipeCustomerId (account_id: number, stripe_customer_id: string){ + async updateAccountStipeCustomerId( + account_id: number, + stripe_customer_id: string + ) { return await prisma_client.account.update({ where: { id: account_id }, data: { - stripe_customer_id, + stripe_customer_id } - }) + }); } - async updateStripeSubscriptionDetailsForAccount (stripe_customer_id: string, stripe_subscription_id: string, current_period_ends: Date, stripe_product_id: string){ + async updateStripeSubscriptionDetailsForAccount( + stripe_customer_id: string, + stripe_subscription_id: string, + current_period_ends: Date, + stripe_product_id: string + ) { const account = await prisma_client.account.findFirstOrThrow({ - where: {stripe_customer_id} + where: { stripe_customer_id } }); - const paid_plan = await prisma_client.plan.findFirstOrThrow({ - where: { stripe_product_id }, + const paid_plan = await prisma_client.plan.findFirstOrThrow({ + where: { stripe_product_id } }); - if(paid_plan.id == account.plan_id){ + if (paid_plan.id == account.plan_id) { // only update sub and period info return await prisma_client.account.update({ where: { id: account.id }, data: { stripe_subscription_id, current_period_ends, - ai_gen_count:0, + ai_gen_count: 0 } }); } else { @@ -70,72 +87,82 @@ export default class AccountService { max_members: paid_plan.max_members, plan_name: paid_plan.name, ai_gen_max_pm: paid_plan.ai_gen_max_pm, - ai_gen_count:0, // I did vacillate on this point ultimately easier to just reset, discussion here https://www.reddit.com/r/SaaS/comments/16e9bew/should_i_reset_usage_counts_on_plan_upgrade/ + ai_gen_count: 0 // I did vacillate on this point ultimately easier to just reset, discussion here https://www.reddit.com/r/SaaS/comments/16e9bew/should_i_reset_usage_counts_on_plan_upgrade/ } }); } - } - async acceptPendingMembership(account_id: number, membership_id: number): Promise { + async acceptPendingMembership( + account_id: number, + membership_id: number + ): Promise { const membership = prisma_client.membership.findFirstOrThrow({ where: { id: membership_id } }); - if((await membership).account_id != account_id){ + if ((await membership).account_id != account_id) { throw new Error(`Membership does not belong to current account`); } return await prisma_client.membership.update({ where: { - id: membership_id, + id: membership_id }, data: { pending: false }, ...membershipWithAccount - }) + }); } - async deleteMembership(account_id: number, membership_id: number): Promise { + async deleteMembership( + account_id: number, + membership_id: number + ): Promise { const membership = prisma_client.membership.findFirstOrThrow({ where: { id: membership_id } }); - if((await membership).account_id != account_id){ + if ((await membership).account_id != account_id) { throw new Error(`Membership does not belong to current account`); } return await prisma_client.membership.delete({ where: { - id: membership_id, + id: membership_id }, ...membershipWithAccount - }) + }); } - async joinUserToAccount(user_id: number, account_id: number, pending: boolean ): Promise { + async joinUserToAccount( + user_id: number, + account_id: number, + pending: boolean + ): Promise { const account = await prisma_client.account.findUnique({ - where: { - id: account_id, - }, - include:{ - members: true, - } + where: { + id: account_id + }, + include: { + members: true } - ) + }); - if(account?.members && account?.members?.length >= account?.max_members){ - throw new Error(`Too Many Members, Account only permits ${account?.max_members} members.`); + if (account?.members && account?.members?.length >= account?.max_members) { + throw new Error( + `Too Many Members, Account only permits ${account?.max_members} members.` + ); } - if(account?.members){ - for(const member of account.members){ - if(member.user_id === user_id){ + if (account?.members) { + for (const member of account.members) { + if (member.user_id === user_id) { throw new Error(`User is already a member`); } } @@ -154,21 +181,23 @@ export default class AccountService { async changeAccountName(account_id: number, new_name: string) { return prisma_client.account.update({ - where: { id: account_id}, + where: { id: account_id }, data: { - name: new_name, + name: new_name } }); } async changeAccountPlan(account_id: number, plan_id: number) { - const plan = await prisma_client.plan.findFirstOrThrow({ where: {id: plan_id}}); + const plan = await prisma_client.plan.findFirstOrThrow({ + where: { id: plan_id } + }); return prisma_client.account.update({ - where: { id: account_id}, + where: { id: account_id }, data: { plan_id: plan_id, features: plan.features, - max_notes: plan.max_notes, + max_notes: plan.max_notes } }); } @@ -179,23 +208,26 @@ export default class AccountService { numbers: true }); return prisma_client.account.update({ - where: { id: account_id}, + where: { id: account_id }, data: { join_password } }); } - // Claim ownership of an account. + // Claim ownership of an account. // User must already be an ADMIN for the Account // Existing OWNER memberships are downgraded to ADMIN // In future, some sort of Billing/Stripe tie in here e.g. changing email details on the Account, not sure. - async claimOwnershipOfAccount(user_id: number, account_id: number): Promise { + async claimOwnershipOfAccount( + user_id: number, + account_id: number + ): Promise { const membership = await prisma_client.membership.findUniqueOrThrow({ where: { user_id_account_id: { user_id: user_id, - account_id: account_id, + account_id: account_id } - }, + } }); if (membership.access === ACCOUNT_ACCESS.OWNER) { @@ -207,20 +239,20 @@ export default class AccountService { const existing_owner_memberships = await prisma_client.membership.findMany({ where: { account_id: account_id, - access: ACCOUNT_ACCESS.OWNER, - }, + access: ACCOUNT_ACCESS.OWNER + } }); - for(const existing_owner_membership of existing_owner_memberships) { + for (const existing_owner_membership of existing_owner_memberships) { await prisma_client.membership.update({ where: { user_id_account_id: { user_id: existing_owner_membership.user_id, - account_id: account_id, + account_id: account_id } }, data: { - access: ACCOUNT_ACCESS.ADMIN, // Downgrade OWNER to ADMIN + access: ACCOUNT_ACCESS.ADMIN // Downgrade OWNER to ADMIN } }); } @@ -230,49 +262,57 @@ export default class AccountService { where: { user_id_account_id: { user_id: user_id, - account_id: account_id, + account_id: account_id } }, data: { - access: ACCOUNT_ACCESS.OWNER, - }, + access: ACCOUNT_ACCESS.OWNER + } }); // return the full membership list because 2 members have changed. - return prisma_client.membership.findMany({ + return prisma_client.membership.findMany({ where: { account_id }, ...membershipWithUser - }); + }); } // Upgrade access of a membership. Cannot use this method to upgrade to or downgrade from OWNER access - async changeUserAccessWithinAccount(user_id: number, account_id: number, access: ACCOUNT_ACCESS) { + async changeUserAccessWithinAccount( + user_id: number, + account_id: number, + access: ACCOUNT_ACCESS + ) { if (access === ACCOUNT_ACCESS.OWNER) { - throw new Error('UNABLE TO UPDATE MEMBERSHIP: use claimOwnershipOfAccount method to change ownership'); + throw new Error( + 'UNABLE TO UPDATE MEMBERSHIP: use claimOwnershipOfAccount method to change ownership' + ); } const membership = await prisma_client.membership.findUniqueOrThrow({ where: { user_id_account_id: { user_id: user_id, - account_id: account_id, + account_id: account_id } - }, + } }); if (membership.access === ACCOUNT_ACCESS.OWNER) { - throw new Error('UNABLE TO UPDATE MEMBERSHIP: use claimOwnershipOfAccount method to change ownership'); + throw new Error( + 'UNABLE TO UPDATE MEMBERSHIP: use claimOwnershipOfAccount method to change ownership' + ); } return prisma_client.membership.update({ where: { user_id_account_id: { user_id: user_id, - account_id: account_id, + account_id: account_id } }, data: { - access: access, + access: access }, include: { account: true @@ -301,40 +341,48 @@ export default class AccountService { } */ - async getAccountWithPeriodRollover (account_id: number){ - const account = await prisma_client.account.findFirstOrThrow({ + async getAccountWithPeriodRollover(account_id: number) { + const account = await prisma_client.account.findFirstOrThrow({ where: { id: account_id } }); - if(account.plan_name === config.initialPlanName && account.current_period_ends < new Date()){ + if ( + account.plan_name === config.initialPlanName && + account.current_period_ends < new Date() + ) { return await prisma_client.account.update({ where: { id: account.id }, data: { - current_period_ends: UtilService.addMonths(account.current_period_ends,1), + current_period_ends: UtilService.addMonths( + account.current_period_ends, + 1 + ), // reset anything that is affected by the rollover - ai_gen_count: 0, - }, + ai_gen_count: 0 + } }); - }; - - return account; - } - - async checkAIGenCount(account_id: number){ - const account = await this.getAccountWithPeriodRollover(account_id); - - if(account.ai_gen_count >= account.ai_gen_max_pm){ - throw new AccountLimitError('Monthly AI gen limit reached, no new AI Generations can be made'); } return account; } - async incrementAIGenCount (account: any){ + async checkAIGenCount(account_id: number) { + const account = await this.getAccountWithPeriodRollover(account_id); + + if (account.ai_gen_count >= account.ai_gen_max_pm) { + throw new AccountLimitError( + 'Monthly AI gen limit reached, no new AI Generations can be made' + ); + } + + return account; + } + + async incrementAIGenCount(account: any) { return await prisma_client.account.update({ where: { id: account.id }, data: { - ai_gen_count: account.ai_gen_count + 1, + ai_gen_count: account.ai_gen_count + 1 } }); } diff --git a/lib/services/auth.service.ts b/lib/services/auth.service.ts index da3b61a..350b6d2 100644 --- a/lib/services/auth.service.ts +++ b/lib/services/auth.service.ts @@ -7,28 +7,36 @@ import generator from 'generate-password-ts'; const config = useRuntimeConfig(); export default class AuthService { - async getFullUserBySupabaseId(supabase_uid: string): Promise { - return prisma_client.user.findFirst({ - where: { supabase_uid }, + async getFullUserBySupabaseId( + supabase_uid: string + ): Promise { + return prisma_client.user.findFirst({ + where: { supabase_uid }, ...fullDBUser }); } async getUserById(user_id: number): Promise { - return prisma_client.user.findFirstOrThrow({ - where: { id: user_id }, - ...fullDBUser + return prisma_client.user.findFirstOrThrow({ + where: { id: user_id }, + ...fullDBUser }); } - async createUser( supabase_uid: string, display_name: string, email: string ): Promise { - const trialPlan = await prisma_client.plan.findFirstOrThrow({ where: { name: config.initialPlanName}}); + async createUser( + supabase_uid: string, + display_name: string, + email: string + ): Promise { + const trialPlan = await prisma_client.plan.findFirstOrThrow({ + where: { name: config.initialPlanName } + }); const join_password: string = generator.generate({ length: 10, numbers: true }); return prisma_client.user.create({ - data:{ + data: { supabase_uid: supabase_uid, display_name: display_name, email: email, @@ -37,13 +45,16 @@ export default class AuthService { account: { create: { name: display_name, - current_period_ends: UtilService.addMonths(new Date(), config.initialPlanActiveMonths), - plan_id: trialPlan.id, + current_period_ends: UtilService.addMonths( + new Date(), + config.initialPlanActiveMonths + ), + plan_id: trialPlan.id, features: trialPlan.features, max_notes: trialPlan.max_notes, max_members: trialPlan.max_members, plan_name: trialPlan.name, - join_password: join_password, + join_password: join_password } }, access: ACCOUNT_ACCESS.OWNER @@ -55,7 +66,7 @@ export default class AuthService { } async deleteUser(user_id: number): Promise { - return prisma_client.user.delete({ + return prisma_client.user.delete({ where: { id: user_id }, ...fullDBUser }); diff --git a/lib/services/errors.ts b/lib/services/errors.ts index d163de8..9af3339 100644 --- a/lib/services/errors.ts +++ b/lib/services/errors.ts @@ -1,6 +1,6 @@ export class AccountLimitError extends Error { constructor(message: string) { - super(message); - Object.setPrototypeOf(this, AccountLimitError.prototype); + super(message); + Object.setPrototypeOf(this, AccountLimitError.prototype); } -} \ No newline at end of file +} diff --git a/lib/services/notes.service.ts b/lib/services/notes.service.ts index b54d3df..c3b19ab 100644 --- a/lib/services/notes.service.ts +++ b/lib/services/notes.service.ts @@ -16,17 +16,19 @@ export default class NotesService { return prisma_client.note.findMany({ where: { account_id } }); } - async createNote( account_id: number, note_text: string ) { + async createNote(account_id: number, note_text: string) { const account = await prisma_client.account.findFirstOrThrow({ - where: { id: account_id}, - include: { notes: true} + where: { id: account_id }, + include: { notes: true } }); - if(account.notes.length>= account.max_notes){ - throw new AccountLimitError('Note Limit reached, no new notes can be added'); + if (account.notes.length >= account.max_notes) { + throw new AccountLimitError( + 'Note Limit reached, no new notes can be added' + ); } - - return prisma_client.note.create({ data: { account_id, note_text }}); + + return prisma_client.note.create({ data: { account_id, note_text } }); } async updateNote(id: number, note_text: string) { @@ -44,14 +46,14 @@ export default class NotesService { const prompt = ` Write an interesting short note about ${userPrompt}. Restrict the note to a single paragraph. - ` + `; const completion = await openai.createCompletion({ - model: "text-davinci-003", + model: 'text-davinci-003', prompt, temperature: 0.6, - stop: "\n\n", + stop: '\n\n', max_tokens: 1000, - n: 1, + n: 1 }); await accountService.incrementAIGenCount(account); diff --git a/lib/services/openai.client.ts b/lib/services/openai.client.ts index 8a5e085..c256a27 100644 --- a/lib/services/openai.client.ts +++ b/lib/services/openai.client.ts @@ -1,9 +1,9 @@ -import { Configuration, OpenAIApi } from "openai"; +import { Configuration, OpenAIApi } from 'openai'; const config = useRuntimeConfig(); const configuration = new Configuration({ - apiKey: config.openAIKey, + apiKey: config.openAIKey }); -export const openai = new OpenAIApi(configuration); \ No newline at end of file +export const openai = new OpenAIApi(configuration); diff --git a/lib/services/service.types.ts b/lib/services/service.types.ts index 0ae51c9..c8e19e3 100644 --- a/lib/services/service.types.ts +++ b/lib/services/service.types.ts @@ -1,25 +1,39 @@ import { Prisma } from '@prisma/client'; export const membershipWithAccount = Prisma.validator()({ - include: { account: true }, -}) -export type MembershipWithAccount = Prisma.MembershipGetPayload + include: { account: true } +}); +export type MembershipWithAccount = Prisma.MembershipGetPayload< + typeof membershipWithAccount +>; export const membershipWithUser = Prisma.validator()({ - include: { user: true }, -}) -export type MembershipWithUser = Prisma.MembershipGetPayload + include: { user: true } +}); +export type MembershipWithUser = Prisma.MembershipGetPayload< + typeof membershipWithUser +>; export const fullDBUser = Prisma.validator()({ - include: { memberships: {include: { - account: true - }}} + include: { + memberships: { + include: { + account: true + } + } + } }); -export type FullDBUser = Prisma.UserGetPayload //TODO - I wonder if this could be replaced by just user level info +export type FullDBUser = Prisma.UserGetPayload; //TODO - I wonder if this could be replaced by just user level info export const accountWithMembers = Prisma.validator()({ - include: { members: {include: { - user: true - }} } -}) -export type AccountWithMembers = Prisma.AccountGetPayload //TODO - I wonder if this could just be a list of full memberships + include: { + members: { + include: { + user: true + } + } + } +}); +export type AccountWithMembers = Prisma.AccountGetPayload< + typeof accountWithMembers +>; //TODO - I wonder if this could just be a list of full memberships diff --git a/lib/services/util.service.ts b/lib/services/util.service.ts index fe60c05..b9bd697 100644 --- a/lib/services/util.service.ts +++ b/lib/services/util.service.ts @@ -9,14 +9,14 @@ export class UtilService { } public static getErrorMessage(error: unknown) { - if (error instanceof Error) return error.message - return String(error) + if (error instanceof Error) return error.message; + return String(error); } public static stringifySafely(obj: any) { let cache: any[] = []; - let str = JSON.stringify(obj, function(key, value) { - if (typeof value === "object" && value !== null) { + let str = JSON.stringify(obj, function (key, value) { + if (typeof value === 'object' && value !== null) { if (cache.indexOf(value) !== -1) { // Circular reference found, discard key return; @@ -28,5 +28,5 @@ export class UtilService { }); cache = []; // reset the cache return str; - } -} \ No newline at end of file + } +} diff --git a/middleware/auth.ts b/middleware/auth.ts index 459b48f..84c8c4e 100644 --- a/middleware/auth.ts +++ b/middleware/auth.ts @@ -1,7 +1,7 @@ export default defineNuxtRouteMiddleware(() => { - const user = useSupabaseUser() + const user = useSupabaseUser(); if (!user.value) { - return navigateTo('/') + return navigateTo('/'); } -}) \ No newline at end of file +}); diff --git a/nuxt.config.ts b/nuxt.config.ts index f893466..2c4b497 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -7,19 +7,24 @@ export default defineNuxtConfig({ typescript: { shim: false }, - modules: ['@nuxtjs/supabase', '@pinia/nuxt', '@nuxtjs/tailwindcss', 'nuxt-icon'], + modules: [ + '@nuxtjs/supabase', + '@pinia/nuxt', + '@nuxtjs/tailwindcss', + 'nuxt-icon' + ], imports: { - dirs: ['./stores'], + dirs: ['./stores'] }, - app:{ + app: { head: { htmlAttrs: { - lang: 'en', + lang: 'en' }, - title: 'SupaNuxt SaaS', - }, + title: 'SupaNuxt SaaS' + } }, - runtimeConfig:{ + runtimeConfig: { stripeSecretKey: process.env.STRIPE_SECRET_KEY, stripeEndpointSecret: process.env.STRIPE_ENDPOINT_SECRET, subscriptionGraceDays: 3, @@ -28,7 +33,7 @@ export default defineNuxtConfig({ openAIKey: process.env.OPENAI_API_KEY, public: { debugMode: true, - siteRootUrl: process.env.URL || 'http://localhost:3000', // URL env variable is provided by netlify by default + siteRootUrl: process.env.URL || 'http://localhost:3000' // URL env variable is provided by netlify by default } } -}) +}); diff --git a/pages/account.vue b/pages/account.vue index fcbbb77..b59f169 100644 --- a/pages/account.vue +++ b/pages/account.vue @@ -3,10 +3,10 @@ import { ACCOUNT_ACCESS } from '~~/prisma/account-access-enum'; const accountStore = useAccountStore(); - const { activeMembership, activeAccountMembers } = storeToRefs(accountStore) + const { activeMembership, activeAccountMembers } = storeToRefs(accountStore); const config = useRuntimeConfig(); - const newAccountName = ref(""); + const newAccountName = ref(''); onMounted(async () => { await accountStore.init(); @@ -14,8 +14,12 @@ }); function formatDate(date: Date | undefined) { - if (!date) { return ""; } - return new Intl.DateTimeFormat('default', { dateStyle: 'long' }).format(date); + if (!date) { + return ''; + } + return new Intl.DateTimeFormat('default', { dateStyle: 'long' }).format( + date + ); } function joinURL() { @@ -25,7 +29,9 @@ + diff --git a/pages/cancel.vue b/pages/cancel.vue index 224fe6f..db7d570 100644 --- a/pages/cancel.vue +++ b/pages/cancel.vue @@ -1,8 +1,6 @@ \ No newline at end of file + diff --git a/pages/dashboard.vue b/pages/dashboard.vue index dd5bdae..06d67c5 100644 --- a/pages/dashboard.vue +++ b/pages/dashboard.vue @@ -3,56 +3,86 @@ import { ACCOUNT_ACCESS } from '~~/prisma/account-access-enum'; definePageMeta({ - middleware: ['auth'], + middleware: ['auth'] }); const accountStore = useAccountStore(); - const { activeMembership } = storeToRefs(accountStore) + const { activeMembership } = storeToRefs(accountStore); const notesStore = useNotesStore(); - const { notes } = storeToRefs(notesStore); // ensure the notes list is reactive - const newNoteText = ref('') + const { notes } = storeToRefs(notesStore); // ensure the notes list is reactive + const newNoteText = ref(''); - async function addNote(){ - await notesStore.createNote(newNoteText.value) + async function addNote() { + await notesStore.createNote(newNoteText.value); newNoteText.value = ''; } - async function genNote(){ - const genNoteText = await notesStore.generateAINoteFromPrompt(newNoteText.value) + async function genNote() { + const genNoteText = await notesStore.generateAINoteFromPrompt( + newNoteText.value + ); newNoteText.value = genNoteText; } onMounted(async () => { await accountStore.init(); await notesStore.fetchNotesForCurrentUser(); - }); + });