diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 58d706b..475d8e5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -106,22 +106,26 @@ jobs: if: github.event_name == 'push' run: | if [ -z "${{ steps.previoustag.outputs.tag }}" ]; then - if git ls-files | grep -q "workers/email-receiver.ts"; then + # Check email worker and its dependencies + if git ls-files | grep -q -E "workers/email-receiver.ts|app/lib/schema.ts|app/lib/webhook.ts|app/config/webhook.ts"; then echo "email_worker_changed=true" >> $GITHUB_OUTPUT else echo "email_worker_changed=false" >> $GITHUB_OUTPUT fi + # Check cleanup worker if git ls-files | grep -q "workers/cleanup.ts"; then echo "cleanup_worker_changed=true" >> $GITHUB_OUTPUT else echo "cleanup_worker_changed=false" >> $GITHUB_OUTPUT fi else - if git diff ${{ steps.previoustag.outputs.tag }}..HEAD --name-only | grep -q "workers/email-receiver.ts"; then + # Check email worker and its dependencies changes + if git diff ${{ steps.previoustag.outputs.tag }}..HEAD --name-only | grep -q -E "workers/email-receiver.ts|app/lib/schema.ts|app/lib/webhook.ts|app/config/webhook.ts"; then echo "email_worker_changed=true" >> $GITHUB_OUTPUT else echo "email_worker_changed=false" >> $GITHUB_OUTPUT fi + # Check cleanup worker changes if git diff ${{ steps.previoustag.outputs.tag }}..HEAD --name-only | grep -q "workers/cleanup.ts"; then echo "cleanup_worker_changed=true" >> $GITHUB_OUTPUT else diff --git a/app/config/email.ts b/app/config/email.ts new file mode 100644 index 0000000..8905818 --- /dev/null +++ b/app/config/email.ts @@ -0,0 +1,7 @@ +export const EMAIL_CONFIG = { + MAX_ACTIVE_EMAILS: 30, // Maximum number of active emails + POLL_INTERVAL: 10_000, // Polling interval in milliseconds + DOMAIN: process.env.NEXT_PUBLIC_EMAIL_DOMAIN || 'moemail.app', // Email domain +} as const + +export type EmailConfig = typeof EMAIL_CONFIG \ No newline at end of file diff --git a/app/config/index.ts b/app/config/index.ts index b1ecf87..c13dd61 100644 --- a/app/config/index.ts +++ b/app/config/index.ts @@ -1,14 +1,2 @@ -export const EMAIL_CONFIG = { - MAX_ACTIVE_EMAILS: 30, // Maximum number of active emails - POLL_INTERVAL: 10_000, // Polling interval in milliseconds - DOMAIN: process.env.NEXT_PUBLIC_EMAIL_DOMAIN || 'moemail.app', // Email domain -} as const - -export const WEBHOOK_CONFIG = { - MAX_RETRIES: 3, // Maximum retry count - TIMEOUT: 10_000, // Timeout time (milliseconds) - RETRY_DELAY: 1000, // Retry delay (milliseconds) - EVENTS: { - NEW_MESSAGE: 'new_message', - } -} as const \ No newline at end of file +export * from './email' +export * from './webhook' \ No newline at end of file diff --git a/app/config/webhook.ts b/app/config/webhook.ts new file mode 100644 index 0000000..892b61f --- /dev/null +++ b/app/config/webhook.ts @@ -0,0 +1,10 @@ +export const WEBHOOK_CONFIG = { + MAX_RETRIES: 3, // Maximum retry count + TIMEOUT: 10_000, // Timeout time (milliseconds) + RETRY_DELAY: 1000, // Retry delay (milliseconds) + EVENTS: { + NEW_MESSAGE: 'new_message', + } +} as const + +export type WebhookConfig = typeof WEBHOOK_CONFIG \ No newline at end of file diff --git a/workers/email-receiver.ts b/workers/email-receiver.ts index 5a75a00..cd16b68 100644 --- a/workers/email-receiver.ts +++ b/workers/email-receiver.ts @@ -3,7 +3,7 @@ import { drizzle } from 'drizzle-orm/d1' import { messages, emails, webhooks } from '../app/lib/schema' import { eq } from 'drizzle-orm' import PostalMime from 'postal-mime' -import { WEBHOOK_CONFIG } from '../app/config' +import { WEBHOOK_CONFIG } from '../app/config/webhook' import { EmailMessage } from '../app/lib/webhook' const handleEmail = async (message: ForwardableEmailMessage, env: Env) => {