extract s3 to integrations
This commit is contained in:
parent
24f1e953f6
commit
545ee225aa
@ -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" });
|
||||||
|
|
||||||
|
@ -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";
|
||||||
|
|
||||||
|
@ -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";
|
||||||
|
|
||||||
|
14
db/backup.ts
14
db/backup.ts
@ -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
11
integrations/aws-s3.ts
Normal 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 });
|
Loading…
Reference in New Issue
Block a user