diff --git a/apps/memoro/apps/server/src/routes/cleanup.ts b/apps/memoro/apps/server/src/routes/cleanup.ts index ea72a30a4..128185b73 100644 --- a/apps/memoro/apps/server/src/routes/cleanup.ts +++ b/apps/memoro/apps/server/src/routes/cleanup.ts @@ -38,7 +38,7 @@ cleanupRoutes.post('/run', async (c) => { // POST /manual — manual trigger with optional user IDs cleanupRoutes.post('/manual', async (c) => { - const body = await c.req.json<{ userIds?: string[] }>().catch(() => ({})); + const body = await c.req.json<{ userIds?: string[] }>().catch(() => ({ userIds: undefined })); const userIds = body.userIds ?? []; console.log( diff --git a/apps/memoro/apps/server/src/routes/credits.ts b/apps/memoro/apps/server/src/routes/credits.ts index 7ef986613..d6f13f093 100644 --- a/apps/memoro/apps/server/src/routes/credits.ts +++ b/apps/memoro/apps/server/src/routes/credits.ts @@ -3,10 +3,11 @@ */ import { Hono } from 'hono'; +import type { AuthVariables } from '@manacore/shared-hono'; import { validateCredits, consumeCredits, COSTS } from '../lib/credits'; import { getBalance } from '@manacore/shared-hono'; -export const creditRoutes = new Hono(); +export const creditRoutes = new Hono<{ Variables: AuthVariables }>(); // GET /pricing — public, returns cost constants creditRoutes.get('/pricing', (c) => { diff --git a/apps/memoro/apps/server/src/routes/internal.ts b/apps/memoro/apps/server/src/routes/internal.ts index 015a20fdd..189d844a4 100644 --- a/apps/memoro/apps/server/src/routes/internal.ts +++ b/apps/memoro/apps/server/src/routes/internal.ts @@ -6,10 +6,7 @@ import { Hono } from 'hono'; import { HTTPException } from 'hono/http-exception'; -import { - handleTranscriptionCompleted, - updateMemoProcessingStatus, -} from '../services/memo'; +import { handleTranscriptionCompleted } from '../services/memo'; import { createServiceClient } from '../lib/supabase'; export const internalRoutes = new Hono(); @@ -54,11 +51,11 @@ internalRoutes.post('/transcription-completed', async (c) => { await handleTranscriptionCompleted({ memoId: body.memoId, userId: body.userId, - transcriptionResult: body.transcriptionResult, - route: body.route, + ...(body.transcriptionResult ? { transcriptionResult: body.transcriptionResult } : {}), + ...(body.route ? { route: body.route } : {}), success: body.success, - error: body.error, - fallbackStage: body.fallbackStage, + ...(body.error ? { error: body.error } : {}), + ...(body.fallbackStage ? { fallbackStage: body.fallbackStage } : {}), }); return c.json({ success: true, memoId: body.memoId }); } catch (err) { diff --git a/apps/memoro/apps/server/src/routes/invites.ts b/apps/memoro/apps/server/src/routes/invites.ts index 5afe44bc9..5657f1f13 100644 --- a/apps/memoro/apps/server/src/routes/invites.ts +++ b/apps/memoro/apps/server/src/routes/invites.ts @@ -3,9 +3,10 @@ */ import { Hono } from 'hono'; +import type { AuthVariables } from '@manacore/shared-hono'; import { acceptInvite, declineInvite, getPendingInvites } from '../services/space'; -export const inviteRoutes = new Hono(); +export const inviteRoutes = new Hono<{ Variables: AuthVariables }>(); // GET /pending — list pending invites for current user inviteRoutes.get('/pending', async (c) => { diff --git a/apps/memoro/apps/server/src/routes/memos.ts b/apps/memoro/apps/server/src/routes/memos.ts index d17fc1548..4fae5d894 100644 --- a/apps/memoro/apps/server/src/routes/memos.ts +++ b/apps/memoro/apps/server/src/routes/memos.ts @@ -3,10 +3,10 @@ */ import { Hono } from 'hono'; +import type { AuthVariables } from '@manacore/shared-hono'; import { v4 as uuidv4 } from 'uuid'; import { createMemoFromUploadedFile, - handleTranscriptionCompleted, callAudioServer, updateMemoProcessingStatus, } from '../services/memo'; @@ -15,7 +15,7 @@ import { createServiceClient } from '../lib/supabase'; import { validateCredits, consumeCredits, COSTS } from '../lib/credits'; import { generateText } from '../lib/ai'; -export const memoRoutes = new Hono(); +export const memoRoutes = new Hono<{ Variables: AuthVariables }>(); // POST / — create memo from uploaded file memoRoutes.post('/', async (c) => { @@ -40,12 +40,12 @@ memoRoutes.post('/', async (c) => { userId, filePath: body.filePath, duration: body.duration, - spaceId: body.spaceId, - blueprintId: body.blueprintId, - memoId: body.memoId, - recordingStartedAt: body.recordingStartedAt, - location: body.location, - mediaType: body.mediaType, + ...(body.spaceId ? { spaceId: body.spaceId } : {}), + ...(body.blueprintId ? { blueprintId: body.blueprintId } : {}), + ...(body.memoId ? { memoId: body.memoId } : {}), + ...(body.recordingStartedAt ? { recordingStartedAt: body.recordingStartedAt } : {}), + ...(body.location !== undefined ? { location: body.location } : {}), + ...(body.mediaType ? { mediaType: body.mediaType } : {}), }); return c.json(result, 201); } catch (err) { @@ -122,8 +122,8 @@ memoRoutes.post('/:id/append', async (c) => { audioPath: body.filePath, duration: body.duration, recordingIndex, - recordingLanguages: body.recordingLanguages, - enableDiarization: body.enableDiarization, + ...(body.recordingLanguages ? { recordingLanguages: body.recordingLanguages } : {}), + ...(body.enableDiarization !== undefined ? { enableDiarization: body.enableDiarization } : {}), isAppend: true, }).catch((err) => console.error(`[memos] Append transcription call failed: ${err}`)); }); diff --git a/apps/memoro/apps/server/src/routes/settings.ts b/apps/memoro/apps/server/src/routes/settings.ts index eefb5a068..8b22ce593 100644 --- a/apps/memoro/apps/server/src/routes/settings.ts +++ b/apps/memoro/apps/server/src/routes/settings.ts @@ -5,9 +5,10 @@ */ import { Hono } from 'hono'; +import type { AuthVariables } from '@manacore/shared-hono'; import { createServiceClient } from '../lib/supabase'; -export const settingsRoutes = new Hono(); +export const settingsRoutes = new Hono<{ Variables: AuthVariables }>(); // GET / — get all user settings settingsRoutes.get('/', async (c) => { diff --git a/apps/memoro/apps/server/src/routes/spaces.ts b/apps/memoro/apps/server/src/routes/spaces.ts index 755385e7b..f2c5776ae 100644 --- a/apps/memoro/apps/server/src/routes/spaces.ts +++ b/apps/memoro/apps/server/src/routes/spaces.ts @@ -3,6 +3,7 @@ */ import { Hono } from 'hono'; +import type { AuthVariables } from '@manacore/shared-hono'; import { createServiceClient } from '../lib/supabase'; import { getSpaces, @@ -17,7 +18,7 @@ import { createInvite, } from '../services/space'; -export const spaceRoutes = new Hono(); +export const spaceRoutes = new Hono<{ Variables: AuthVariables }>(); // GET / — list user's spaces spaceRoutes.get('/', async (c) => { diff --git a/apps/memoro/apps/server/src/services/memo.ts b/apps/memoro/apps/server/src/services/memo.ts index de3be0b5b..ae06832e3 100644 --- a/apps/memoro/apps/server/src/services/memo.ts +++ b/apps/memoro/apps/server/src/services/memo.ts @@ -136,7 +136,7 @@ export async function createMemoFromUploadedFile(params: CreateMemoParams): Prom userId, audioPath: filePath, duration, - blueprintId, + ...(blueprintId ? { blueprintId } : {}), }).catch((err) => { console.error(`[memo] Audio server call failed for memo ${memoId}:`, err); updateMemoProcessingStatus(memoId, 'transcription', 'failed', { @@ -208,7 +208,7 @@ export async function handleTranscriptionCompleted( consumeCredits(userId, 'transcription', cost, `Transcription for memo ${memoId}`, { memoId, durationSeconds: duration, - }).catch((err) => console.error('[memo] Failed to consume credits:', err)); + }).catch((err: unknown) => console.error('[memo] Failed to consume credits:', err)); // Fire headline generation asynchronously queueMicrotask(() => { diff --git a/apps/memoro/apps/server/src/services/space.ts b/apps/memoro/apps/server/src/services/space.ts index f46e037c8..91a1be449 100644 --- a/apps/memoro/apps/server/src/services/space.ts +++ b/apps/memoro/apps/server/src/services/space.ts @@ -369,7 +369,7 @@ export async function acceptInvite( export async function declineInvite( inviteId: string, - userId: string + _userId: string ): Promise<{ success: boolean }> { const supabase = createServiceClient(); diff --git a/packages/shared-hono/src/credits.ts b/packages/shared-hono/src/credits.ts index be003ef25..8c3f8e286 100644 --- a/packages/shared-hono/src/credits.ts +++ b/packages/shared-hono/src/credits.ts @@ -62,7 +62,7 @@ export async function getBalance(userId: string): Promise { */ export async function validateCredits( userId: string, - operation: string, + _operation: string, amount: number ): Promise { try {