B2B-88: add starter kit structure and elements
This commit is contained in:
3
packages/mailers/shared/README.md
Normal file
3
packages/mailers/shared/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Mailers Shared - @kit/mailers-shared
|
||||
|
||||
This package provides shared utilities for mailers.
|
||||
3
packages/mailers/shared/eslint.config.mjs
Normal file
3
packages/mailers/shared/eslint.config.mjs
Normal file
@@ -0,0 +1,3 @@
|
||||
import eslintConfigBase from '@kit/eslint-config/base.js';
|
||||
|
||||
export default eslintConfigBase;
|
||||
1
packages/mailers/shared/node_modules/@kit/eslint-config
generated
vendored
Symbolic link
1
packages/mailers/shared/node_modules/@kit/eslint-config
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../../tooling/eslint
|
||||
1
packages/mailers/shared/node_modules/@kit/prettier-config
generated
vendored
Symbolic link
1
packages/mailers/shared/node_modules/@kit/prettier-config
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../../tooling/prettier
|
||||
1
packages/mailers/shared/node_modules/@kit/tsconfig
generated
vendored
Symbolic link
1
packages/mailers/shared/node_modules/@kit/tsconfig
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../../tooling/typescript
|
||||
1
packages/mailers/shared/node_modules/zod
generated
vendored
Symbolic link
1
packages/mailers/shared/node_modules/zod
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../node_modules/.pnpm/zod@3.25.56/node_modules/zod
|
||||
28
packages/mailers/shared/package.json
Normal file
28
packages/mailers/shared/package.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "@kit/mailers-shared",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"clean": "git clean -xdf .turbo node_modules",
|
||||
"format": "prettier --check \"**/*.{ts,tsx}\"",
|
||||
"lint": "eslint .",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"prettier": "@kit/prettier-config",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/eslint-config": "workspace:*",
|
||||
"@kit/prettier-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"zod": "^3.24.4"
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"*": [
|
||||
"src/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
3
packages/mailers/shared/src/index.ts
Normal file
3
packages/mailers/shared/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './schema/mailer.schema';
|
||||
export * from './schema/smtp-config.schema';
|
||||
export * from './mailer';
|
||||
7
packages/mailers/shared/src/mailer.ts
Normal file
7
packages/mailers/shared/src/mailer.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { MailerSchema } from './schema/mailer.schema';
|
||||
|
||||
export abstract class Mailer<Res = unknown> {
|
||||
abstract sendEmail(data: z.infer<typeof MailerSchema>): Promise<Res>;
|
||||
}
|
||||
20
packages/mailers/shared/src/schema/mailer.schema.ts
Normal file
20
packages/mailers/shared/src/schema/mailer.schema.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const MailerSchema = z
|
||||
.object({
|
||||
to: z.string().email(),
|
||||
// this is not necessarily formatted
|
||||
// as an email so we type it loosely
|
||||
from: z.string().min(1),
|
||||
subject: z.string(),
|
||||
})
|
||||
.and(
|
||||
z.union([
|
||||
z.object({
|
||||
text: z.string(),
|
||||
}),
|
||||
z.object({
|
||||
html: z.string(),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
28
packages/mailers/shared/src/schema/smtp-config.schema.ts
Normal file
28
packages/mailers/shared/src/schema/smtp-config.schema.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'server-only';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
export const SmtpConfigSchema = z.object({
|
||||
user: z.string({
|
||||
description:
|
||||
'This is the email account to send emails from. This is specific to the email provider.',
|
||||
required_error: `Please provide the variable EMAIL_USER`,
|
||||
}),
|
||||
pass: z.string({
|
||||
description: 'This is the password for the email account',
|
||||
required_error: `Please provide the variable EMAIL_PASSWORD`,
|
||||
}),
|
||||
host: z.string({
|
||||
description: 'This is the SMTP host for the email provider',
|
||||
required_error: `Please provide the variable EMAIL_HOST`,
|
||||
}),
|
||||
port: z.number({
|
||||
description:
|
||||
'This is the port for the email provider. Normally 587 or 465.',
|
||||
required_error: `Please provide the variable EMAIL_PORT`,
|
||||
}),
|
||||
secure: z.boolean({
|
||||
description: 'This is whether the connection is secure or not',
|
||||
required_error: `Please provide the variable EMAIL_TLS`,
|
||||
}),
|
||||
});
|
||||
8
packages/mailers/shared/tsconfig.json
Normal file
8
packages/mailers/shared/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "@kit/tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||
},
|
||||
"include": ["*.ts", "src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user