Skip to content

Commit ad8363c

Browse files
committed
Clean up API tech debt: remove unused refactor code
Deleted unused code from incomplete refactor: - api/src/http/ (routes, schemas, plugins) - never wired up - api/src/services/ - only used by deleted routes - api/src/infrastructure/container.ts, database/, external/ - api/src/core/errors/, result.ts, types/ Consolidated configuration: - Deleted api/config.ts, now using api/src/config/env.ts - Routes now import from src/config/env.js and src/infrastructure/supabase.js Fixed ESM imports: - Added .js extensions to all src/ imports for consistency The API now has a clean structure: - api/routes/ - working routes (use simple JSON schemas) - api/middleware/ - auth plugin - api/schemas/, api/utils/ - shared code - api/src/config/ - Zod-validated env - api/src/infrastructure/ - supabase client, logging - api/src/core/plugins/ - error handler, request context
1 parent 8a1ff45 commit ad8363c

Some content is hidden

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

73 files changed

+20
-7420
lines changed

api/config.ts

Lines changed: 0 additions & 89 deletions
This file was deleted.

api/middleware/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { FastifyPluginAsync, FastifyRequest, FastifyReply } from 'fastify'
88
import fp from 'fastify-plugin'
9-
import { createSupabaseClient } from '../config.js'
9+
import { createSupabaseClient } from '../src/infrastructure/supabase.js'
1010
import type { UserProfile } from '../types.js'
1111

1212
const authPluginImpl: FastifyPluginAsync = async (fastify) => {

api/routes/auth.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
import { FastifyPluginAsync, FastifyReply } from 'fastify'
88
import { createClient } from '@supabase/supabase-js'
9-
import { createSupabaseClient, SUPABASE_URL, SUPABASE_KEY, SUPABASE_SERVICE_KEY } from '../config.js'
9+
import { createSupabaseClient } from '../src/infrastructure/supabase.js'
10+
import { env } from '../src/config/env.js'
11+
12+
// Destructure for backwards compatibility
13+
const { SUPABASE_URL, SUPABASE_KEY, SUPABASE_SERVICE_KEY } = env
1014
import { schemas } from '../schemas/index.js'
1115

1216
// Helper to send error responses without TypeScript complaining about schema types

api/routes/files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { FastifyPluginAsync, FastifyReply } from 'fastify'
88
import crypto from 'crypto'
9-
import { SIGNED_URL_EXPIRY } from '../config.js'
9+
import { SIGNED_URL_EXPIRY } from '../src/config/env.js'
1010
import { schemas } from '../schemas/index.js'
1111
import { computeHash, getFileTypeFromExtension, triggerWebhooks } from '../utils/index.js'
1212
import type { FileRecord } from '../types.js'

api/src/config/env.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ export function validateEnv(): Env {
2626
}
2727

2828
export const env = validateEnv();
29+
30+
// Constants
31+
export const SIGNED_URL_EXPIRY = 3600; // 1 hour

api/src/core/errors/AppError.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

api/src/core/errors/ErrorCodes.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

api/src/core/errors/HttpErrors.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

api/src/core/errors/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

api/src/core/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
export * from './errors';
2-
export * from './types';
3-
export * from './result';
4-
export * from './plugins';
1+
export * from './plugins';

0 commit comments

Comments
 (0)