Skip to content

Commit

Permalink
cleanup and fix env
Browse files Browse the repository at this point in the history
Signed-off-by: Shreyans Jain <shreyans@shreyans.sh>
  • Loading branch information
CodeWithShreyans committed Dec 9, 2023
1 parent 4a834b4 commit 6b39ca3
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 440 deletions.
12 changes: 0 additions & 12 deletions drizzle.config.ts

This file was deleted.

6 changes: 2 additions & 4 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import { withContentlayer } from "next-contentlayer"
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
await import("./src/env.mjs")
const { env } = await import("./src/env.mjs")

/** @type {import("next").NextConfig} */
const config = {
compiler: {
removeConsole:
process.env.NODE_ENV === "production"
? { exclude: ["error"] }
: false,
env.NODE_ENV === "production" ? { exclude: ["error"] } : false,
},
experimental: {
ppr: true,
Expand Down
144 changes: 66 additions & 78 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,79 +1,67 @@
{
"name": "shreyans.sh",
"version": "2.0.0",
"private": true,
"scripts": {
"build": "next build",
"db:push": "dotenv drizzle-kit push:mysql",
"db:studio": "dotenv drizzle-kit studio",
"dev": "next dev",
"lint": "next lint",
"start": "next start"
},
"dependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
"@js-temporal/polyfill": "^0.4.4",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tooltip": "^1.0.7",
"@sentry/nextjs": "^7.85.0",
"@t3-oss/env-nextjs": "^0.7.1",
"@tanstack/react-query": "^5.12.2",
"@trpc/client": "^10.44.1",
"@trpc/next": "^10.44.1",
"@trpc/react-query": "^10.44.1",
"@trpc/server": "^10.44.1",
"@types/luxon": "^3.3.7",
"@unpic/react": "^0.1.4",
"@vercel/analytics": "^1.1.1",
"@vercel/kv": "^1.0.1",
"class-variance-authority": "^0.7.0",
"drizzle-orm": "^0.29.1",
"eslint-plugin-perfectionist": "^2.5.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-tailwindcss": "^3.13.0",
"geist": "^1.2.0",
"html-react-parser": "^5.0.7",
"lucide-react": "^0.294.0",
"luxon": "^3.4.4",
"next": "canary",
"next-contentlayer": "^0.3.4",
"next-themes": "^0.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-spring": "^9.7.3",
"rehype-slug": "^6.0.0",
"remark-gfm": "^4.0.0",
"remark-hint": "^1.0.10",
"shiki": "^0.14.5",
"superjson": "^2.2.1",
"tailwind-merge": "^2.1.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/eslint": "^8.44.8",
"@types/node": "^20.10.4",
"@types/react": "^18.2.42",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"autoprefixer": "^10.4.16",
"dotenv-cli": "^7.3.0",
"drizzle-kit": "^0.20.6",
"eslint": "^8.55.0",
"eslint-config-next": "^14.0.3",
"postcss": "^8.4.32",
"prettier": "^3.1.0",
"tailwindcss": "insiders",
"typescript": "^5.3.3"
},
"nextBundleAnalysis": {
"budget": null,
"budgetPercentIncreaseRed": 20,
"minimumChangeThreshold": 0,
"showDetails": true
}
}
"name": "shreyans.sh",
"version": "2.0.0",
"private": true,
"scripts": {
"build": "next build",
"db:push": "dotenv drizzle-kit push:mysql",
"db:studio": "dotenv drizzle-kit studio",
"dev": "next dev",
"lint": "next lint",
"start": "next start"
},
"dependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tooltip": "^1.0.7",
"@sentry/nextjs": "^7.85.0",
"@t3-oss/env-nextjs": "^0.7.1",
"@vercel/analytics": "^1.1.1",
"class-variance-authority": "^0.7.0",
"eslint-plugin-perfectionist": "^2.5.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-tailwindcss": "^3.13.0",
"geist": "^1.2.0",
"html-react-parser": "^5.0.7",
"lucide-react": "^0.294.0",
"next": "canary",
"next-contentlayer": "^0.3.4",
"next-themes": "^0.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-spring": "^9.7.3",
"rehype-slug": "^6.0.0",
"remark-gfm": "^4.0.0",
"remark-hint": "^1.0.10",
"shiki": "^0.14.5",
"tailwind-merge": "^2.1.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/eslint": "^8.44.8",
"@types/node": "^20.10.4",
"@types/react": "^18.2.42",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"autoprefixer": "^10.4.16",
"dotenv-cli": "^7.3.0",
"drizzle-kit": "^0.20.6",
"eslint": "^8.55.0",
"eslint-config-next": "^14.0.3",
"postcss": "^8.4.32",
"prettier": "^3.1.0",
"tailwindcss": "insiders",
"typescript": "^5.3.3"
},
"nextBundleAnalysis": {
"budget": null,
"budgetPercentIncreaseRed": 20,
"minimumChangeThreshold": 0,
"showDetails": true
}
}
3 changes: 2 additions & 1 deletion src/app/(pages)/blog/views.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unstable_noStore } from "next/cache"

