Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
m-abdelwahab committed Jun 11, 2024
1 parent e1cdd54 commit d8613a1
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cleanup-projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ jobs:
- name: Cleanup Projects
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
NEON_API_KEY: ${{ secrets.NEON_API_KEY }}
INSTANT_POSTGRES_API_KEY: ${{ secrets.INSTANT_POSTGRES_API_KEY }}
run: bun run packages/db/src/cleanup-projects.ts
4 changes: 2 additions & 2 deletions .github/workflows/deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
COOKIE_SECRET: ${{ secrets.COOKIE_SECRET }}
NEON_API_KEY: ${{ secrets.NEON_API_KEY }}
INSTANT_POSTGRES_API_KEY: ${{ secrets.INSTANT_POSTGRES_API_KEY }}
APP_URL: ${{ secrets.APP_URL }}
CLOUDFLARE_TURNSTILE_SECRET_KEY: ${{ secrets.CLOUDFLARE_TURNSTILE_SECRET_KEY }}
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
echo "{
\"DATABASE_URL\": \"${{ secrets.DATABASE_URL }}\",
\"COOKIE_SECRET\": \"${{ secrets.COOKIE_SECRET }}\",
\"NEON_API_KEY\": \"${{ secrets.NEON_API_KEY }}\",
\"INSTANT_POSTGRES_API_KEY\": \"${{ secrets.INSTANT_POSTGRES_API_KEY }}\",
\"APP_URL\": \"${{ secrets.APP_URL }}\",
\"CLOUDFLARE_TURNSTILE_SECRET_KEY\": \"${{ secrets.CLOUDFLARE_TURNSTILE_SECRET_KEY }}\",
\"UPSTASH_REDIS_REST_URL\": \"${{ secrets.UPSTASH_REDIS_REST_URL }}\",
Expand Down
4 changes: 2 additions & 2 deletions apps/api/.dev.vars.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
COOKIE_SECRET=
DATABASE_URL=
NEON_API_KEY=
APP_URL=http://localhost:3000
CLOUDFLARE_TURNSTILE_SECRET_KEY=
UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=
UPSTASH_REDIS_REST_TOKEN=
INSTANT_POSTGRES_API_KEY=
2 changes: 1 addition & 1 deletion apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const route = app.post(
);
}

const neonApiClient = neon(c.env.NEON_API_KEY);
const neonApiClient = neon(c.env.INSTANT_POSTGRES_API_KEY);

const start = Date.now();

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import type { schema } from "@instant-postgres/neon";

export type Bindings = {
DATABASE_URL: string;
NEON_API_KEY: string;
COOKIE_SECRET: string;
APP_URL: string;
CLOUDFLARE_TURNSTILE_SECRET_KEY: string;
UPSTASH_REDIS_REST_URL: string;
UPSTASH_REDIS_REST_TOKEN: string;
INSTANT_POSTGRES_API_KEY: string;
};

export type SuccessResponse<ResultType> = {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/components/deploy-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const DeployButton = () => {

<Turnstile
className="hidden"
siteKey="0x4AAAAAAAa4q5vJcjGaJqL7"
siteKey={CLOUDFLARE_TURNSTILE_SITE_KEY}
onSuccess={(token) => setToken(token)}
/>
</fetcher.Form>
Expand Down
10 changes: 6 additions & 4 deletions packages/db/src/cleanup-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { and, sql } from "drizzle-orm";
import { db } from ".";

const DATABASE_URL = process.env.DATABASE_URL;
const NEON_API_KEY = process.env.NEON_API_KEY;
const INSTANT_POSTGRES_API_KEY = process.env.INSTANT_POSTGRES_API_KEY;

const fetchOldProjects = async (client: NeonDriver["client"]) => {
const fiveMinutesAgo = sql`now() - interval '5 minutes'`;
Expand Down Expand Up @@ -52,12 +52,14 @@ const markProjectsAsDeleted = async (client: NeonDriver["client"]) => {

const main = async () => {
try {
if (!DATABASE_URL || !NEON_API_KEY) {
throw new Error("Missing DATABASE_URL or NEON_API_KEY env var");
if (!DATABASE_URL || !INSTANT_POSTGRES_API_KEY) {
throw new Error(
"Missing DATABASE_URL or INSTANT_POSTGRES_API_KEY env var",
);
}

const client = db(DATABASE_URL);
const neonApiClient = neon(NEON_API_KEY);
const neonApiClient = neon(INSTANT_POSTGRES_API_KEY);

const oldProjects = await fetchOldProjects(client);

Expand Down

0 comments on commit d8613a1

Please sign in to comment.