Formated Files

This commit is contained in:
Ahmad 2024-02-15 20:49:19 -05:00
parent d5631b309a
commit e768d9181f
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
138 changed files with 1829 additions and 1851 deletions

View file

@ -1,8 +1,8 @@
import { auth } from "@clerk/nextjs";
import { ENTITY_TYPE } from "@prisma/client";
import { NextResponse } from "next/server";
import { auth } from '@clerk/nextjs';
import { ENTITY_TYPE } from '@prisma/client';
import { NextResponse } from 'next/server';
import { db } from "@/lib/db";
import { db } from '@/lib/db';
export async function GET(
req: Request,
@ -12,7 +12,7 @@ export async function GET(
const { orgId, userId } = auth();
if (!orgId || !userId)
return new NextResponse(JSON.stringify({ error: "Unauthorized" }), {
return new NextResponse(JSON.stringify({ error: 'Unauthorized' }), {
status: 401,
});
@ -23,7 +23,7 @@ export async function GET(
entityType: ENTITY_TYPE.CARD,
},
orderBy: {
createdAt: "desc",
createdAt: 'desc',
},
take: 3,
});

View file

@ -1,7 +1,7 @@
import { auth } from "@clerk/nextjs";
import { NextResponse } from "next/server";
import { auth } from '@clerk/nextjs';
import { NextResponse } from 'next/server';
import { db } from "@/lib/db";
import { db } from '@/lib/db';
export async function GET(
req: Request,
@ -11,7 +11,7 @@ export async function GET(
const { orgId, userId } = auth();
if (!orgId || !userId)
return new NextResponse(JSON.stringify({ error: "Unauthorized" }), {
return new NextResponse(JSON.stringify({ error: 'Unauthorized' }), {
status: 401,
});

View file

@ -1,13 +1,13 @@
import Stripe from "stripe";
import { headers } from "next/headers";
import { NextResponse } from "next/server";
import Stripe from 'stripe';
import { headers } from 'next/headers';
import { NextResponse } from 'next/server';
import { db } from "@/lib/db";
import { stripe } from "@/lib/stripe";
import { db } from '@/lib/db';
import { stripe } from '@/lib/stripe';
export async function POST(req: Request) {
const body = await req.text();
const signature = headers().get("Stripe-Signature") as string;
const signature = headers().get('Stripe-Signature') as string;
let event: Stripe.Event;
@ -23,13 +23,13 @@ export async function POST(req: Request) {
const session = event.data.object as Stripe.Checkout.Session;
if (event.type === "checkout.session.completed") {
if (event.type === 'checkout.session.completed') {
const subscription = await stripe.subscriptions.retrieve(
session.subscription as string
);
if (!session?.metadata?.orgId) {
return new NextResponse(JSON.stringify({ error: "Missing orgId" }), {
return new NextResponse(JSON.stringify({ error: 'Missing orgId' }), {
status: 400,
});
}
@ -47,7 +47,7 @@ export async function POST(req: Request) {
});
}
if (event.type === "invoice.payment_succeeded") {
if (event.type === 'invoice.payment_succeeded') {
const subscription = await stripe.subscriptions.retrieve(
session.subscription as string
);