Skip to content

Commit 38aab1e

Browse files
committed
chore: use t3-env as source of truth
1 parent b594e99 commit 38aab1e

File tree

18 files changed

+53
-37
lines changed

18 files changed

+53
-37
lines changed

apps/sim/app/api/workflows/[id]/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type NextRequest, NextResponse } from 'next/server'
33
import { z } from 'zod'
44
import { getSession } from '@/lib/auth'
55
import { verifyInternalToken } from '@/lib/auth/internal'
6+
import { env } from '@/lib/env'
67
import { createLogger } from '@/lib/logs/console-logger'
78
import { getUserEntityPermissions, hasAdminPermission } from '@/lib/permissions/utils'
89
import { loadWorkflowFromNormalizedTables } from '@/lib/workflows/db-helpers'
@@ -224,7 +225,7 @@ export async function DELETE(
224225
// This prevents "Block not found" errors when collaborative updates try to process
225226
// after the workflow has been deleted
226227
try {
227-
const socketUrl = process.env.SOCKET_SERVER_URL || 'http://localhost:3002'
228+
const socketUrl = env.SOCKET_SERVER_URL || 'http://localhost:3002'
228229
const socketResponse = await fetch(`${socketUrl}/api/workflow-deleted`, {
229230
method: 'POST',
230231
headers: { 'Content-Type': 'application/json' },

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/components/chat-deploy/chat-deploy.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { Input } from '@/components/ui/input'
3030
import { Label } from '@/components/ui/label'
3131
import { Skeleton } from '@/components/ui/skeleton'
3232
import { Textarea } from '@/components/ui/textarea'
33+
import { env } from '@/lib/env'
3334
import { createLogger } from '@/lib/logs/console-logger'
3435
import { getBaseDomain } from '@/lib/urls/utils'
3536
import { cn } from '@/lib/utils'
@@ -54,7 +55,7 @@ interface ChatDeployProps {
5455
type AuthType = 'public' | 'password' | 'email'
5556

5657
const getDomainSuffix = (() => {
57-
const suffix = process.env.NODE_ENV === 'development' ? `.${getBaseDomain()}` : '.simstudio.ai'
58+
const suffix = env.NODE_ENV === 'development' ? `.${getBaseDomain()}` : '.simstudio.ai'
5859
return () => suffix
5960
})()
6061

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useParams, usePathname, useRouter } from 'next/navigation'
77
import { Skeleton } from '@/components/ui/skeleton'
88
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
99
import { useSession } from '@/lib/auth-client'
10+
import { env } from '@/lib/env'
1011
import { createLogger } from '@/lib/logs/console-logger'
1112
import {
1213
getKeyboardShortcutText,
@@ -27,7 +28,7 @@ import { WorkspaceHeader } from './components/workspace-header/workspace-header'
2728

2829
const logger = createLogger('Sidebar')
2930

30-
const IS_DEV = process.env.NODE_ENV === 'development'
31+
const IS_DEV = env.NODE_ENV === 'development'
3132

3233
export function Sidebar() {
3334
useGlobalShortcuts()

apps/sim/blocks/blocks/file.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { DocumentIcon } from '@/components/icons'
2+
import { env } from '@/lib/env'
23
import { createLogger } from '@/lib/logs/console-logger'
34
import type { FileParserOutput } from '@/tools/file/types'
45
import type { BlockConfig, SubBlockConfig, SubBlockLayout, SubBlockType } from '../types'
56

67
const logger = createLogger('FileBlock')
78

8-
const shouldEnableURLInput = process.env.NODE_ENV === 'production'
9+
const shouldEnableURLInput = env.NODE_ENV === 'production'
910

1011
const inputMethodBlock: SubBlockConfig = {
1112
id: 'inputMethod',

apps/sim/blocks/blocks/mistral_parse.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { MistralIcon } from '@/components/icons'
2+
import { env } from '@/lib/env'
23
import type { MistralParserOutput } from '@/tools/mistral/types'
34
import type { BlockConfig, SubBlockConfig, SubBlockLayout, SubBlockType } from '../types'
45

5-
const shouldEnableFileUpload = process.env.NODE_ENV === 'production'
6+
const shouldEnableFileUpload = env.NODE_ENV === 'production'
67

78
const inputMethodBlock: SubBlockConfig = {
89
id: 'inputMethod',

apps/sim/components/emails/workspace-invitation.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Section,
1212
Text,
1313
} from '@react-email/components'
14+
import { env } from '@/lib/env'
1415
import { baseStyles } from './base-styles'
1516
import EmailFooter from './footer'
1617

@@ -20,7 +21,7 @@ interface WorkspaceInvitationEmailProps {
2021
invitationLink?: string
2122
}
2223

23-
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
24+
const baseUrl = env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
2425

2526
export const WorkspaceInvitationEmail = ({
2627
workspaceName = 'Workspace',

apps/sim/contexts/socket-context.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from 'react'
1212
import { useParams } from 'next/navigation'
1313
import { io, type Socket } from 'socket.io-client'
14+
import { env } from '@/lib/env'
1415
import { createLogger } from '@/lib/logs/console-logger'
1516

1617
const logger = createLogger('SocketContext')
@@ -134,7 +135,7 @@ export function SocketProvider({ children, user }: SocketProviderProps) {
134135
// Generate initial token for socket authentication
135136
const token = await generateSocketToken()
136137

137-
const socketUrl = process.env.NEXT_PUBLIC_SOCKET_URL || 'http://localhost:3002'
138+
const socketUrl = env.NEXT_PUBLIC_SOCKET_URL || 'http://localhost:3002'
138139

139140
logger.info('Attempting to connect to Socket.IO server', {
140141
url: socketUrl,

apps/sim/db/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ declare global {
3838
}
3939

4040
export const db = global.database || drizzleClient
41-
if (process.env.NODE_ENV !== 'production') global.database = db
41+
if (env.NODE_ENV !== 'production') global.database = db

apps/sim/lib/auth-client.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { stripeClient } from '@better-auth/stripe/client'
22
import { emailOTPClient, genericOAuthClient, organizationClient } from 'better-auth/client/plugins'
33
import { createAuthClient } from 'better-auth/react'
4+
import { env } from './env'
45

56
const clientEnv = {
6-
NEXT_PUBLIC_VERCEL_URL: process.env.NEXT_PUBLIC_VERCEL_URL,
7-
NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
8-
NODE_ENV: process.env.NODE_ENV,
9-
VERCEL_ENV: process.env.VERCEL_ENV || '',
10-
BETTER_AUTH_URL: process.env.BETTER_AUTH_URL,
7+
NEXT_PUBLIC_VERCEL_URL: env.NEXT_PUBLIC_VERCEL_URL,
8+
NEXT_PUBLIC_APP_URL: env.NEXT_PUBLIC_APP_URL,
9+
NODE_ENV: env.NODE_ENV,
10+
VERCEL_ENV: env.VERCEL_ENV || '',
11+
BETTER_AUTH_URL: env.BETTER_AUTH_URL,
1112
}
1213

1314
export function getBaseURL() {

apps/sim/lib/email/unsubscribe.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { eq } from 'drizzle-orm'
33
import { createLogger } from '@/lib/logs/console-logger'
44
import { db } from '@/db'
55
import { settings, user } from '@/db/schema'
6+
import { env } from '../env'
67
import type { EmailType } from './mailer'
78

89
const logger = createLogger('Unsubscribe')
@@ -20,7 +21,7 @@ export interface EmailPreferences {
2021
export function generateUnsubscribeToken(email: string, emailType = 'marketing'): string {
2122
const salt = randomBytes(16).toString('hex')
2223
const hash = createHash('sha256')
23-
.update(`${email}:${salt}:${emailType}:${process.env.BETTER_AUTH_SECRET}`)
24+
.update(`${email}:${salt}:${emailType}:${env.BETTER_AUTH_SECRET}`)
2425
.digest('hex')
2526

2627
return `${salt}:${hash}:${emailType}`
@@ -41,7 +42,7 @@ export function verifyUnsubscribeToken(
4142
if (parts.length === 2) {
4243
const [salt, expectedHash] = parts
4344
const hash = createHash('sha256')
44-
.update(`${email}:${salt}:${process.env.BETTER_AUTH_SECRET}`)
45+
.update(`${email}:${salt}:${env.BETTER_AUTH_SECRET}`)
4546
.digest('hex')
4647

4748
return { valid: hash === expectedHash, emailType: 'marketing' }
@@ -52,7 +53,7 @@ export function verifyUnsubscribeToken(
5253
if (!salt || !expectedHash || !emailType) return { valid: false }
5354

5455
const hash = createHash('sha256')
55-
.update(`${email}:${salt}:${emailType}:${process.env.BETTER_AUTH_SECRET}`)
56+
.update(`${email}:${salt}:${emailType}:${env.BETTER_AUTH_SECRET}`)
5657
.digest('hex')
5758

5859
return { valid: hash === expectedHash, emailType }

0 commit comments

Comments
 (0)