extract s3 to integrations

This commit is contained in:
m5r 2021-10-13 21:42:23 +02:00
parent 24f1e953f6
commit 545ee225aa
6 changed files with 17 additions and 16 deletions

View File

@ -1,7 +1,7 @@
import { Queue } from "quirrel/blitz"; import { Queue } from "quirrel/blitz";
import appLogger from "../../../../integrations/logger"; import appLogger from "integrations/logger";
import { sendEmail } from "../../../../integrations/ses"; import { sendEmail } from "integrations/aws-ses";
const logger = appLogger.child({ queue: "notify-email-change" }); const logger = appLogger.child({ queue: "notify-email-change" });

View File

@ -4,7 +4,7 @@ import type { PaddleSdkSubscriptionCreatedEvent } from "@devoxa/paddle-sdk";
import db, { MembershipRole } from "db"; import db, { MembershipRole } from "db";
import appLogger from "integrations/logger"; import appLogger from "integrations/logger";
import { sendEmail } from "integrations/ses"; import { sendEmail } from "integrations/aws-ses";
import type { Metadata } from "integrations/paddle"; import type { Metadata } from "integrations/paddle";
import { translateSubscriptionStatus } from "integrations/paddle"; import { translateSubscriptionStatus } from "integrations/paddle";

View File

@ -4,7 +4,7 @@ import { PaddleSdkSubscriptionUpdatedEvent } from "@devoxa/paddle-sdk";
import db, { MembershipRole } from "db"; import db, { MembershipRole } from "db";
import appLogger from "integrations/logger"; import appLogger from "integrations/logger";
import { sendEmail } from "integrations/ses"; import { sendEmail } from "integrations/aws-ses";
import type { Metadata } from "integrations/paddle"; import type { Metadata } from "integrations/paddle";
import { translateSubscriptionStatus } from "integrations/paddle"; import { translateSubscriptionStatus } from "integrations/paddle";

View File

@ -2,19 +2,9 @@ import url from "url";
import querystring from "querystring"; import querystring from "querystring";
import { spawn } from "child_process"; import { spawn } from "child_process";
import { PassThrough } from "stream"; import { PassThrough } from "stream";
import { getConfig } from "blitz";
import AWS from "aws-sdk";
import { sendEmail } from "../integrations/ses";
const { serverRuntimeConfig } = getConfig(); import { sendEmail } from "integrations/aws-ses";
import { s3 } from "integrations/aws-s3";
const s3 = new AWS.S3({
credentials: new AWS.Credentials({
accessKeyId: serverRuntimeConfig.awsS3.accessKeyId,
secretAccessKey: serverRuntimeConfig.awsS3.secretAccessKey,
}),
region: serverRuntimeConfig.awsS3.region,
});
export default async function backup(schedule: "daily" | "weekly" | "monthly") { export default async function backup(schedule: "daily" | "weekly" | "monthly") {
const s3Bucket = `shellphone-${schedule}-backup`; const s3Bucket = `shellphone-${schedule}-backup`;

11
integrations/aws-s3.ts Normal file
View File

@ -0,0 +1,11 @@
import { Credentials, S3 } from "aws-sdk";
import { getConfig } from "blitz";
const { serverRuntimeConfig } = getConfig();
const credentials = new Credentials({
accessKeyId: serverRuntimeConfig.awsSes.accessKeyId,
secretAccessKey: serverRuntimeConfig.awsSes.secretAccessKey,
});
export const s3 = new S3({ region: serverRuntimeConfig.awsS3.region, credentials });