Skip to content

Commit

Permalink
fix: specify aws region
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixNgFender committed Apr 15, 2024
1 parent 56a18d7 commit e18ef83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const envSchema = z.object({

// Email
ENABLE_EMAIL: isBoolean,
AWS_REGION: isString.optional(),
AWS_ACCESS_KEY_ID: isString.optional(),
AWS_SECRET_ACCESS_KEY: isString.optional(),

Expand Down
10 changes: 8 additions & 2 deletions src/lib/email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ import { AppError } from './error';

let ses: SES;

if (env.ENABLE_EMAIL && env.AWS_ACCESS_KEY_ID && env.AWS_SECRET_ACCESS_KEY) {
if (
env.ENABLE_EMAIL &&
env.AWS_REGION &&
env.AWS_ACCESS_KEY_ID &&
env.AWS_SECRET_ACCESS_KEY
) {
ses = new SES({
region: env.AWS_REGION,
credentials: {
accessKeyId: env.AWS_ACCESS_KEY_ID,
secretAccessKey: env.AWS_SECRET_ACCESS_KEY,
},
});
} else if (
env.ENABLE_EMAIL &&
(!env.AWS_ACCESS_KEY_ID || !env.AWS_SECRET_ACCESS_KEY)
(!env.AWS_REGION || !env.AWS_ACCESS_KEY_ID || !env.AWS_SECRET_ACCESS_KEY)
) {
throw new AppError(
'StartupError',
Expand Down

0 comments on commit e18ef83

Please sign in to comment.