Remove Cloudflare mailer implementation, update dependencies and updated code to reflect stricter EsLint settings

Deleted CloudflareMailer class and its implementation from the mailers package. Updated dependencies across various packages, converting certain imports to use `type` only, and bumped versions for packages like `react-query`, `lucide-react`, and others.
This commit is contained in:
gbuomprisco
2024-08-01 14:57:55 +02:00
parent 5c28eaabeb
commit 23154c366d
48 changed files with 607 additions and 469 deletions
+3 -3
View File
@@ -56,11 +56,11 @@
"@marsidev/react-turnstile": "^0.7.2",
"@radix-ui/react-icons": "^1.3.0",
"@supabase/supabase-js": "^2.45.0",
"@tanstack/react-query": "5.51.15",
"@tanstack/react-query-next-experimental": "^5.51.15",
"@tanstack/react-query": "5.51.16",
"@tanstack/react-query-next-experimental": "^5.51.16",
"@tanstack/react-table": "^8.19.3",
"date-fns": "^3.6.0",
"lucide-react": "^0.417.0",
"lucide-react": "^0.418.0",
"next": "14.2.5",
"next-sitemap": "^4.2.3",
"next-themes": "0.3.0",
+2 -2
View File
@@ -34,11 +34,11 @@
"prettier": "@kit/prettier-config",
"dependencies": {
"@manypkg/cli": "^0.21.4",
"@turbo/gen": "^2.0.9",
"@turbo/gen": "^2.0.11",
"cross-env": "^7.0.3",
"pnpm": "^9.6.0",
"prettier": "^3.3.3",
"turbo": "2.0.9",
"turbo": "2.0.11",
"typescript": "^5.5.4"
},
"pnpm": {
+1 -1
View File
@@ -30,7 +30,7 @@
"@supabase/supabase-js": "^2.45.0",
"@types/react": "^18.3.3",
"date-fns": "^3.6.0",
"lucide-react": "^0.417.0",
"lucide-react": "^0.418.0",
"next": "14.2.5",
"react": "18.3.1",
"react-hook-form": "^7.52.1",
@@ -1,7 +1,7 @@
import { PlusSquare } from 'lucide-react';
import { z } from 'zod';
import { LineItemSchema } from '@kit/billing';
import type { LineItemSchema } from '@kit/billing';
import { formatCurrency } from '@kit/shared/utils';
import { If } from '@kit/ui/if';
import { Trans } from '@kit/ui/trans';
@@ -10,7 +10,7 @@ import { z } from 'zod';
import {
BillingConfig,
LineItemSchema,
type LineItemSchema,
getPlanIntervals,
getPrimaryLineItem,
getProductPlanPair,
@@ -10,7 +10,7 @@ import { z } from 'zod';
import {
BillingConfig,
LineItemSchema,
type LineItemSchema,
getPlanIntervals,
getPrimaryLineItem,
} from '@kit/billing';
@@ -4,7 +4,7 @@ import { z } from 'zod';
import {
BillingConfig,
BillingProviderSchema,
type BillingProviderSchema,
BillingWebhookHandlerService,
} from '@kit/billing';
@@ -1,14 +1,15 @@
import 'server-only';
import { SupabaseClient } from '@supabase/supabase-js';
import { BillingConfig } from '@kit/billing';
import { Database } from '@kit/supabase/database';
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
import { BillingEventHandlerFactoryService } from './billing-event-handler-factory.service';
import { createBillingEventHandlerService } from './billing-event-handler.service';
// a function that returns a Supabase client
type ClientProvider = () => ReturnType<typeof getSupabaseServerActionClient>;
type ClientProvider = () => SupabaseClient<Database>;
// the billing provider from the database
type BillingProvider = Database['public']['Enums']['billing_provider'];
@@ -3,7 +3,7 @@ import 'server-only';
import { z } from 'zod';
import {
BillingProviderSchema,
type BillingProviderSchema,
BillingStrategyProviderService,
} from '@kit/billing';
@@ -1,6 +1,6 @@
import { z } from 'zod';
import { BillingProviderSchema } from '@kit/billing';
import type { BillingProviderSchema } from '@kit/billing';
import {
CancelSubscriptionParamsSchema,
CreateBillingCheckoutSchema,
@@ -1,7 +1,7 @@
import { getCustomer } from '@lemonsqueezy/lemonsqueezy.js';
import { z } from 'zod';
import { CreateBillingPortalSessionSchema } from '@kit/billing/schema';
import type { CreateBillingPortalSessionSchema } from '@kit/billing/schema';
import { initializeLemonSqueezyClient } from './lemon-squeezy-sdk';
@@ -5,7 +5,7 @@ import {
} from '@lemonsqueezy/lemonsqueezy.js';
import { z } from 'zod';
import { CreateBillingCheckoutSchema } from '@kit/billing/schema';
import type { CreateBillingCheckoutSchema } from '@kit/billing/schema';
import { getLemonSqueezyEnv } from '../schema/lemon-squeezy-server-env.schema';
import { initializeLemonSqueezyClient } from './lemon-squeezy-sdk';
@@ -12,7 +12,7 @@ import {
import { z } from 'zod';
import { BillingStrategyProviderService } from '@kit/billing';
import {
import type {
CancelSubscriptionParamsSchema,
CreateBillingCheckoutSchema,
CreateBillingPortalSessionSchema,
@@ -1,7 +1,7 @@
import type { Stripe } from 'stripe';
import { z } from 'zod';
import { CreateBillingPortalSessionSchema } from '@kit/billing/schema';
import type { CreateBillingPortalSessionSchema } from '@kit/billing/schema';
/**
* @name createStripeBillingPortalSession
@@ -1,7 +1,7 @@
import type { Stripe } from 'stripe';
import { z } from 'zod';
import { CreateBillingCheckoutSchema } from '@kit/billing/schema';
import type { CreateBillingCheckoutSchema } from '@kit/billing/schema';
/**
* @name createStripeCheckout
@@ -4,7 +4,7 @@ import type { Stripe } from 'stripe';
import { z } from 'zod';
import { BillingStrategyProviderService } from '@kit/billing';
import {
import type {
CancelSubscriptionParamsSchema,
CreateBillingCheckoutSchema,
CreateBillingPortalSessionSchema,
+1 -1
View File
@@ -15,7 +15,7 @@
"./route-handler": "./src/keystatic-route-handler.ts"
},
"dependencies": {
"@keystatic/core": "0.5.30",
"@keystatic/core": "0.5.32",
"@keystatic/next": "^5.0.1",
"@markdoc/markdoc": "^0.4.0"
},
+2 -2
View File
@@ -35,10 +35,10 @@
"@kit/ui": "workspace:^",
"@radix-ui/react-icons": "^1.3.0",
"@supabase/supabase-js": "^2.45.0",
"@tanstack/react-query": "5.51.15",
"@tanstack/react-query": "5.51.16",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"lucide-react": "^0.417.0",
"lucide-react": "^0.418.0",
"next": "14.2.5",
"next-themes": "0.3.0",
"react": "18.3.1",
@@ -74,6 +74,7 @@ export const UpdatePasswordForm = ({
// if the user does not have an email assigned, it's possible they
// don't have an email/password factor linked, and the UI is out of sync
if (!email) {
/* eslint-disable @typescript-eslint/prefer-promise-reject-errors */
return Promise.reject(t(`cannotUpdatePassword`));
}
+2 -2
View File
@@ -22,10 +22,10 @@
"@makerkit/data-loader-supabase-core": "^0.0.8",
"@makerkit/data-loader-supabase-nextjs": "^1.2.3",
"@supabase/supabase-js": "^2.45.0",
"@tanstack/react-query": "5.51.15",
"@tanstack/react-query": "5.51.16",
"@tanstack/react-table": "^8.19.3",
"@types/react": "^18.3.3",
"lucide-react": "^0.417.0",
"lucide-react": "^0.418.0",
"next": "14.2.5",
"react": "18.3.1",
"react-dom": "18.3.1",
+2 -2
View File
@@ -29,9 +29,9 @@
"@marsidev/react-turnstile": "^0.7.2",
"@radix-ui/react-icons": "^1.3.0",
"@supabase/supabase-js": "^2.45.0",
"@tanstack/react-query": "5.51.15",
"@tanstack/react-query": "5.51.16",
"@types/react": "^18.3.3",
"lucide-react": "^0.417.0",
"lucide-react": "^0.418.0",
"next": "14.2.5",
"react-hook-form": "^7.52.1",
"react-i18next": "^15.0.0",
@@ -32,7 +32,7 @@ export function OauthProviders(props: {
const credential = await signInRequest();
if (!credential) {
return Promise.reject();
return Promise.reject(new Error('Failed to sign in with provider'));
}
},
[],
@@ -33,7 +33,7 @@ export function PasswordSignInContainer({
onSignIn(userId);
}
} catch (e) {
} catch {
// wrong credentials, do nothing
} finally {
resetCaptchaToken();
+2 -2
View File
@@ -21,9 +21,9 @@
"@kit/tsconfig": "workspace:*",
"@kit/ui": "workspace:*",
"@supabase/supabase-js": "^2.45.0",
"@tanstack/react-query": "5.51.15",
"@tanstack/react-query": "5.51.16",
"@types/react": "^18.3.3",
"lucide-react": "^0.417.0",
"lucide-react": "^0.418.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-i18next": "^15.0.0"
+2 -2
View File
@@ -33,13 +33,13 @@
"@kit/tsconfig": "workspace:*",
"@kit/ui": "workspace:^",
"@supabase/supabase-js": "^2.45.0",
"@tanstack/react-query": "5.51.15",
"@tanstack/react-query": "5.51.16",
"@tanstack/react-table": "^8.19.3",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"class-variance-authority": "^0.7.0",
"date-fns": "^3.6.0",
"lucide-react": "^0.417.0",
"lucide-react": "^0.418.0",
"next": "14.2.5",
"react": "18.3.1",
"react-dom": "18.3.1",
@@ -78,7 +78,7 @@ function CreateOrganizationAccountForm(props: { onClose: () => void }) {
startTransition(async () => {
try {
await createTeamAccountAction(data);
} catch (error) {
} catch {
setError(true);
}
});
@@ -63,7 +63,7 @@ function DeleteInvitationForm({
await deleteInvitationAction({ invitationId });
setIsOpen(false);
} catch (e) {
} catch {
setError(true);
}
});
@@ -68,7 +68,7 @@ function RenewInvitationForm({
await renewInvitationAction({ invitationId });
setIsOpen(false);
} catch (e) {
} catch {
setError(true);
}
});
@@ -93,7 +93,7 @@ function UpdateInvitationForm({
});
setIsOpen(false);
} catch (e) {
} catch {
setError(true);
}
});
@@ -68,7 +68,7 @@ function RemoveMemberForm({
await removeMemberFromAccountAction({ accountId, userId });
setIsOpen(false);
} catch (e) {
} catch {
setError(true);
}
});
@@ -102,7 +102,7 @@ function TransferOrganizationOwnershipForm({
await transferOwnershipAction(data);
setIsOpen(false);
} catch (error) {
} catch {
setError(true);
}
});
@@ -103,7 +103,7 @@ function UpdateMemberForm({
});
setIsOpen(false);
} catch (e) {
} catch {
setError(true);
}
});
@@ -8,9 +8,9 @@ import { z } from 'zod';
import { getLogger } from '@kit/shared/logger';
import { Database } from '@kit/supabase/database';
import { DeleteInvitationSchema } from '../../schema/delete-invitation.schema';
import { InviteMembersSchema } from '../../schema/invite-members.schema';
import { UpdateInvitationSchema } from '../../schema/update-invitation.schema';
import type { DeleteInvitationSchema } from '../../schema/delete-invitation.schema';
import type { InviteMembersSchema } from '../../schema/invite-members.schema';
import type { UpdateInvitationSchema } from '../../schema/update-invitation.schema';
export function createAccountInvitationsService(
client: SupabaseClient<Database>,
@@ -7,9 +7,9 @@ import { z } from 'zod';
import { getLogger } from '@kit/shared/logger';
import { Database } from '@kit/supabase/database';
import { RemoveMemberSchema } from '../../schema/remove-member.schema';
import { TransferOwnershipConfirmationSchema } from '../../schema/transfer-ownership-confirmation.schema';
import { UpdateMemberRoleSchema } from '../../schema/update-member-role.schema';
import type { RemoveMemberSchema } from '../../schema/remove-member.schema';
import type { TransferOwnershipConfirmationSchema } from '../../schema/transfer-ownership-confirmation.schema';
import type { UpdateMemberRoleSchema } from '../../schema/update-member-role.schema';
import { createAccountPerSeatBillingService } from './account-per-seat-billing.service';
export function createAccountMembersService(client: SupabaseClient<Database>) {
+1 -1
View File
@@ -21,7 +21,7 @@
"@kit/shared": "workspace:^",
"@kit/tailwind-config": "workspace:*",
"@kit/tsconfig": "workspace:*",
"@tanstack/react-query": "5.51.15",
"@tanstack/react-query": "5.51.16",
"react-i18next": "^15.0.0"
},
"dependencies": {
-10
View File
@@ -19,12 +19,6 @@ Make sure the app installs the `@kit/mailers` package before using it.
By default, the package uses `nodemailer`.
To use Cloudflare, please set the environment variable `MAILER_PROVIDER` to `cloudflare`.
```
MAILER_PROVIDER=cloudflare
```
To use [Resend](https:///resend.com)'s HTTP API, please set the environment variable `MAILER_PROVIDER` to `resend`.
```
@@ -48,10 +42,6 @@ async function sendEmail() {
}
```
## Cloudflare
If you're using the `cloudflare` provider, please also read the instructions of the package [Vercel Email](https://github.com/Sh4yy/vercel-email) to setup your Workers.
## Resend
If you're using the `resend` provider, please add the following environment variables:
@@ -1,31 +0,0 @@
import 'server-only';
import Email from 'vercel-email';
import { z } from 'zod';
import { Mailer } from '../../mailer';
import { MailerSchema } from '../../schema/mailer.schema';
type Config = z.infer<typeof MailerSchema>;
/**
* A class representing a mailer using Cloudflare's Workers thanks to the 'vercel-email' package.
* @implements {Mailer}
*/
export class CloudflareMailer implements Mailer {
async sendEmail(config: Config) {
const schema = {
to: config.to,
from: config.from,
subject: config.subject,
};
const content =
'text' in config ? { text: config.text } : { html: config.html };
return Email.send({
...schema,
...content,
});
}
}
@@ -3,7 +3,7 @@ import 'server-only';
import { z } from 'zod';
import { Mailer } from '../../mailer';
import { MailerSchema } from '../../schema/mailer.schema';
import type { MailerSchema } from '../../schema/mailer.schema';
import { getSMTPConfiguration } from '../../smtp-configuration';
type Config = z.infer<typeof MailerSchema>;
+1 -1
View File
@@ -3,7 +3,7 @@ import 'server-only';
import { z } from 'zod';
import { Mailer } from '../../mailer';
import { MailerSchema } from '../../schema/mailer.schema';
import type { MailerSchema } from '../../schema/mailer.schema';
type Config = z.infer<typeof MailerSchema>;
+1 -10
View File
@@ -1,7 +1,7 @@
import { z } from 'zod';
const MAILER_PROVIDER = z
.enum(['nodemailer', 'cloudflare', 'resend'])
.enum(['nodemailer', 'resend'])
.default('nodemailer')
.parse(process.env.MAILER_PROVIDER);
@@ -13,9 +13,6 @@ export async function getMailer() {
case 'nodemailer':
return getNodemailer();
case 'cloudflare':
return getCloudflareMailer();
case 'resend':
return getResendMailer();
@@ -36,12 +33,6 @@ async function getNodemailer() {
}
}
async function getCloudflareMailer() {
const { CloudflareMailer } = await import('./impl/cloudflare');
return new CloudflareMailer();
}
async function getResendMailer() {
const { ResendMailer } = await import('./impl/resend');
+1 -1
View File
@@ -16,7 +16,7 @@
"./config/server": "./src/sentry.client.server.ts"
},
"dependencies": {
"@sentry/nextjs": "^8.20.0"
"@sentry/nextjs": "^8.22.0"
},
"devDependencies": {
"@kit/eslint-config": "workspace:*",
+1 -1
View File
@@ -29,7 +29,7 @@
"@supabase/gotrue-js": "2.64.4",
"@supabase/ssr": "^0.4.0",
"@supabase/supabase-js": "^2.45.0",
"@tanstack/react-query": "5.51.15",
"@tanstack/react-query": "5.51.16",
"@types/react": "^18.3.3",
"next": "14.2.5",
"react": "18.3.1",
+1 -1
View File
@@ -21,7 +21,7 @@ export function useUser(initialData?: User | null) {
return response.data.user;
}
return Promise.reject('Unexpected result format');
return Promise.reject(new Error('Unexpected result format'));
};
return useQuery({
+2 -2
View File
@@ -31,7 +31,7 @@
"clsx": "^2.1.1",
"cmdk": "1.0.0",
"input-otp": "1.2.4",
"lucide-react": "^0.417.0",
"lucide-react": "^0.418.0",
"react-top-loading-bar": "2.3.1",
"tailwind-merge": "^2.4.0"
},
@@ -41,7 +41,7 @@
"@kit/tailwind-config": "workspace:*",
"@kit/tsconfig": "workspace:*",
"@radix-ui/react-icons": "^1.3.0",
"@tanstack/react-query": "5.51.15",
"@tanstack/react-query": "5.51.16",
"@tanstack/react-table": "^8.19.3",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
+1 -1
View File
@@ -19,7 +19,7 @@ import {
import { cn, isRouteActive } from '../utils';
import { SidebarContext } from './context/sidebar.context';
import { If } from './if';
import { NavigationConfigSchema } from './navigation-config.schema';
import type { NavigationConfigSchema } from './navigation-config.schema';
import { Trans } from './trans';
export type SidebarConfig = z.infer<typeof NavigationConfigSchema>;
+545 -360
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -24,6 +24,7 @@ const config = {
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
+3 -3
View File
@@ -16,10 +16,10 @@
"@next/eslint-plugin-next": "^14.2.5",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/eslint": "^8.56.10",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^2.0.9",
"eslint-config-turbo": "^2.0.11",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2"