├── .env.local.sample
├── .eslintrc.json
├── .gitignore
├── README.md
├── lib
└── mongodb.js
├── next.config.js
├── package-lock.json
├── package.json
├── pages
├── _app.js
├── api
│ └── hello.js
└── index.js
├── postcss.config.js
├── public
├── favicon.ico
├── favicon.png
├── hero.webp
└── vercel.svg
├── styles
└── globals.css
└── tailwind.config.js
/.env.local.sample:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=
2 | AUTH0_SECRET=
3 | AUTH0_BASE_URL=
4 | AUTH0_ISSUER_BASE_URL=
5 | AUTH0_CLIENT_ID=
6 | AUTH0_CLIENT_SECRET=
7 | MONGODB_URI=
8 | NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
9 | STRIPE_SECRET_KEY=
10 | STRIPE_WEBHOOK_SECRET=
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "next/core-web-vitals"
3 | }
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 | .pnpm-debug.log*
27 |
28 | # local env files
29 | .env*.local
30 |
31 | # vercel
32 | .vercel
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Next JS & Open AI / GPT: Next-generation Next JS & AI apps
2 | This is the starter repo for the [Next JS & Open AI / GPT: Next-generation Next JS & AI apps course](https://www.udemy.com/course/next-js-ai/?referralCode=CF9492ACD4991930F84E).
3 |
--------------------------------------------------------------------------------
/lib/mongodb.js:
--------------------------------------------------------------------------------
1 | import { MongoClient } from 'mongodb';
2 |
3 | if (!process.env.MONGODB_URI) {
4 | throw new Error('Invalid/Missing environment variable: "MONGODB_URI"');
5 | }
6 |
7 | const uri = process.env.MONGODB_URI;
8 |
9 | let client;
10 | let clientPromise;
11 |
12 | if (process.env.NODE_ENV === 'development') {
13 | // In development mode, use a global variable so that the value
14 | // is preserved across module reloads caused by HMR (Hot Module Replacement).
15 | if (!global._mongoClientPromise) {
16 | client = new MongoClient(uri);
17 | global._mongoClientPromise = client.connect();
18 | }
19 | clientPromise = global._mongoClientPromise;
20 | } else {
21 | // In production mode, it's best to not use a global variable.
22 | client = new MongoClient(uri);
23 | clientPromise = client.connect();
24 | }
25 |
26 | // Export a module-scoped MongoClient promise. By doing this in a
27 | // separate module, the client can be shared across functions.
28 | export default clientPromise;
29 |
--------------------------------------------------------------------------------
/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {
3 | reactStrictMode: true,
4 | }
5 |
6 | module.exports = nextConfig
7 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nextjs-openai-starter",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "next dev",
7 | "build": "next build",
8 | "start": "next start",
9 | "lint": "next lint"
10 | },
11 | "dependencies": {
12 | "@auth0/nextjs-auth0": "^2.2.1",
13 | "@fortawesome/fontawesome-svg-core": "^6.2.1",
14 | "@fortawesome/free-solid-svg-icons": "^6.2.1",
15 | "@fortawesome/react-fontawesome": "^0.2.0",
16 | "@next/font": "^13.1.6",
17 | "@webdeveducation/next-verify-stripe": "^1.0.1",
18 | "micro-cors": "^0.1.1",
19 | "mongodb": "^4.13.0",
20 | "next": "13.1.6",
21 | "numeral": "^2.0.6",
22 | "openai": "^3.2.1",
23 | "react": "18.2.0",
24 | "react-dom": "18.2.0",
25 | "sharp": "^0.32.1",
26 | "stripe": "^11.8.0"
27 | },
28 | "devDependencies": {
29 | "autoprefixer": "^10.4.13",
30 | "eslint": "8.33.0",
31 | "eslint-config-next": "13.1.6",
32 | "postcss": "^8.4.21",
33 | "tailwindcss": "^3.2.4"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/pages/_app.js:
--------------------------------------------------------------------------------
1 | import '../styles/globals.css'
2 |
3 | function MyApp({ Component, pageProps }) {
4 | return