Files
Momento/memento-note/app/api/ai/convert-markdown/route.ts
Sepehr Ramezani fcb5932d33
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 45s
fix: agent notes default to markdown, add convert-to-rich-text option
- Agent-created notes are now type 'markdown' by default (raw markdown content)
- Switching note type from markdown → richtext auto-converts content to HTML
  via /api/ai/convert-markdown endpoint using the existing markdownToHtml utility
- Users can freely switch between markdown and richtext in the note type selector

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-01 16:32:49 +02:00

23 lines
738 B
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import { auth } from '@/auth'
import { markdownToHtml } from '@/lib/markdown-to-html'
export async function POST(request: NextRequest) {
try {
const session = await auth()
if (!session?.user?.id) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
const { content } = await request.json()
if (!content || typeof content !== 'string') {
return NextResponse.json({ error: 'Content is required' }, { status: 400 })
}
const html = markdownToHtml(content)
return NextResponse.json({ html })
} catch (error: any) {
return NextResponse.json({ error: error.message || 'Conversion failed' }, { status: 500 })
}
}