Skip to content

Commit

Permalink
moving to main file for env loading
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenNaihin committed Dec 19, 2023
1 parent 8f7e98a commit 43210d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 4 additions & 0 deletions npm_package/exec/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import path from 'path';
import { execSync } from 'child_process';
import transformRoute from './transformRoute.js';
import terraformLambdaTemplate from './terraformLambdaTemplate.js';
import { loadEnvVariables } from './handleEnv.js';

// Define __dirname in ES module
const __dirname = new URL('.', import.meta.url).pathname;
Expand All @@ -21,6 +22,9 @@ async function packageAndDeployLambda(routePath: string): Promise<void> {
}
fs.mkdirSync(lambdaDir);

// loads the tf and openai variables
await loadEnvVariables();

const routeDir = path.join(routePath, 'route.ts');

// Read and transform the original file
Expand Down
4 changes: 0 additions & 4 deletions npm_package/exec/transformRoute.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import OpenAI from 'openai';
import { loadEnvVariables } from './handleEnv.js';

export default async function transformRoute(originalContent: string) {
// loads the tf and openai variables
await loadEnvVariables();

if (!process.env.OPENAI_API_KEY) {
throw new Error(
'OPENAI_API_KEY is not set. Please set the environment variable.'
Expand Down

0 comments on commit 43210d7

Please sign in to comment.