History

refactor(dokploy): remove stripe from global scope

Mauricio Siu committed 2 years ago

Commit fa053b41 parent bcc7afa2 files · +5 −11Browse files

Unified · Split

2 files
  1. apps/dokploy/pages/api/stripe/webhook.ts +5 −5
  2. apps/dokploy/server/utils/stripe.ts +0 −6
apps/dokploy/pages/api/stripe/webhook.ts+5−5
@@ -6,11 +6,6 @@ import { asc, eq } from "drizzle-orm"; · 5 unmodified lines
66 import type { NextApiRequest, NextApiResponse } from "next";
77 import Stripe from "stripe";
88
9−const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
10− apiVersion: "2024-09-30.acacia",
11− maxNetworkRetries: 3,
12−});
13−
149 const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET || "";
1510
1611 export const config = {
@@ -26,6 +21,11 @@ export default async function handler( · 9 unmodified lines
2621 if (!endpointSecret) {
2722 return res.status(400).send("Webhook Error: Missing Stripe Secret Key");
2823 }
24+ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
25+ apiVersion: "2024-09-30.acacia",
26+ maxNetworkRetries: 3,
27+ });
28+
2929 const buf = await buffer(req);
3030 const sig = req.headers["stripe-signature"] as string;
3131
apps/dokploy/server/utils/stripe.ts+0−6
@@ -1,14 +1,8 @@
1−import Stripe from "stripe";
2−
31 export const WEBSITE_URL =
42 process.env.NODE_ENV === "development"
53 ? "http://localhost:3000"
64 : "https://app.dokploy.com";
75
8−export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
9− apiVersion: "2024-09-30.acacia",
10−});
11−
126 const BASE_PRICE_MONTHLY_ID = process.env.BASE_PRICE_MONTHLY_ID || ""; // $4.00
137
148 const BASE_ANNUAL_MONTHLY_ID = process.env.BASE_ANNUAL_MONTHLY_ID || ""; // $7.99

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t