feat: add notes app

This commit is contained in:
2026-10-01 19:39:20 +02:00
parent ccb8dd3d15
commit ddbb6f37b5
35 changed files with 706 additions and 52 deletions
+40
View File
@@ -0,0 +1,40 @@
import type { H3Event } from 'h3'
export interface NotesDocRow {
id: number
title: string | null
content?: string | null
created: string | null
updated: string | null
}
export const NOTES_SUMMARY_FIELDS = 'title,created,updated'
export function notesTable(event: H3Event): string {
const { baserowNotesAppTableId } = useRuntimeConfig(event)
if (!baserowNotesAppTableId) {
throw createError({ statusCode: 500, statusMessage: 'NUXT_BASEROW_NOTES_APP_TABLE_ID is not set' })
}
return baserowNotesAppTableId
}
export function notesDocId(event: H3Event): number {
const id = Number(getRouterParam(event, 'id'))
if (!Number.isInteger(id) || id < 1) {
throw createError({ statusCode: 400, statusMessage: 'Invalid note' })
}
return id
}
/** `created` and `updated` are plain date fields, so the server keeps them up to date */
export function notesNow(): string {
return new Date().toISOString()
}
export function toNotesDocSummary(row: NotesDocRow): NotesDocSummary {
return { id: row.id, title: (row.title ?? '').trim(), created: row.created, updated: row.updated }
}
export function toNotesDoc(row: NotesDocRow): NotesDoc {
return { ...toNotesDocSummary(row), content: row.content ?? '' }
}