Skip to content

Commit

Permalink
fix: fixed checkout, separated tier for edge and upgraded to Next 14
Browse files Browse the repository at this point in the history
  • Loading branch information
jerriclynsjohn committed Oct 30, 2023
1 parent d586c96 commit 8c60d23
Show file tree
Hide file tree
Showing 8 changed files with 695 additions and 325 deletions.
15 changes: 15 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
NEXT_PUBLIC_APP_URL='http://localhost:3000'

TIER_BASE_URL='https://api.tier.run'
TIER_API_KEY='sk_test_51O5RLmFbUk96SQSJnjbwqatMyssU1DEIWgYnLMeZZbLli1a1caDllVeDfbconRJ17n0m5bE7lGNK99KiIVx8CVu600MwsphlgW'

NEXTAUTH_SECRET='3PiU5FXmFZTvB5LVMXHTYJFGTYPoQcoVjCV+v+hgzqQ='
NEXTAUTH_URL='http://localhost:3000'

GITHUB_CLIENT_ID='b97f541991b16308723f'
GITHUB_CLIENT_SECRET='f599a0f220d33ebdc39f5a30637a7a100645e6b7'

OPENAI_API_KEY='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'

POSTGRES_URL_NON_POOLING='postgres://default:3mUOJRE6XSNA@ep-sweet-unit-55027686.us-east-1.postgres.vercel-storage.com:5432/verceldb'
POSTGRES_PRISMA_URL='postgres://default:3mUOJRE6XSNA@ep-sweet-unit-55027686.us-east-1.postgres.vercel-storage.com:5432/verceldb?pgbouncer=true&connect_timeout=15'
1 change: 0 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const nextConfig = {
domains: ["avatars.githubusercontent.com"],
},
experimental: {
serverActions: true,
serverComponentsExternalPackages: ["@prisma/client"],
},
typescript: {
Expand Down
974 changes: 662 additions & 312 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"@headlessui/react": "^1.7.15",
"@heroicons/react": "^2.0.18",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.4.1",
"@prisma/client": "^5.5.2",
"@radix-ui/react-toast": "^1.1.4",
"@t3-oss/env-nextjs": "^0.6.0",
"ai": "^2.1.26",
"clsx": "^1.2.1",
"cva": "npm:class-variance-authority@^0.6.1",
"lucide-react": "^0.256.0",
"next": "^13.4.7",
"next-auth": "^4.22.1",
"next": "^14.0.0",
"next-auth": "^4.24.4",
"nodemailer": "^6.9.3",
"openai-edge": "^1.2.2",
"react": "^18.2.0",
Expand All @@ -44,14 +44,14 @@
"@tailwindcss/line-clamp": "^0.4.4",
"@tailwindcss/typography": "^0.5.9",
"@types/node": "^20.3.2",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/react": "^18.2.33",
"@types/react-dom": "^18.2.14",
"@typescript-eslint/parser": "^5.60.1",
"autoprefixer": "^10.4.14",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.43.0",
"eslint-config-next": "^13.4.7",
"eslint-config-next": "^14.0.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-tailwindcss": "^3.13.0",
Expand All @@ -62,7 +62,7 @@
"prettier": "^2.8.8",
"prettier-plugin-tailwindcss": "^0.3.0",
"pretty-quick": "^3.1.3",
"prisma": "^5.4.1",
"prisma": "^5.5.2",
"stripe": "^12.17.0",
"tailwindcss": "^3.3.2",
"tailwindcss-animate": "^1.0.6",
Expand Down
1 change: 0 additions & 1 deletion src/app/api/change-plan/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export async function GET(req: Request) {
const checkout = await tier.checkout(`org:${user?.id}`, successUrl, {
cancelUrl,
});

return new Response(JSON.stringify({ url: checkout.url }));
} else {
console.log("subscribe");
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/generate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { z } from "zod";
import { env } from "@/env.mjs";
import { TIER_AICOPY_FEATURE_ID, TIER_EXTRACOPY_FEATURE_ID } from "@/config/tierConstants";
import { openAI } from "@/lib/ai";
import { tier } from "@/lib/tier";
import { tier } from "@/lib/tier-edge";

if (!env.OPENAI_API_KEY) {
throw new Error("Missing env var from OpenAI");
Expand Down
9 changes: 9 additions & 0 deletions src/lib/tier-edge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Tier } from "tier/client";

import { env } from "@/env.mjs";

export const tier = new Tier({
baseURL: env.TIER_BASE_URL as string,
apiKey: env.TIER_API_KEY,
debug: true,
});
4 changes: 1 addition & 3 deletions src/lib/tier.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// import { Tier } from "tier"; // If you do not want to make Tier work on edge

import { Tier } from "tier/client"; // If you want to make Tier work on edge
import { Tier } from "tier";

import { env } from "@/env.mjs";

Expand Down

1 comment on commit 8c60d23

@vercel
Copy link

@vercel vercel bot commented on 8c60d23 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

tier-vercel-openai – ./

tier-vercel-openai-tier.vercel.app
tier-vercel-openai.vercel.app
tier-vercel-openai-git-main-tier.vercel.app

Please sign in to comment.