Skip to content

Commit

Permalink
feat: validate t3 env on build
Browse files Browse the repository at this point in the history
  • Loading branch information
ixartz committed Aug 22, 2023
1 parent 77f6a65 commit 6d448ed
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"endOfLine": "auto"
}
],
"import/extensions": "off", // Avoid missing file extension errors, TypeScript already provides a similar feature
"react/function-component-definition": "off", // Disable Airbnb's specific function type
"react/destructuring-assignment": "off", // Vscode doesn't support automatically destructuring, it's a pain to add a new variable
"react/require-default-props": "off", // Allow non-defined react props as undefined
Expand Down
9 changes: 6 additions & 3 deletions next.config.js → next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* eslint-disable import/no-extraneous-dependencies */
const withBundleAnalyzer = require('@next/bundle-analyzer')({
/* eslint-disable import/no-extraneous-dependencies, import/extensions */
import './src/lib/Env.mjs';
import withBundleAnalyzer from '@next/bundle-analyzer';

const bundleAnalyzer = withBundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
});

/** @type {import('next').NextConfig} */
module.exports = withBundleAnalyzer({
export default bundleAnalyzer({
eslint: {
dirs: ['.'],
},
Expand Down
2 changes: 1 addition & 1 deletion src/lib/DB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';
import { migrate } from 'drizzle-orm/libsql/migrator';

import { Env } from './Env';
import { Env } from './Env.mjs';

const client = createClient({
url: Env.DATABASE_URL,
Expand Down
1 change: 1 addition & 0 deletions src/lib/Env.ts → src/lib/Env.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/prefer-default-export */
import { createEnv } from '@t3-oss/env-nextjs';
import process from 'process';
import { z } from 'zod';
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"allowJs": false,
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,

Expand All @@ -52,6 +53,7 @@
"**/*.ts",
"**/*.tsx",
".storybook/*.ts",
".next/types/**/*.ts"
".next/types/**/*.ts",
"src/lib/Env.mjs"
]
}

0 comments on commit 6d448ed

Please sign in to comment.