28 lines
935 B
JavaScript
28 lines
935 B
JavaScript
import { readBody } from 'h3'
|
|
import { z } from 'zod'
|
|
import { requireAdminSession } from '../../../../utils/admin-auth'
|
|
import { createPostExportJob } from '../../../../repositories/post-export-repository'
|
|
|
|
const postExportJobInputSchema = z.object({
|
|
chunkSize: z.number().int().min(1).max(500).optional(),
|
|
retentionDays: z.number().int().min(1).max(100).optional()
|
|
}).default({})
|
|
|
|
/**
|
|
* 관리자 게시물 Export 작업 요청 API
|
|
* @param {import('h3').H3Event} event - 요청 이벤트
|
|
* @returns {Promise<Object>} 생성된 Export 작업
|
|
*/
|
|
export default defineEventHandler(async (event) => {
|
|
const adminSession = requireAdminSession(event)
|
|
const input = postExportJobInputSchema.parse(await readBody(event))
|
|
|
|
return createPostExportJob({
|
|
requestedBy: adminSession.userId,
|
|
requestedEmail: adminSession.email,
|
|
scope: 'all',
|
|
chunkSize: input.chunkSize,
|
|
retentionDays: input.retentionDays
|
|
})
|
|
})
|