Skip to content

Commit

Permalink
fix: download secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamesb committed Feb 24, 2024
1 parent 20dc51d commit a96d5de
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"scripts": {
"_build": "cd packages/shared && tsc -b && cd ../cli && tsc -b && cd ../server && tsc -b && cd ../client && tsc -b && yarn build",
"build": "yarn workspace server build:prisma && yarn _build",
"build": "yarn workspace server build:prisma && yarn workspace server download-secrets && yarn _build",
"server": "yarn workspace server dev",
"client": "yarn workspace client dev",
"worker": "yarn workspace server worker"
Expand Down
2 changes: 2 additions & 0 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dependencies": {
"@prisma/client": "5.8.0",
"@quixo3/prisma-session-store": "^3.1.13",
"aws-sdk": "^2.1565.0",
"cookie-parser": "^1.4.6",
"cookie-session": "^2.0.0",
"cors": "^2.8.5",
Expand Down Expand Up @@ -33,6 +34,7 @@
"typescript": "^5.2.2"
},
"scripts": {
"download-secrets": "npx tsx scripts/downloadSecrets.ts",
"dev": "nodemon -x 'tsc -b && ts-node src/main.ts'",
"start": "ts-node --transpile-only src/main.ts",
"build": "yarn && npx prisma generate && npx prisma migrate deploy",
Expand Down
17 changes: 17 additions & 0 deletions packages/server/scripts/downloadSecrets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import AWS from "aws-sdk";
import dotenv from "dotenv";
import fs from "fs";

dotenv.config();

AWS.config.update({
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET,
});

const localFilePath = "../../accounts.db";

var s3 = new AWS.S3();
const file = fs.createWriteStream(localFilePath);
const params = { Bucket: "twitter-accounts-open-rec", Key: "accounts.db" };
s3.getObject(params).createReadStream().pipe(file);
6 changes: 6 additions & 0 deletions packages/server/scripts/inspectdb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { exec } from "child_process";
import dotenv from "dotenv";

dotenv.config();

exec(`DATABASE_URL="${process.env.PROD_DATABASE_URL}" npx prisma studio`);
Loading

0 comments on commit a96d5de

Please sign in to comment.