Add env variables & auth.js
This commit is contained in:
		
							
								
								
									
										61
									
								
								.eslintrc.cjs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								.eslintrc.cjs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
				
			|||||||
 | 
					/** @type {import("eslint").Linter.Config} */
 | 
				
			||||||
 | 
					const config = {
 | 
				
			||||||
 | 
					  "parser": "@typescript-eslint/parser",
 | 
				
			||||||
 | 
					  "parserOptions": {
 | 
				
			||||||
 | 
					    "project": true
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "plugins": [
 | 
				
			||||||
 | 
					    "@typescript-eslint",
 | 
				
			||||||
 | 
					    "drizzle"
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  "extends": [
 | 
				
			||||||
 | 
					    "next/core-web-vitals",
 | 
				
			||||||
 | 
					    "plugin:@typescript-eslint/recommended-type-checked",
 | 
				
			||||||
 | 
					    "plugin:@typescript-eslint/stylistic-type-checked"
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  "rules": {
 | 
				
			||||||
 | 
					    "@typescript-eslint/array-type": "off",
 | 
				
			||||||
 | 
					    "@typescript-eslint/consistent-type-definitions": "off",
 | 
				
			||||||
 | 
					    "@typescript-eslint/consistent-type-imports": [
 | 
				
			||||||
 | 
					      "warn",
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        "prefer": "type-imports",
 | 
				
			||||||
 | 
					        "fixStyle": "inline-type-imports"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "@typescript-eslint/no-unused-vars": [
 | 
				
			||||||
 | 
					      "warn",
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        "argsIgnorePattern": "^_"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "@typescript-eslint/require-await": "off",
 | 
				
			||||||
 | 
					    "@typescript-eslint/no-misused-promises": [
 | 
				
			||||||
 | 
					      "error",
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        "checksVoidReturn": {
 | 
				
			||||||
 | 
					          "attributes": false
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "drizzle/enforce-delete-with-where": [
 | 
				
			||||||
 | 
					      "error",
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        "drizzleObjectName": [
 | 
				
			||||||
 | 
					          "db",
 | 
				
			||||||
 | 
					          "ctx.db"
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "drizzle/enforce-update-with-where": [
 | 
				
			||||||
 | 
					      "error",
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        "drizzleObjectName": [
 | 
				
			||||||
 | 
					          "db",
 | 
				
			||||||
 | 
					          "ctx.db"
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					module.exports = config;
 | 
				
			||||||
							
								
								
									
										46
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# dependencies
 | 
				
			||||||
 | 
					/node_modules
 | 
				
			||||||
 | 
					/.pnp
 | 
				
			||||||
 | 
					.pnp.js
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# testing
 | 
				
			||||||
 | 
					/coverage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# database
 | 
				
			||||||
 | 
					/prisma/db.sqlite
 | 
				
			||||||
 | 
					/prisma/db.sqlite-journal
 | 
				
			||||||
 | 
					db.sqlite
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# next.js
 | 
				
			||||||
 | 
					/.next/
 | 
				
			||||||
 | 
					/out/
 | 
				
			||||||
 | 
					next-env.d.ts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# production
 | 
				
			||||||
 | 
					/build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# misc
 | 
				
			||||||
 | 
					.DS_Store
 | 
				
			||||||
 | 
					*.pem
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# debug
 | 
				
			||||||
 | 
					npm-debug.log*
 | 
				
			||||||
 | 
					yarn-debug.log*
 | 
				
			||||||
 | 
					yarn-error.log*
 | 
				
			||||||
 | 
					.pnpm-debug.log*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# local env files
 | 
				
			||||||
 | 
					# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
 | 
				
			||||||
 | 
					.env
 | 
				
			||||||
 | 
					.env*.local
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# vercel
 | 
				
			||||||
 | 
					.vercel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# typescript
 | 
				
			||||||
 | 
					*.tsbuildinfo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# idea files
 | 
				
			||||||
 | 
					.idea
 | 
				
			||||||
							
								
								
									
										5
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					# Tech Tracker Website
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### [Find Here](https://techtracker.gibbyb.com/)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Application used by COG employees to update their status & location throughout the day.
 | 
				
			||||||
							
								
								
									
										12
									
								
								drizzle.config.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								drizzle.config.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					import { type Config } from "drizzle-kit";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { env } from "~/env";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default {
 | 
				
			||||||
 | 
					  schema: "./src/server/db/schema.ts",
 | 
				
			||||||
 | 
					  dialect: "mysql",
 | 
				
			||||||
 | 
					  dbCredentials: {
 | 
				
			||||||
 | 
					    url: env.DATABASE_URL,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  tablesFilter: ["tech_tracker_web_*"],
 | 
				
			||||||
 | 
					} satisfies Config;
 | 
				
			||||||
							
								
								
									
										10
									
								
								next.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								next.config.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
 | 
				
			||||||
 | 
					 * for Docker builds.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					await import("./src/env.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** @type {import("next").NextConfig} */
 | 
				
			||||||
 | 
					const config = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default config;
 | 
				
			||||||
							
								
								
									
										48
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name": "tech_tracker_web",
 | 
				
			||||||
 | 
					  "version": "0.1.0",
 | 
				
			||||||
 | 
					  "private": true,
 | 
				
			||||||
 | 
					  "type": "module",
 | 
				
			||||||
 | 
					  "scripts": {
 | 
				
			||||||
 | 
					    "build": "next build",
 | 
				
			||||||
 | 
					    "db:generate": "drizzle-kit generate",
 | 
				
			||||||
 | 
					    "db:migrate": "drizzle-kit migrate",
 | 
				
			||||||
 | 
					    "db:push": "drizzle-kit push",
 | 
				
			||||||
 | 
					    "db:studio": "drizzle-kit studio",
 | 
				
			||||||
 | 
					    "dev": "next dev",
 | 
				
			||||||
 | 
					    "lint": "next lint",
 | 
				
			||||||
 | 
					    "start": "next start"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "dependencies": {
 | 
				
			||||||
 | 
					    "@t3-oss/env-nextjs": "^0.10.1",
 | 
				
			||||||
 | 
					    "drizzle-orm": "^0.30.10",
 | 
				
			||||||
 | 
					    "geist": "^1.3.0",
 | 
				
			||||||
 | 
					    "mysql2": "^3.9.7",
 | 
				
			||||||
 | 
					    "next": "^14.2.4",
 | 
				
			||||||
 | 
					    "next-auth": "5.0.0-beta.19",
 | 
				
			||||||
 | 
					    "react": "^18.3.1",
 | 
				
			||||||
 | 
					    "react-dom": "^18.3.1",
 | 
				
			||||||
 | 
					    "zod": "^3.23.3"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "devDependencies": {
 | 
				
			||||||
 | 
					    "@types/eslint": "^8.56.10",
 | 
				
			||||||
 | 
					    "@types/node": "^20.14.10",
 | 
				
			||||||
 | 
					    "@types/react": "^18.3.3",
 | 
				
			||||||
 | 
					    "@types/react-dom": "^18.3.0",
 | 
				
			||||||
 | 
					    "@typescript-eslint/eslint-plugin": "^7.1.1",
 | 
				
			||||||
 | 
					    "@typescript-eslint/parser": "^7.1.1",
 | 
				
			||||||
 | 
					    "drizzle-kit": "^0.21.4",
 | 
				
			||||||
 | 
					    "eslint": "^8.57.0",
 | 
				
			||||||
 | 
					    "eslint-config-next": "^14.2.4",
 | 
				
			||||||
 | 
					    "eslint-plugin-drizzle": "^0.2.3",
 | 
				
			||||||
 | 
					    "postcss": "^8.4.39",
 | 
				
			||||||
 | 
					    "prettier": "^3.3.2",
 | 
				
			||||||
 | 
					    "prettier-plugin-tailwindcss": "^0.6.5",
 | 
				
			||||||
 | 
					    "tailwindcss": "^3.4.3",
 | 
				
			||||||
 | 
					    "typescript": "^5.5.3"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "ct3aMetadata": {
 | 
				
			||||||
 | 
					    "initVersion": "7.36.1"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "packageManager": "pnpm@9.3.0"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										4603
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										4603
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										7
									
								
								postcss.config.cjs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								postcss.config.cjs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					const config = {
 | 
				
			||||||
 | 
					  plugins: {
 | 
				
			||||||
 | 
					    tailwindcss: {},
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module.exports = config;
 | 
				
			||||||
							
								
								
									
										6
									
								
								prettier.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								prettier.config.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */
 | 
				
			||||||
 | 
					const config = {
 | 
				
			||||||
 | 
					  plugins: ["prettier-plugin-tailwindcss"],
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default config;
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								public/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 15 KiB  | 
							
								
								
									
										2
									
								
								src/app/api/auth/[...nextauth]/route.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/app/api/auth/[...nextauth]/route.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					import { handlers } from "~/auth"
 | 
				
			||||||
 | 
					export const { GET, POST } = handlers
 | 
				
			||||||
							
								
								
									
										20
									
								
								src/app/layout.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/app/layout.tsx
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					import "~/styles/globals.css";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { GeistSans } from "geist/font/sans";
 | 
				
			||||||
 | 
					import { type Metadata } from "next";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const metadata: Metadata = {
 | 
				
			||||||
 | 
					  title: "Create T3 App",
 | 
				
			||||||
 | 
					  description: "Generated by create-t3-app",
 | 
				
			||||||
 | 
					  icons: [{ rel: "icon", url: "/favicon.ico" }],
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default function RootLayout({
 | 
				
			||||||
 | 
					  children,
 | 
				
			||||||
 | 
					}: Readonly<{ children: React.ReactNode }>) {
 | 
				
			||||||
 | 
					  return (
 | 
				
			||||||
 | 
					    <html lang="en" className={`${GeistSans.variable}`}>
 | 
				
			||||||
 | 
					      <body>{children}</body>
 | 
				
			||||||
 | 
					    </html>
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										37
									
								
								src/app/page.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/app/page.tsx
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					import Link from "next/link";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default function HomePage() {
 | 
				
			||||||
 | 
					  return (
 | 
				
			||||||
 | 
					    <main className="flex min-h-screen flex-col items-center justify-center bg-gradient-to-b from-[#2e026d] to-[#15162c] text-white">
 | 
				
			||||||
 | 
					      <div className="container flex flex-col items-center justify-center gap-12 px-4 py-16">
 | 
				
			||||||
 | 
					        <h1 className="text-5xl font-extrabold tracking-tight text-white sm:text-[5rem]">
 | 
				
			||||||
 | 
					          Create <span className="text-[hsl(280,100%,70%)]">T3</span> App
 | 
				
			||||||
 | 
					        </h1>
 | 
				
			||||||
 | 
					        <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:gap-8">
 | 
				
			||||||
 | 
					          <Link
 | 
				
			||||||
 | 
					            className="flex max-w-xs flex-col gap-4 rounded-xl bg-white/10 p-4 text-white hover:bg-white/20"
 | 
				
			||||||
 | 
					            href="https://create.t3.gg/en/usage/first-steps"
 | 
				
			||||||
 | 
					            target="_blank"
 | 
				
			||||||
 | 
					          >
 | 
				
			||||||
 | 
					            <h3 className="text-2xl font-bold">First Steps →</h3>
 | 
				
			||||||
 | 
					            <div className="text-lg">
 | 
				
			||||||
 | 
					              Just the basics - Everything you need to know to set up your
 | 
				
			||||||
 | 
					              database and authentication.
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					          </Link>
 | 
				
			||||||
 | 
					          <Link
 | 
				
			||||||
 | 
					            className="flex max-w-xs flex-col gap-4 rounded-xl bg-white/10 p-4 text-white hover:bg-white/20"
 | 
				
			||||||
 | 
					            href="https://create.t3.gg/en/introduction"
 | 
				
			||||||
 | 
					            target="_blank"
 | 
				
			||||||
 | 
					          >
 | 
				
			||||||
 | 
					            <h3 className="text-2xl font-bold">Documentation →</h3>
 | 
				
			||||||
 | 
					            <div className="text-lg">
 | 
				
			||||||
 | 
					              Learn more about Create T3 App, the libraries it uses, and how to
 | 
				
			||||||
 | 
					              deploy it.
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					          </Link>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					      </div>
 | 
				
			||||||
 | 
					    </main>
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										12
									
								
								src/auth.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/auth.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					import NextAuth from "next-auth"
 | 
				
			||||||
 | 
					import Entra from "next-auth/providers/microsoft-entra-id"
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					export const { handlers, auth, signIn, signOut } = NextAuth({
 | 
				
			||||||
 | 
					  providers: [
 | 
				
			||||||
 | 
					    Entra({
 | 
				
			||||||
 | 
					      clientId: process.env.AUTH_MICROSOFT_ENTRA_ID_ID,
 | 
				
			||||||
 | 
					      clientSecret: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET,
 | 
				
			||||||
 | 
					      tenantId: process.env.AUTH_MICROSOFT_ENTRA_ID_TENANT_ID,
 | 
				
			||||||
 | 
					    }),
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
							
								
								
									
										56
									
								
								src/env.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/env.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
				
			|||||||
 | 
					import { createEnv } from "@t3-oss/env-nextjs";
 | 
				
			||||||
 | 
					import { z } from "zod";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const env = createEnv({
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Specify your server-side environment variables schema here. This way you can ensure the app
 | 
				
			||||||
 | 
					   * isn't built with invalid env vars.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  server: {
 | 
				
			||||||
 | 
					    DATABASE_URL: z.string().url(),
 | 
				
			||||||
 | 
					    NODE_ENV: z
 | 
				
			||||||
 | 
					      .enum(["development", "test", "production"])
 | 
				
			||||||
 | 
					      .default("development"),
 | 
				
			||||||
 | 
					    API_KEY: z.string(),
 | 
				
			||||||
 | 
					    AUTH_SECRET: 
 | 
				
			||||||
 | 
					      process.env.NODE_ENV === "production"
 | 
				
			||||||
 | 
					        ? z.string()
 | 
				
			||||||
 | 
					        : z.string().optional(),
 | 
				
			||||||
 | 
					    AUTH_MICROSOFT_ENTRA_ID: z.string(),
 | 
				
			||||||
 | 
					    AUTH_MICROSOFT_ENTRA_SECRET: z.string(),
 | 
				
			||||||
 | 
					    AUTH_MICROSOFT_ENTRA_TENANT_ID: z.string(),
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Specify your client-side environment variables schema here. This way you can ensure the app
 | 
				
			||||||
 | 
					   * isn't built with invalid env vars. To expose them to the client, prefix them with
 | 
				
			||||||
 | 
					   * `NEXT_PUBLIC_`.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  client: {
 | 
				
			||||||
 | 
					    // NEXT_PUBLIC_CLIENTVAR: z.string(),
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
 | 
				
			||||||
 | 
					   * middlewares) or client-side so we need to destruct manually.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  runtimeEnv: {
 | 
				
			||||||
 | 
					    DATABASE_URL: process.env.DATABASE_URL,
 | 
				
			||||||
 | 
					    NODE_ENV: process.env.NODE_ENV,
 | 
				
			||||||
 | 
					    API_KEY: process.env.API_KEY,
 | 
				
			||||||
 | 
					    AUTH_SECRET: process.env.AUTH_SECRET,
 | 
				
			||||||
 | 
					    AUTH_MICROSOFT_ENTRA_ID: process.env.AUTH_MICROSOFT_ENTRA_ID,
 | 
				
			||||||
 | 
					    AUTH_MICROSOFT_ENTRA_SECRET: process.env.AUTH_MICROSOFT_ENTRA_SECRET,
 | 
				
			||||||
 | 
					    AUTH_MICROSOFT_ENTRA_TENANT_ID: process.env.AUTH_MICROSOFT_ENTRA_TENANT_ID,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
 | 
				
			||||||
 | 
					   * useful for Docker builds.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  skipValidation: !!process.env.SKIP_ENV_VALIDATION,
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
 | 
				
			||||||
 | 
					   * `SOME_VAR=''` will throw an error.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  emptyStringAsUndefined: true,
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
							
								
								
									
										18
									
								
								src/server/db/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/server/db/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					import { drizzle } from "drizzle-orm/mysql2";
 | 
				
			||||||
 | 
					import { createPool, type Pool } from "mysql2/promise";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { env } from "~/env";
 | 
				
			||||||
 | 
					import * as schema from "./schema";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Cache the database connection in development. This avoids creating a new connection on every HMR
 | 
				
			||||||
 | 
					 * update.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					const globalForDb = globalThis as unknown as {
 | 
				
			||||||
 | 
					  conn: Pool | undefined;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const conn = globalForDb.conn ?? createPool({ uri: env.DATABASE_URL });
 | 
				
			||||||
 | 
					if (env.NODE_ENV !== "production") globalForDb.conn = conn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const db = drizzle(conn, { schema, mode: "default" });
 | 
				
			||||||
							
								
								
									
										34
									
								
								src/server/db/schema.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/server/db/schema.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					// Example model schema from the Drizzle docs
 | 
				
			||||||
 | 
					// https://orm.drizzle.team/docs/sql-schema-declaration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { sql } from "drizzle-orm";
 | 
				
			||||||
 | 
					import {
 | 
				
			||||||
 | 
					  bigint,
 | 
				
			||||||
 | 
					  index,
 | 
				
			||||||
 | 
					  mysqlTableCreator,
 | 
				
			||||||
 | 
					  timestamp,
 | 
				
			||||||
 | 
					  varchar,
 | 
				
			||||||
 | 
					} from "drizzle-orm/mysql-core";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
 | 
				
			||||||
 | 
					 * database instance for multiple projects.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @see https://orm.drizzle.team/docs/goodies#multi-project-schema
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export const createTable = mysqlTableCreator((name) => `tech_tracker_web_${name}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const posts = createTable(
 | 
				
			||||||
 | 
					  "post",
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    id: bigint("id", { mode: "number" }).primaryKey().autoincrement(),
 | 
				
			||||||
 | 
					    name: varchar("name", { length: 256 }),
 | 
				
			||||||
 | 
					    createdAt: timestamp("created_at")
 | 
				
			||||||
 | 
					      .default(sql`CURRENT_TIMESTAMP`)
 | 
				
			||||||
 | 
					      .notNull(),
 | 
				
			||||||
 | 
					    updatedAt: timestamp("updated_at").onUpdateNow(),
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  (example) => ({
 | 
				
			||||||
 | 
					    nameIndex: index("name_idx").on(example.name),
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
							
								
								
									
										3
									
								
								src/styles/globals.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/styles/globals.css
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					@tailwind base;
 | 
				
			||||||
 | 
					@tailwind components;
 | 
				
			||||||
 | 
					@tailwind utilities;
 | 
				
			||||||
							
								
								
									
										14
									
								
								tailwind.config.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								tailwind.config.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					import { type Config } from "tailwindcss";
 | 
				
			||||||
 | 
					import { fontFamily } from "tailwindcss/defaultTheme";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default {
 | 
				
			||||||
 | 
					  content: ["./src/**/*.tsx"],
 | 
				
			||||||
 | 
					  theme: {
 | 
				
			||||||
 | 
					    extend: {
 | 
				
			||||||
 | 
					      fontFamily: {
 | 
				
			||||||
 | 
					        sans: ["var(--font-geist-sans)", ...fontFamily.sans],
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  plugins: [],
 | 
				
			||||||
 | 
					} satisfies Config;
 | 
				
			||||||
							
								
								
									
										42
									
								
								tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								tsconfig.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "compilerOptions": {
 | 
				
			||||||
 | 
					    /* Base Options: */
 | 
				
			||||||
 | 
					    "esModuleInterop": true,
 | 
				
			||||||
 | 
					    "skipLibCheck": true,
 | 
				
			||||||
 | 
					    "target": "es2022",
 | 
				
			||||||
 | 
					    "allowJs": true,
 | 
				
			||||||
 | 
					    "resolveJsonModule": true,
 | 
				
			||||||
 | 
					    "moduleDetection": "force",
 | 
				
			||||||
 | 
					    "isolatedModules": true,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Strictness */
 | 
				
			||||||
 | 
					    "strict": true,
 | 
				
			||||||
 | 
					    "noUncheckedIndexedAccess": true,
 | 
				
			||||||
 | 
					    "checkJs": true,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Bundled projects */
 | 
				
			||||||
 | 
					    "lib": ["dom", "dom.iterable", "ES2022"],
 | 
				
			||||||
 | 
					    "noEmit": true,
 | 
				
			||||||
 | 
					    "module": "ESNext",
 | 
				
			||||||
 | 
					    "moduleResolution": "Bundler",
 | 
				
			||||||
 | 
					    "jsx": "preserve",
 | 
				
			||||||
 | 
					    "plugins": [{ "name": "next" }],
 | 
				
			||||||
 | 
					    "incremental": true,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Path Aliases */
 | 
				
			||||||
 | 
					    "baseUrl": ".",
 | 
				
			||||||
 | 
					    "paths": {
 | 
				
			||||||
 | 
					      "~/*": ["./src/*"]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "include": [
 | 
				
			||||||
 | 
					    ".eslintrc.cjs",
 | 
				
			||||||
 | 
					    "next-env.d.ts",
 | 
				
			||||||
 | 
					    "**/*.ts",
 | 
				
			||||||
 | 
					    "**/*.tsx",
 | 
				
			||||||
 | 
					    "**/*.cjs",
 | 
				
			||||||
 | 
					    "**/*.js",
 | 
				
			||||||
 | 
					    ".next/types/**/*.ts"
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  "exclude": ["node_modules"]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user