diff --git a/.gitignore b/.gitignore index fff3377..c159944 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,4 @@ lerna-debug.log* *.sln *.sw? -backend/.secrets.js +backend/.env diff --git a/README.md b/README.md index f59793f..853e905 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,12 @@ unzip kongruity.zip cd kongruity ``` -### 2. Create a secrets file +### 2. Create an environment file -The backend expects a `.secrets.js` file containing an Anthropic API key in the root `backend/` directory. This file is git-ignored and must be created manually: +The backend expects a `.env` file containing an Anthropic API key in the root `backend/` directory. This file is git-ignored and must be created manually: ```bash -echo 'export const anthropicApiKey = ""' > backend/.secrets.js +echo 'ANTHROPIC_API_KEY=' > backend/.env ``` Replace `` with your actual key. diff --git a/backend/server.js b/backend/server.js index f62c4e6..fbb2fef 100644 --- a/backend/server.js +++ b/backend/server.js @@ -1,3 +1,4 @@ +import 'dotenv/config'; import app from './app.js'; const PORT = process.env.PORT || 3001; diff --git a/backend/services/clustering.service.js b/backend/services/clustering.service.js index f1e72d1..bd81d98 100644 --- a/backend/services/clustering.service.js +++ b/backend/services/clustering.service.js @@ -1,8 +1,7 @@ import Anthropic from "@anthropic-ai/sdk"; -import { anthropicApiKey } from "../.secrets.js"; const client = new Anthropic({ - apiKey: anthropicApiKey, + apiKey: process.env.ANTHROPIC_API_KEY, }); const buildPrompt = (notes) => { diff --git a/backend/tests/Clustering.service.test.js b/backend/tests/Clustering.service.test.js index 34cc13a..74a0596 100644 --- a/backend/tests/Clustering.service.test.js +++ b/backend/tests/Clustering.service.test.js @@ -14,10 +14,6 @@ vi.mock('@anthropic-ai/sdk', () => { }; }); -vi.mock('../.secrets.js', () => ({ - anthropicApiKey: 'test-key-not-real', -})); - import { clusterNotes } from '../services/clustering.service.js'; const MOCK_NOTES = [