import { env } from "@/env.mjs"
import { cn } from "@/lib/utils"

type SentryResponse = {
Expand All @@ -26,7 +27,7 @@ const getViews = async (slug: string) => {
api.searchParams.set("query", `(transaction:/blog/${slug})`)
const views = await fetch(api, {
headers: {
Authorization: `Bearer ${process.env.SENTRY_TOKEN}`,
Authorization: `Bearer ${env.SENTRY_TOKEN}`,
},
})

Expand Down
2 changes: 0 additions & 2 deletions src/app/(pages)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export default function RootLayout({
className="mx-auto flex h-fit min-h-screen max-w-xl flex-col items-center justify-between gap-2 px-4 text-base sm:max-w-[46rem]"
id="body"
>
{/* <TRPCReactProvider headers={headers()}> */}
<ThemeProvider
attribute="class"
defaultTheme="system"
Expand All @@ -100,7 +99,6 @@ export default function RootLayout({
</div>
<Footer />
</ThemeProvider>
{/* </TRPCReactProvider> */}
<Analytics />
</body>
</html>
Expand Down
27 changes: 0 additions & 27 deletions src/app/_api/trpc/[trpc]/route.ts

This file was deleted.

18 changes: 9 additions & 9 deletions src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export const env = createEnv({
* isn't built with invalid env vars. To expose them to the client, prefix them with
* `NEXT_PUBLIC_`.
*/
client: {},
client: {
NEXT_PUBLIC_SENTRY_DSN: z.string(),
},

/**
* Makes it so that empty strings are treated as undefined.
Expand All @@ -20,24 +22,22 @@ export const env = createEnv({
* middlewares) or client-side so we need to destruct manually.
*/
runtimeEnv: {
// DATABASE_URL: process.env.DATABASE_URL,
NEXT_PUBLIC_SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN,

NODE_ENV: process.env.NODE_ENV,

SENTRY_TOKEN: process.env.SENTRY_TOKEN,
},
/**
* 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()
// .refine(
// (str) => !str.includes("YOUR_MYSQL_URL_HERE"),
// "You forgot to change the default URL",
// ),
NODE_ENV: z
.enum(["development", "test", "production"])
.default("development"),

SENTRY_TOKEN: z.string(),
},
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
Expand Down
4 changes: 3 additions & 1 deletion src/lib/utils/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import React from "react"

import { animated, useSpring } from "react-spring"

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

import { random } from "."

const useHasMounted = () => {
Expand Down Expand Up @@ -260,7 +262,7 @@ const VisuallyHidden = ({
}
const [forceShow, setForceShow] = React.useState(false)
React.useEffect(() => {
if (process.env.NODE_ENV !== "production") {
if (env.NODE_ENV !== "production") {
const handleKeyDown = (ev: KeyboardEvent) => {
if (ev.key === "Alt") {
setForceShow(true)
Expand Down
14 changes: 0 additions & 14 deletions src/server/api/root.ts

This file was deleted.

31 changes: 0 additions & 31 deletions src/server/api/routers/post.ts

This file was deleted.

Loading

0 comments on commit 6b39ca3

Please sign in to comment.