Skip to content

Commit

Permalink
fix: added env file checker
Browse files Browse the repository at this point in the history
  • Loading branch information
nolostra committed Sep 18, 2024
1 parent e585103 commit d7b6ec4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
15 changes: 11 additions & 4 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import { fileURLToPath } from "node:url";
import createJiti from "jiti";

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

// Import env here to validate during build. Using jiti we can import .ts files :)
jiti("./src/env");

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
Expand All @@ -9,12 +17,11 @@ const nextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
//Change it with your cdn access domain here
hostname: 'job-board.b-cdn.net',
protocol: "https",
hostname: "job-board.b-cdn.net", // Change this to your CDN domain
},
],
},
};

module.exports = nextConfig;
export default nextConfig; // ES module export
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "100xdevs-job-board",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down Expand Up @@ -47,6 +48,7 @@
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-toast": "^1.2.1",
"@t3-oss/env-nextjs": "^0.11.1",
"@types/lodash": "^4.17.7",
"@types/uuid": "^10.0.0",
"@uidotdev/usehooks": "^2.4.1",
Expand All @@ -55,6 +57,7 @@
"clsx": "^2.1.1",
"dayjs": "^1.11.13",
"framer-motion": "^11.5.4",
"jiti": "^1.21.6",
"lodash": "^4.17.21",
"lucide-react": "^0.426.0",
"next": "14.2.5",
Expand Down
2 changes: 1 addition & 1 deletion src/components/gmaps-autosuggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function GmapsAutocompleteAddress({ form }: { form: any }) {
return (
<>
<Script
src={`https://maps.googleapis.com/maps/api/js?key=${process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY}&libraries=places`}
src={`https://maps.googleapis.com/maps/api/js?key=${process.env.GOOGLE_MAPS_API_KEY}&libraries=places`}
strategy="lazyOnload"
onLoad={initializeGmaps}
/>
Expand Down
25 changes: 25 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { createEnv } from '@t3-oss/env-nextjs';
import { z } from 'zod';

export const env = createEnv({
server: {
DATABASE_URL: z.string().min(1),
POSTGRES_URL: z.string().min(1),
POSTGRES_HOST: z.string().min(1),
POSTGRES_USERNAME: z.string().min(1),
POSTGRES_PASSWORD: z.string().min(1),
NEXTAUTH_SECRET: z.string().min(1),
NEXTAUTH_URL: z.string().url(),
},
client: {},
// Specify the runtimeEnv manually for both server and client variables
runtimeEnv: {
DATABASE_URL: process.env.DATABASE_URL,
POSTGRES_URL: process.env.POSTGRES_URL,
POSTGRES_HOST: process.env.POSTGRES_HOST,
POSTGRES_USERNAME: process.env.POSTGRES_USERNAME,
POSTGRES_PASSWORD: process.env.POSTGRES_PASSWORD,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
},
});

0 comments on commit d7b6ec4

Please sign in to comment.