INNER CODE UNIT · TypeScript
saveNote
vercel/server-components-notes-demo · app/actions.ts:9
export async function saveNote(
noteId: string | null,
title: string,
body: string
) {
const cookieStore = await cookies()
const userCookie = cookieStore.get(userCookieKey)
const user = getUser(userCookie?.value)
if (!noteId) {
noteId = Date.now().toString()
}
const payload = {
id: noteId,
title: title.slice(0, 255),
updated_at: Date.now(),
body: body.slice(0, 2048),