Files
Momento/memento-note/app/api/notes/daily/route.ts
Antigravity c415d93945
Some checks failed
CI / Lint, Unit Tests & Build (push) Failing after 1m7s
CI / Deploy production (on server) (push) Has been skipped
feat: Tier 1 & 2 — Daily Note, Voice, Flashcard quota, Readwise, Calendar, Agent Gallery
Tier 1:
- BASIC tier: chat (10/mo) + reformulate (10/mo) désormais accessibles
- Nouveaux quotas: ai_flashcard + voice_transcribe dans tous les tiers
- /api/notes/daily : note du jour auto-créée (find or create)
- Bouton Note du Jour dans la sidebar (CalendarDays)
- Voice-to-Text dans l'éditeur (Web Speech API, bouton Mic toolbar)
- Flashcard generation → quota ai_flashcard (au lieu de reformulate)

Tier 2:
- Intégration Readwise: GET/POST/DELETE /api/integrations/readwise
- Intégration Google Calendar: OAuth flow + today's events + meeting notes
- /api/integrations/calendar + /callback
- Page /settings/integrations avec cards Calendar + Readwise
- SettingsNav: onglet Intégrations
- AgentTemplates: catégories + 4 nouveaux templates (Digest/Recap/AutoTagger/Synthesis)

Schema:
- UserAISettings.integrationTokens Json? (migration 20260529160000)
- prisma generate + migrate deploy appliqués

Fix:
- SpeechRecognition types (triple-slash @types/dom-speech-recognition)
- Notebook.create: suppression champ 'description' inexistant

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-29 15:14:01 +00:00

65 lines
1.6 KiB
TypeScript

import { NextResponse } from 'next/server'
import { auth } from '@/auth'
import prisma from '@/lib/prisma'
function getTodayTitle(): string {
return new Date().toISOString().slice(0, 10) // YYYY-MM-DD
}
function getTodayContent(dateStr: string): string {
const d = new Date(dateStr)
const options: Intl.DateTimeFormatOptions = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
}
const formatted = d.toLocaleDateString('fr-FR', options)
return JSON.stringify({
type: 'doc',
content: [
{ type: 'heading', attrs: { level: 1 }, content: [{ type: 'text', text: `📅 ${formatted}` }] },
{ type: 'paragraph', content: [{ type: 'text', text: '' }] },
],
})
}
/**
* GET /api/notes/daily
* Returns (or creates) today's daily note for the authenticated user.
*/
export async function GET() {
const session = await auth()
if (!session?.user?.id) {
return NextResponse.json({ success: false, error: 'Unauthorized' }, { status: 401 })
}
const today = getTodayTitle()
const userId = session.user.id
// Try to find existing daily note for today
let note = await prisma.note.findFirst({
where: {
userId,
title: today,
type: 'daily',
trashedAt: null,
},
})
if (!note) {
note = await prisma.note.create({
data: {
userId,
title: today,
content: getTodayContent(today),
type: 'daily',
color: '#FEF9C3', // yellow-100 — distinguishes daily notes visually
labels: JSON.stringify(['daily']),
},
})
}
return NextResponse.json({ success: true, note })
}