Skip to content

Commit d81002f

Browse files
authored
Merge pull request #659 from Merit-Systems/br/knip-server
Add PNPM Knip and Env.ts
2 parents f4384b6 + 46a7503 commit d81002f

75 files changed

Lines changed: 417 additions & 1498 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/integration-tests.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ jobs:
5757
CDP_API_KEY_SECRET: ${{ secrets.CDP_API_KEY_SECRET }}
5858
CDP_WALLET_SECRET: ${{ secrets.CDP_WALLET_SECRET }}
5959

60+
# Facilitator Configuration
61+
PROXY_FACILITATOR_URL: ${{ secrets.PROXY_FACILITATOR_URL }}
62+
6063
# OAuth Configuration (short expiry for fast integration tests)
6164
OAUTH_REFRESH_TOKEN_EXPIRY_SECONDS: 5
6265
OAUTH_ACCESS_TOKEN_EXPIRY_SECONDS: 5
@@ -150,6 +153,9 @@ jobs:
150153
CDP_WALLET_SECRET=${{ secrets.CDP_WALLET_SECRET }}
151154
WALLET_OWNER="integration-test-owner"
152155
156+
# Facilitator Configuration
157+
PROXY_FACILITATOR_URL=${{ secrets.PROXY_FACILITATOR_URL }}
158+
153159
# OAuth Configuration
154160
OAUTH_REFRESH_TOKEN_EXPIRY_SECONDS=5
155161
OAUTH_ACCESS_TOKEN_EXPIRY_SECONDS=5
@@ -230,6 +236,7 @@ jobs:
230236
DATABASE_URL="${DATABASE_URL}" \
231237
NODE_ENV=test \
232238
PORT=3069 \
239+
PROXY_FACILITATOR_URL="${PROXY_FACILITATOR_URL}" \
233240
OPENAI_API_KEY="${OPENAI_API_KEY}" \
234241
ANTHROPIC_API_KEY="${ANTHROPIC_API_KEY}" \
235242
CDP_API_KEY_ID="${CDP_API_KEY_ID}" \
@@ -343,6 +350,9 @@ jobs:
343350
CDP_API_KEY_SECRET: ${{ secrets.CDP_API_KEY_SECRET }}
344351
CDP_WALLET_SECRET: ${{ secrets.CDP_WALLET_SECRET }}
345352

353+
# Facilitator Configuration
354+
PROXY_FACILITATOR_URL: ${{ secrets.PROXY_FACILITATOR_URL }}
355+
346356
# OAuth Configuration
347357
OAUTH_REFRESH_TOKEN_EXPIRY_SECONDS: 2592000
348358
OAUTH_ACCESS_TOKEN_EXPIRY_SECONDS: 86400
@@ -397,6 +407,7 @@ jobs:
397407
CDP_API_KEY_ID=${{ secrets.CDP_API_KEY_ID }}
398408
CDP_API_KEY_SECRET=${{ secrets.CDP_API_KEY_SECRET }}
399409
CDP_WALLET_SECRET=${{ secrets.CDP_WALLET_SECRET }}
410+
PROXY_FACILITATOR_URL=${{ secrets.PROXY_FACILITATOR_URL }}
400411
OAUTH_REFRESH_TOKEN_EXPIRY_SECONDS=2592000
401412
CI=true
402413
NODE_ENV=test

packages/app/server/knip.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@latest/schema.json",
3+
"ignore": [
4+
"/scripts/**",
5+
"/src/__tests__/**",
6+
"/src/generated/**",
7+
"/src/clients/**",
8+
"/dist/**"
9+
],
10+
"ignoreDependencies": ["@merit-systems/echo-typescript-sdk"]
11+
}

