Skip to content

Commit

Permalink
feat: migreate Env.mjs file to Env.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ixartz committed May 10, 2024
1 parent 75c9751 commit 2e6ff12
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
10 changes: 8 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/* eslint-disable import/no-extraneous-dependencies, import/extensions */
import { withSentryConfig } from '@sentry/nextjs';
import './src/libs/Env.mjs';
import { fileURLToPath } from 'node:url';

import withBundleAnalyzer from '@next/bundle-analyzer';
import { withSentryConfig } from '@sentry/nextjs';
import createJiti from 'jiti';
import withNextIntl from 'next-intl/plugin';

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

jiti('./src/libs/Env');

const withNextIntlConfig = withNextIntl('./src/libs/i18n.ts');

const bundleAnalyzer = withBundleAnalyzer({
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-fail-on-console": "^3.2.0",
"jiti": "^1.21.0",
"lint-staged": "^15.2.2",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.38",
Expand Down
2 changes: 1 addition & 1 deletion src/libs/DB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { migrate } from 'drizzle-orm/libsql/migrator';

import * as schema from '@/models/Schema';

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

const client = createClient({
url: Env.DATABASE_URL,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/Env.mjs → src/libs/Env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const Env = createEnv({
STRIPE_WEBHOOK_SECRET: z.string().min(1),
},
client: {
NEXT_PUBLIC_APP_URL: z.string().optional(),
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string().min(1),
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.string().min(1),
},
Expand All @@ -24,6 +25,7 @@ export const Env = createEnv({
LOGTAIL_SOURCE_TOKEN: process.env.LOGTAIL_SOURCE_TOKEN,
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY,
STRIPE_WEBHOOK_SECRET: process.env.STRIPE_WEBHOOK_SECRET,
NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY:
process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY:
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pino from 'pino';

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

let options = {};

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
"**/*.tsx",
".storybook/*.ts",
".next/types/**/*.ts",
"src/libs/Env.mjs"
"src/libs/Env.ts"
]
}

0 comments on commit 2e6ff12

Please sign in to comment.