b90ff252d1
Public archive with sidebar navigation, project pages, month archive, search and entry pages with image blocks. Admin area for brands, projects, post types, users, api clients, media and the entry editor with drag and drop images, preview per audience, scheduling and publish checks. Read and write API with bearer tokens, audience scoping, idempotent creation, OpenAPI document and editorial guide. Magic link login with configurable allowed domains, whole app behind the session gate. 456 tests including design rule checks.
37 lines
932 B
TypeScript
37 lines
932 B
TypeScript
import { z } from 'zod'
|
|
import { markRead } from '~/data/repositories/reads'
|
|
import { resolveClient } from '~/lib/api-auth'
|
|
import { problem } from '~/lib/problem'
|
|
|
|
const bodySchema = z.object({
|
|
external_user_id: z.string().min(1),
|
|
post_ids: z.array(z.uuid()).min(1).max(200),
|
|
})
|
|
|
|
export async function POST(request: Request) {
|
|
const client = await resolveClient(request)
|
|
|
|
if (!client) {
|
|
return problem(401, 'unauthorized')
|
|
}
|
|
|
|
if (!client.projectId) {
|
|
return problem(422, 'client_without_project')
|
|
}
|
|
|
|
const parsed = bodySchema.safeParse(await request.json().catch(() => null))
|
|
|
|
if (!parsed.success) {
|
|
return problem(400, 'invalid_body', parsed.error.issues.map(issue => issue.path.join('.')).join(', '))
|
|
}
|
|
|
|
const marked = await markRead({
|
|
projectId: client.projectId,
|
|
externalUserId: parsed.data.external_user_id,
|
|
scope: client.scope,
|
|
postIds: parsed.data.post_ids,
|
|
})
|
|
|
|
return Response.json({ marked })
|
|
}
|