Skip to content

Commit

Permalink
Chore/NS-21-configure-T3-env (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skolaczk authored Jan 30, 2024
1 parent 7a77b76 commit 32a68fe
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 13 deletions.
45 changes: 43 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@
},
"dependencies": {
"@radix-ui/react-slot": "^1.0.2",
"@t3-oss/env-nextjs": "^0.8.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.312.0",
"next": "14.1.0",
"next-themes": "^0.2.1",
"react": "^18",
"react-dom": "^18",
"tailwind-merge": "^2.2.1"
"tailwind-merge": "^2.2.1",
"zod": "^3.22.4"
},
"devDependencies": {
"@commitlint/cli": "^18.6.0",
Expand Down
8 changes: 1 addition & 7 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import { defineConfig, devices } from '@playwright/test';
* See https://playwright.dev/docs/test-configuration.
*/

// Use process.env.PORT by default and fallback to port 3000
const PORT = process.env.PORT || 3000;

// Set webServer.url and use.baseURL with the location of the WebServer respecting the correct set port
const baseURL = `http://localhost:${PORT}`;

export default defineConfig({
testDir: './src/__tests__/e2e',
/* Run tests in files in parallel */
Expand All @@ -31,7 +25,7 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL,
baseURL: 'http://localhost:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
Expand Down
14 changes: 14 additions & 0 deletions src/env.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createEnv } from '@t3-oss/env-nextjs';
import { z } from 'zod';

export const env = createEnv({
server: {
NEXT_PUBLIC_SITE_URL: z.string().url(),
NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION_ID: z.string().min(1),
},
runtimeEnv: {
NEXT_PUBLIC_SITE_URL: process.env.NEXT_PUBLIC_SITE_URL,
NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION_ID:
process.env.NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION_ID,
},
});
7 changes: 4 additions & 3 deletions src/lib/constant.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { env } from '@/env.mjs';

export const siteConfig = {
title: 'Next.js Starter',
description:
Expand Down Expand Up @@ -27,7 +29,6 @@ export const siteConfig = {
'Efficient Development',
'Code Quality',
],
url: process.env.NEXT_PUBLIC_SITE_URL || 'https://example.com',
googleSiteVerificationId:
process.env.NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION_ID || '',
url: env.NEXT_PUBLIC_SITE_URL || 'https://example.com',
googleSiteVerificationId: env.NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION_ID || '',
};

0 comments on commit 32a68fe

Please sign in to comment.