Skip to content

Commit 49fed25

Browse files
committed
refactor: remove dotenv usage in apis and update local settings properly
1 parent 91f294e commit 49fed25

File tree

8 files changed

+6
-25
lines changed

8 files changed

+6
-25
lines changed

packages/agent-api/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
"build": "tsc",
99
"watch": "tsc -w",
1010
"clean": "rimraf dist",
11-
"prestart": "npm run clean && npm run build",
11+
"prestart": "npm run clean && npm run update:local-settings && npm run build",
1212
"start:host": "func start --port 7072",
1313
"start": "concurrently npm:start:* npm:watch --raw --kill-others",
14-
"update:local-settings": "node ./scripts/update-local-settings.mjs",
15-
"postinstall": "npm run update:local-settings"
14+
"update:local-settings": "node ./scripts/update-local-settings.mjs"
1615
},
1716
"author": "Microsoft",
1817
"license": "MIT",
@@ -31,6 +30,7 @@
3130
"devDependencies": {
3231
"@types/node": "^20",
3332
"azure-functions-core-tools": "^4",
33+
"dotenv": "^17.2.1",
3434
"typescript": "^5"
3535
}
3636
}

packages/agent-api/src/functions/chats-delete.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import process from 'node:process';
22
import { HttpRequest, HttpResponseInit, InvocationContext, app } from '@azure/functions';
33
import { AzureCosmsosDBNoSQLChatMessageHistory } from '@langchain/azure-cosmosdb';
4-
import 'dotenv/config';
54
import { getCredentials, getUserId } from '../auth.js';
65

76
async function deleteChats(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {

packages/agent-api/src/functions/chats-get.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import process from 'node:process';
22
import { HttpRequest, HttpResponseInit, InvocationContext, app } from '@azure/functions';
33
import { AzureCosmsosDBNoSQLChatMessageHistory } from '@langchain/azure-cosmosdb';
4-
import 'dotenv/config';
54
import { getCredentials, getUserId } from '../auth.js';
65

76
async function getChats(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {

packages/agent-api/src/functions/chats-post.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { createToolCallingAgent } from 'langchain/agents';
1111
import { AgentExecutor } from 'langchain/agents';
1212
import { loadMcpTools } from '@langchain/mcp-adapters';
1313
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
14-
import 'dotenv/config';
1514
import { getAzureOpenAiTokenProvider, getCredentials, getUserId } from '../auth.js';
1615
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
1716
import { ChainValues } from '@langchain/core/utils/types.js';

packages/burger-api/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
"build": "tsc",
99
"watch": "tsc -w",
1010
"clean": "rimraf dist",
11-
"prestart": "npm run clean",
11+
"prestart": "npm run clean && npm run update:local-settings",
1212
"start:storage": "azurite --silent --location ./.azurite --debug ./.azurite/debug.log",
1313
"start:host": "func start",
1414
"start": "concurrently npm:start:* npm:watch --raw --kill-others",
15-
"update:local-settings": "node ./scripts/update-local-settings.mjs",
16-
"postinstall": "npm run update:local-settings",
17-
"generate:burgers": "npx -y genaiscript@latest run generate-burgers",
18-
"generate:images": "npx -y genaiscript@latest run generate-images"
15+
"update:local-settings": "node ./scripts/update-local-settings.mjs"
1916
},
2017
"author": "Microsoft",
2118
"license": "MIT",
@@ -25,14 +22,14 @@
2522
"@azure/functions": "^4.7.0",
2623
"@azure/identity": "^4.8.0",
2724
"@azure/storage-blob": "^12.27.0",
28-
"dotenv": "^17.0.0",
2925
"js-yaml": "^4.1.0"
3026
},
3127
"devDependencies": {
3228
"@types/js-yaml": "^4.0.9",
3329
"@types/node": "^20",
3430
"azure-functions-core-tools": "^4",
3531
"azurite": "^3",
32+
"dotenv": "^17.0.0",
3633
"typescript": "^5"
3734
}
3835
}

packages/burger-api/src/blob-service.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import path from 'node:path';
33
import { Buffer } from 'node:buffer';
44
import { BlobServiceClient, ContainerClient } from '@azure/storage-blob';
55
import { DefaultAzureCredential } from '@azure/identity';
6-
import dotenv from 'dotenv';
7-
8-
// Env file is located in the root of the repository
9-
dotenv.config({ path: path.join(process.cwd(), '../../.env'), quiet: true });
106

117
export class BlobService {
128
private static instance: BlobService;

packages/burger-api/src/db-service.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import path from 'node:path';
21
import { Container, CosmosClient, Database } from '@azure/cosmos';
32
import { DefaultAzureCredential } from '@azure/identity';
4-
import dotenv from 'dotenv';
53
import burgersData from '../data/burgers.json';
64
import toppingsData from '../data/toppings.json';
75
import { ToppingCategory, Topping } from './topping.js';
86
import { Burger } from './burger.js';
97
import { Order, OrderStatus } from './order.js';
108

11-
// Env file is located in the root of the repository
12-
dotenv.config({ path: path.join(process.cwd(), '../../.env'), quiet: true });
13-
149
// Helper to strip properties starting with underscore from an object
1510
function stripUnderscoreProperties<T extends object>(object: T): T {
1611
if (!object || typeof object !== 'object') return object;

packages/burger-api/src/functions/openapi-get.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import fs from 'node:fs/promises';
33
import path from 'node:path';
44
import { app, type HttpRequest, type InvocationContext } from '@azure/functions';
55
import yaml from 'js-yaml';
6-
import dotenv from 'dotenv';
7-
8-
// Env file is located in the root of the repository
9-
dotenv.config({ path: path.join(process.cwd(), '../../.env'), quiet: true });
106

117
app.http('openapi-get', {
128
methods: ['GET'],

0 commit comments

Comments
 (0)