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
6import type { NextApiRequest, NextApiResponse } from "next";6import type { NextApiRequest, NextApiResponse } from "next";
7import Stripe from "stripe";7import Stripe from "stripe";
8 8
9const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
10 apiVersion: "2024-09-30.acacia",
11 maxNetworkRetries: 3,
12});
13
14const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET || "";9const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET || "";
15 10
16export const config = {11export const config = {
@@ -26,6 +21,11 @@ export default async function handler( · 9 unmodified lines
26 if (!endpointSecret) {21 if (!endpointSecret) {
27 return res.status(400).send("Webhook Error: Missing Stripe Secret Key");22 return res.status(400).send("Webhook Error: Missing Stripe Secret Key");
28 }23 }
24 const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
25 apiVersion: "2024-09-30.acacia",
26 maxNetworkRetries: 3,
27 });
28
29 const buf = await buffer(req);29 const buf = await buffer(req);
30 const sig = req.headers["stripe-signature"] as string;30 const sig = req.headers["stripe-signature"] as string;
31 31
apps/dokploy/server/utils/stripe.ts+0−6
@@ -1,14 +1,8 @@
1import Stripe from "stripe";
2
3export const WEBSITE_URL =1export const WEBSITE_URL =
4 process.env.NODE_ENV === "development"2 process.env.NODE_ENV === "development"
5 ? "http://localhost:3000"3 ? "http://localhost:3000"
6 : "https://app.dokploy.com";4 : "https://app.dokploy.com";
7 5
8export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
9 apiVersion: "2024-09-30.acacia",
10});
11
12const BASE_PRICE_MONTHLY_ID = process.env.BASE_PRICE_MONTHLY_ID || ""; // $4.006const BASE_PRICE_MONTHLY_ID = process.env.BASE_PRICE_MONTHLY_ID || ""; // $4.00
13 7
14const BASE_ANNUAL_MONTHLY_ID = process.env.BASE_ANNUAL_MONTHLY_ID || ""; // $7.998const 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