Skip to content

Commit 442071c

Browse files
authored
Merge pull request #79 from alpsla/fix/v9-tool-parsers
Fix/v9 tool parsers
2 parents c3f8d5a + 78b51db commit 442071c

11 files changed

Lines changed: 2341 additions & 404 deletions

File tree

apps/api/src/__tests__/middleware/auth-middleware.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ const mockSupabase = {
99
eq: jest.fn().mockReturnThis()
1010
};
1111

12-
jest.mock('@supabase/supabase-js', () => ({
13-
createClient: jest.fn(() => mockSupabase)
12+
// Mock the database package's getSupabase function
13+
jest.mock('@codequal/database/supabase/client', () => ({
14+
getSupabase: jest.fn(() => mockSupabase)
1415
}));
1516

1617
import { Request, Response, NextFunction } from 'express';
@@ -24,7 +25,8 @@ describe('Authentication Middleware', () => {
2425

2526
beforeEach(() => {
2627
mockRequest = {
27-
headers: {}
28+
headers: {},
29+
path: '/api/test' // Default path to avoid undefined errors
2830
} as any;
2931

3032
mockResponse = {

apps/api/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import usageStatsRoutes from './routes/usage-stats';
3636
import researcherRoutes from './routes/researcher';
3737
import metricsRoutes from './routes/metrics';
3838
import monitoringPublicRoutes from './routes/monitoring-public';
39+
import v9AnalyzeRoutes from './routes/v9-analyze';
3940
import { errorHandler } from './middleware/error-handler';
4041
// import { i18nMiddleware, translateResponse, validateLanguage } from './middleware/i18n-middleware';
4142
import { requestLogger } from './middleware/request-logger';
@@ -214,6 +215,12 @@ app.use('/stripe', stripeWebhookRoutes);
214215
// Note: This must come before the auth middleware to allow public access
215216
app.use('/api/monitoring/public', monitoringPublicRoutes);
216217

218+
// V9 Unified Analysis API (for development/testing - no auth required)
219+
// TODO: Add proper authentication before production deployment
220+
if (process.env.NODE_ENV !== 'production') {
221+
app.use('/api/v9', v9AnalyzeRoutes);
222+
logger.info('V9 API routes mounted at /api/v9 (no auth - dev mode)');
223+
}
217224

218225
// Internal API routes (requires user authentication)
219226
app.use('/api', authMiddleware);

apps/api/src/middleware/auth-middleware.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ export const authMiddleware = async (
3434
return next();
3535
}
3636

37+
// Skip auth for V9 routes in development mode
38+
// Note: V9 routes have their own auth when needed
39+
if (process.env.NODE_ENV !== 'production' && (req.path.startsWith('/v9') || req.baseUrl?.includes('/v9'))) {
40+
return next();
41+
}
42+
3743
// Temporary: Allow internal researcher testing
3844
if (req.path === '/researcher/research' && req.headers['x-internal-test'] === 'true') {
3945
(req as any).user = {

0 commit comments

Comments
 (0)