Skip to content

Commit

Permalink
feat: updates more packages including t3 env
Browse files Browse the repository at this point in the history
  • Loading branch information
ixahmedxi committed May 14, 2024
1 parent 489aa18 commit 7b61028
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 34 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Config } from "drizzle-kit";
import { env } from "./src/env.mjs";
import { env } from "./src/env";

export default {
schema: "./src/db/schema/index.ts",
Expand Down
9 changes: 7 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import createMDX from "@next/mdx";
import { fileURLToPath } from "node:url";
import rehypeSlug from "rehype-slug";
import remarkGfm from "remark-gfm";
import "./src/env.mjs";

import createJiti from "jiti";

const jiti = createJiti(fileURLToPath(import.meta.url));

jiti("./src/env");

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
pageExtensions: ["mdx", "ts", "tsx"],
experimental: {
serverComponentsExternalPackages: ["libsql"],
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@nextui-org/react": "^2.3.6",
"@paralleldrive/cuid2": "^2.2.2",
"@radix-ui/react-scroll-area": "^1.0.5",
"@t3-oss/env-nextjs": "^0.7.1",
"@t3-oss/env-nextjs": "^0.10.1",
"@tanstack/react-query": "4.36.1",
"@tanstack/react-query-next-experimental": "^5.36.0",
"@tanstack/react-virtual": "beta",
Expand Down Expand Up @@ -73,10 +73,10 @@
"encoding": "^0.1.13",
"eslint": "8.55.0",
"eslint-config-next": "14.2.3",
"framer-motion": "^10.16.16",
"lucide-react": "^0.294.0",
"framer-motion": "^11.2.0",
"lucide-react": "^0.378.0",
"next": "14.2.3",
"next-themes": "^0.2.1",
"next-themes": "^0.3.0",
"node-fetch": "^3.3.2",
"postcss": "8.4.38",
"react": "18.3.1",
Expand All @@ -97,20 +97,21 @@
"tailwindcss": "3.4.3",
"typescript": "5.4.5",
"use-resize-observer": "^9.1.0",
"usehooks-ts": "^2.9.1",
"usehooks-ts": "^3.1.0",
"utf-8-validate": "^6.0.4",
"zod": "^3.23.8"
},
"devDependencies": {
"@savvywombat/tailwindcss-grid-areas": "^3.1.0",
"@tailwindcss/typography": "^0.5.10",
"@savvywombat/tailwindcss-grid-areas": "^4.0.0",
"@tailwindcss/typography": "^0.5.13",
"@types/eslint": "^8.56.10",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"drizzle-kit": "^0.20.6",
"jiti": "^1.21.0",
"node-gyp": "^10.1.0",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.9",
"prettier-plugin-tailwindcss": "^0.5.14",
"rimraf": "^5.0.7"
}
}
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CookieBanner, NoodleAnalytics } from "@/components/cookie-banner";
import { ClerkProvider } from "@clerk/nextjs";
import { dark } from "@clerk/themes";
import type { Metadata } from "next";
import { ThemeProvider } from "next-themes";
import { Inter, JetBrains_Mono } from "next/font/google";
import { siteConfig } from "./config";
import "./globals.css";
Expand Down Expand Up @@ -56,7 +57,9 @@ export default function RootLayout({
>
<html lang="en">
<body className={`${sans.variable} ${mono.variable} font-sans`}>
<Providers>{children}</Providers>
<ThemeProvider attribute="class" enableSystem>
<Providers>{children}</Providers>
</ThemeProvider>
<CookieBanner />
<NoodleAnalytics />
</body>
Expand Down
10 changes: 4 additions & 6 deletions src/app/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import { NextUIProvider } from "@nextui-org/react";
import { ThemeProvider as NextThemesProvider, useTheme } from "next-themes";
import { type PropsWithChildren, useEffect, useState } from "react";
import { useTheme } from "next-themes";
import { useEffect, useState, type PropsWithChildren } from "react";
import { Toaster } from "sonner";

const ToastProvider = () => {
Expand All @@ -29,10 +29,8 @@ const ToastProvider = () => {
export function Providers({ children }: PropsWithChildren) {
return (
<NextUIProvider>
<NextThemesProvider attribute="class" enableSystem>
<ToastProvider />
{children}
</NextThemesProvider>
<ToastProvider />
{children}
</NextUIProvider>
);
}
2 changes: 1 addition & 1 deletion src/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { env } from "@/env.mjs";
import { env } from "@/env";
import { createClient } from "@libsql/client";
import { drizzle } from "drizzle-orm/libsql";
import * as schema from "./schema";
Expand Down
28 changes: 18 additions & 10 deletions src/env.mjs → src/env.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
// @ts-check
import { createEnv } from "@t3-oss/env-nextjs";
import { vercel } from "@t3-oss/env-nextjs/presets";
import { z } from "zod";

export const env = createEnv({
server: {
DATABASE_URL: z.string().url(),
DATABASE_AUTH_TOKEN: z.string().optional(),
extends: [vercel()],

shared: {
NODE_ENV: z
.enum(["development", "test", "production"])
.default("development"),
},
server: {
// Turso DB
DATABASE_URL: z.string().url(),
DATABASE_AUTH_TOKEN: z.string().optional(),

// Upstash
UPSTASH_REDIS_REST_URL: z.string().optional(),
UPSTASH_REDIS_REST_TOKEN: z.string().optional(),

// Clerk
CLERK_SECRET_KEY: z.string().min(1),
},
client: {
// Clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string().min(1),
},
runtimeEnv: {
DATABASE_URL: process.env.DATABASE_URL,
DATABASE_AUTH_TOKEN: process.env.DATABASE_AUTH_TOKEN,

experimental__runtimeEnv: {
NODE_ENV: process.env.NODE_ENV,
CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY,
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY:
process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
UPSTASH_REDIS_REST_TOKEN: process.env.UPSTASH_REDIS_REST_TOKEN,
UPSTASH_REDIS_REST_URL: process.env.UPSTASH_REDIS_REST_URL,
},

skipValidation: !!process.env.SKIP_ENV_VALIDATION,
emptyStringAsUndefined: true,
});
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";
import { NextResponse } from "next/server";
import { env } from "./env.mjs";
import { env } from "./env";

let redis: Redis;
let ratelimit: Ratelimit;
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/trpc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { db } from "@/db";
import { env } from "@/env.mjs";
import { env } from "@/env";
import { getAuth } from "@clerk/nextjs/server";
import { TRPCError, initTRPC } from "@trpc/server";
import { Redis } from "@upstash/redis";
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
Expand Down

0 comments on commit 7b61028

Please sign in to comment.