Skip to content

Commit 9f0673b

Browse files
authored
Remove process.env (#854)
1 parent 18332b9 commit 9f0673b

File tree

7 files changed

+13
-11
lines changed

7 files changed

+13
-11
lines changed

apps/sim/app/api/copilot/methods/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type NextRequest, NextResponse } from 'next/server'
22
import { z } from 'zod'
3+
import { env } from '@/lib/env'
34
import { createLogger } from '@/lib/logs/console/logger'
45
import { getRedisClient } from '@/lib/redis'
56
import { copilotToolRegistry } from '../tools/registry'
@@ -233,7 +234,7 @@ const MethodExecutionSchema = z.object({
233234
// Simple internal API key authentication
234235
function checkInternalApiKey(req: NextRequest) {
235236
const apiKey = req.headers.get('x-api-key')
236-
const expectedApiKey = process.env.INTERNAL_API_SECRET
237+
const expectedApiKey = env.INTERNAL_API_SECRET
237238

238239
if (!expectedApiKey) {
239240
return { success: false, error: 'Internal API key not configured' }

apps/sim/app/api/copilot/tools/other/online-search.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { env } from '@/lib/env'
12
import { createLogger } from '@/lib/logs/console/logger'
23
import { executeTool } from '@/tools'
34
import { BaseCopilotTool } from '../base'
@@ -49,7 +50,7 @@ async function onlineSearch(params: OnlineSearchParams): Promise<OnlineSearchRes
4950
type,
5051
gl,
5152
hl,
52-
apiKey: process.env.SERPER_API_KEY || '',
53+
apiKey: env.SERPER_API_KEY || '',
5354
}
5455

5556
const result = await executeTool('serper_search', toolParams)

apps/sim/app/api/copilot/tools/user/set-environment-variables.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { env } from '@/lib/env'
12
import { createLogger } from '@/lib/logs/console/logger'
23
import { BaseCopilotTool } from '../base'
34

@@ -44,7 +45,7 @@ async function setEnvironmentVariables(
4445
})
4546

4647
// Forward the request to the existing environment variables endpoint
47-
const envUrl = `${process.env.NEXTAUTH_URL || 'http://localhost:3000'}/api/environment/variables`
48+
const envUrl = `${env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/api/environment/variables`
4849

4950
const response = await fetch(envUrl, {
5051
method: 'PUT',

apps/sim/app/api/copilot/tools/workflow/build-workflow.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { env } from '@/lib/env'
12
import { createLogger } from '@/lib/logs/console/logger'
23
import { getAllBlocks } from '@/blocks/registry'
34
import type { BlockConfig } from '@/blocks/types'
@@ -6,8 +7,8 @@ import { generateLoopBlocks, generateParallelBlocks } from '@/stores/workflows/w
67
import { BaseCopilotTool } from '../base'
78

89
// Sim Agent API configuration
9-
const SIM_AGENT_API_URL = process.env.SIM_AGENT_API_URL || 'http://localhost:8000'
10-
const SIM_AGENT_API_KEY = process.env.SIM_AGENT_API_KEY
10+
const SIM_AGENT_API_URL = env.SIM_AGENT_API_URL || 'http://localhost:8000'
11+
const SIM_AGENT_API_KEY = env.SIM_AGENT_API_KEY
1112

1213
interface BuildWorkflowParams {
1314
yamlContent: string

apps/sim/app/api/copilot/tools/workflow/edit-workflow.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { env } from '@/lib/env'
12
import { createLogger } from '@/lib/logs/console/logger'
23
import { getAllBlocks } from '@/blocks/registry'
34
import type { BlockConfig } from '@/blocks/types'
@@ -7,8 +8,8 @@ import { generateLoopBlocks, generateParallelBlocks } from '@/stores/workflows/w
78
const logger = createLogger('EditWorkflowAPI')
89

910
// Sim Agent API configuration
10-
const SIM_AGENT_API_URL = process.env.SIM_AGENT_API_URL || 'http://localhost:8000'
11-
const SIM_AGENT_API_KEY = process.env.SIM_AGENT_API_KEY
11+
const SIM_AGENT_API_URL = env.SIM_AGENT_API_URL || 'http://localhost:8000'
12+
const SIM_AGENT_API_KEY = env.SIM_AGENT_API_KEY
1213

1314
// Types for operations
1415
interface EditWorkflowOperation {

apps/sim/app/api/copilot/tools/workflow/get-user-workflow.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ import { db } from '@/db'
55
import { workflow as workflowTable } from '@/db/schema'
66
import { BaseCopilotTool } from '../base'
77

8-
// Sim Agent API configuration
9-
const SIM_AGENT_API_URL = process.env.SIM_AGENT_API_URL || 'http://localhost:8000'
10-
const SIM_AGENT_API_KEY = process.env.SIM_AGENT_API_KEY
11-
128
interface GetUserWorkflowParams {
139
workflowId: string
1410
includeMetadata?: boolean

apps/sim/lib/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const env = createEnv({
5858
FREESTYLE_API_KEY: z.string().min(1).optional(), // Freestyle AI API key
5959
OLLAMA_URL: z.string().url().optional(), // Ollama local LLM server URL
6060
ELEVENLABS_API_KEY: z.string().min(1).optional(), // ElevenLabs API key for text-to-speech in deployed chat
61+
SERPER_API_KEY: z.string().min(1).optional(), // Serper API key for online search
6162

6263
// Azure OpenAI Configuration
6364
AZURE_OPENAI_ENDPOINT: z.string().url().optional(), // Azure OpenAI service endpoint

0 commit comments

Comments
 (0)