packages/app/server/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "echo-server",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "index.js",
5+
"main": "dist/server.js",
66
"scripts": {
77
"copy-schema": "mkdir -p prisma && cp ../control/prisma/schema.prisma prisma/ && cp -r ../control/prisma/migrations prisma/",
88
"prisma:generate": "pnpx prisma generate",
@@ -33,6 +33,7 @@
3333
"type-check": "tsc --noEmit",
3434
"format": "prettier --write src/**/*.{ts,js}",
3535
"format:check": "prettier --check src/**/*.{ts,js}",
36+
"knip": "knip",
3637
"docker:build": "./scripts/build-local-docker.sh",
3738
"docker:run": "./scripts/run-local-docker.sh",
3839
"docker:build-and-run": "pnpm run docker:build && pnpm run docker:run"
@@ -42,7 +43,6 @@
4243
"license": "ISC",
4344
"dependencies": {
4445
"@coinbase/cdp-sdk": "^1.34.0",
45-
"@coinbase/x402": "^0.6.5",
4646
"@e2b/code-interpreter": "^2.0.1",
4747
"@google-cloud/storage": "^7.17.1",
4848
"@google/genai": "^1.20.0",
@@ -58,28 +58,25 @@
5858
"@opentelemetry/semantic-conventions": "^1.36.0",
5959
"@opentelemetry/winston-transport": "^0.14.1",
6060
"@prisma/client": "6.16.0",
61+
"@t3-oss/env-core": "^0.13.8",
6162
"@types/compression": "^1.7.5",
6263
"@types/cors": "^2.8.19",
6364
"@types/express": "^4.17.21",
6465
"@types/multer": "^2.0.0",
65-
"@types/node": "^20.11.24",
66-
"@types/node-fetch": "^2.6.11",
66+
"@types/node": "^20.19.16",
6767
"compression": "^1.8.0",
6868
"cors": "^2.8.5",
6969
"dotenv": "^16.5.0",
7070
"express": "^4.18.3",
7171
"google-auth-library": "^10.3.0",
7272
"jose": "^6.0.11",
7373
"multer": "^2.0.2",
74-
"node-fetch": "^2.7.0",
7574
"openai": "^6.2.0",
7675
"prisma": "6.16.0",
77-
"ts-node": "^10.9.2",
7876
"typescript": "^5.3.3",
7977
"uuid": "^11.1.0",
8078
"viem": "^2.33.3",
8179
"winston": "^3.17.0",
82-
"x402-express": "^0.6.5",
8380
"zod": "^4.1.11"
8481
},
8582
"devDependencies": {
@@ -88,6 +85,8 @@
8885
"@typescript-eslint/eslint-plugin": "^8.34.1",
8986
"@typescript-eslint/parser": "^8.34.1",
9087
"eslint": "^9.29.0",
88+
"knip": "^5.63.1",
89+
"prettier": "^3.4.2",
9190
"supertest": "^6.3.4",
9291
"tsup": "^8.5.0",
9392
"tsx": "^4.20.5",

packages/app/server/src/__tests__/responses.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
ResponseInputItem,
55
} from 'openai/resources/responses/responses';
66
import dotenv from 'dotenv';
7+
import { env } from '../env';
78

89
// Load environment variables from .env file
910
dotenv.config();
@@ -13,15 +14,13 @@ describe('Echo API Test', () => {
1314

1415
beforeAll(() => {
1516
// Check if ECHO_API_KEY is set
16-
if (!process.env.ECHO_API_KEY) {
17+
if (!env.ECHO_API_KEY) {
1718
throw new Error('ECHO_API_KEY environment variable is not set');
1819
}
1920

20-
console.log('ECHO_API_KEY:', process.env.ECHO_API_KEY);
21-
2221
// Create OpenAI client with echo.router.merit.systems baseURL
2322
oai = new OpenAI({
24-
apiKey: process.env.ECHO_API_KEY,
23+
apiKey: env.ECHO_API_KEY,
2524
baseURL: 'http://localhost:3070',
2625
timeout: 30000,
2726
});
@@ -43,7 +42,7 @@ describe('Echo API Test', () => {
4342
console.log('Base URL:', oai.baseURL);
4443
console.log(
4544
'API Key (first 10 chars):',
46-
process.env.ECHO_API_KEY?.substring(0, 10) + '...'
45+
env.ECHO_API_KEY?.substring(0, 10) + '...'
4746
);
4847
console.log('Input being sent:', JSON.stringify(input, null, 2));
4948
console.log('==========================');

packages/app/server/src/clients/anthropic-client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Anthropic from '@anthropic-ai/sdk';
22
import dotenv from 'dotenv';
3+
import { env } from '../env';
34

45
dotenv.config();
56

@@ -8,7 +9,7 @@ async function makeRequest(useStreaming: boolean = true) {
89
// Initialize OpenAI client with custom baseURL
910
const claude = new Anthropic({
1011
baseURL: 'http://localhost:3070',
11-
apiKey: process.env.ECHO_API_KEY, // Required by the client but not used with local server
12+
apiKey: env.ECHO_API_KEY, // Required by the client but not used with local server
1213
});
1314

1415
if (useStreaming) {

packages/app/server/src/clients/anthropic-gpt-client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import OpenAI from 'openai';
22
import dotenv from 'dotenv';
3+
import { env } from '../env';
34

45
dotenv.config();
56

@@ -8,7 +9,7 @@ async function makeRequest(useStreaming: boolean = false) {
89
// Initialize OpenAI client with custom baseURL
910
const openai = new OpenAI({
1011
baseURL: 'http://localhost:3070',
11-
apiKey: process.env.ECHO_API_KEY, // Required by the client but not used with local server
12+
apiKey: env.ECHO_API_KEY, // Required by the client but not used with local server
1213
});
1314

1415
if (useStreaming) {

packages/app/server/src/clients/gemini-client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { GoogleGenAI } from '@google/genai';
22
import dotenv from 'dotenv';
3+
import { env } from '../env';
34

45
dotenv.config();
56

67
async function makeRequest(useStreaming: boolean = false) {
78
try {
89
// Initialize Gemini client
910
const ai = new GoogleGenAI({
10-
apiKey: process.env.ECHO_API_KEY || '',
11-
// apiKey: process.env.GEMINI_API_KEY || '',
11+
apiKey: env.ECHO_API_KEY || '',
12+
// apiKey: env.GEMINI_API_KEY || '',
1213
httpOptions: {
1314
baseUrl: 'http://localhost:3070',
1415
},

packages/app/server/src/clients/gemini-gpt-client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import OpenAI from 'openai';
22
import dotenv from 'dotenv';
3+
import { env } from '../env';
34

45
dotenv.config();
56

@@ -8,7 +9,7 @@ async function makeRequest(useStreaming: boolean = false) {
89
// Initialize OpenAI client with custom baseURL
910
const openai = new OpenAI({
1011
baseURL: 'http://localhost:3070',
11-
apiKey: process.env.ECHO_API_KEY, // Required by the client but not used with local server
12+
apiKey: env.ECHO_API_KEY, // Required by the client but not used with local server
1213
});
1314

1415
if (useStreaming) {

packages/app/server/src/clients/gpt-client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import OpenAI from 'openai';
22
import dotenv from 'dotenv';
3+
import { env } from '../env';
34

45
dotenv.config();
56

@@ -8,7 +9,7 @@ async function makeRequest(useStreaming: boolean = false) {
89
// Initialize OpenAI client with custom baseURL
910
const openai = new OpenAI({
1011
baseURL: 'http://localhost:3070/5b20a7e2-f4eb-4879-b889-dc19148a6b06',
11-
apiKey: process.env.ECHO_API_KEY, // Required by the client but not used with local server
12+
apiKey: env.ECHO_API_KEY, // Required by the client but not used with local server
1213
});
1314

1415
if (useStreaming) {

packages/app/server/src/clients/openai-image-formdata-client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import OpenAI, { toFile } from 'openai';
22
import fs from 'fs';
33
import path from 'path';
44
import dotenv from 'dotenv';
5+
import { env } from '../env';
56

67
dotenv.config();
78

89
async function makeImageEditRequest() {
910
try {
1011
// Initialize OpenAI client
1112
const client = new OpenAI({
12-
apiKey: process.env.ECHO_API_KEY || '',
13+
apiKey: env.ECHO_API_KEY || '',
1314
baseURL: 'http://localhost:3070',
1415
});
1516

@@ -73,7 +74,7 @@ async function makeImageEditRequestWithMultipleImages() {
7374
try {
7475
// Initialize OpenAI client
7576
const client = new OpenAI({
76-
apiKey: process.env.ECHO_API_KEY || '',
77+
apiKey: env.ECHO_API_KEY || '',
7778
baseURL: 'http://localhost:3070/v1',
7879
});
7980

0 commit comments

Comments
 (0)