29 lines
897 B
JavaScript
29 lines
897 B
JavaScript
import { requireAdminSession } from '../../../../utils/admin-auth.js'
|
|
import { getAnalyticsSummary } from '../../../../repositories/analytics-repository.js'
|
|
import { getPublicBlogStatistics } from '../../../../repositories/blog-statistics-repository.js'
|
|
|
|
/**
|
|
* 관리자 통계 요약 API
|
|
* @param {import('h3').H3Event} event - 요청 이벤트
|
|
* @returns {Promise<Object>} 통계 요약
|
|
*/
|
|
export default defineEventHandler(async (event) => {
|
|
requireAdminSession(event)
|
|
|
|
const query = getQuery(event)
|
|
const days = Number(query.days) || 30
|
|
const period = String(query.period || 'weekly')
|
|
|
|
const [summary, statistics] = await Promise.all([
|
|
getAnalyticsSummary({ days, period }),
|
|
getPublicBlogStatistics()
|
|
])
|
|
|
|
return {
|
|
...summary,
|
|
totalVisitors: statistics.totalVisitors,
|
|
totalPageViews: statistics.totalPageViews,
|
|
totalPosts: statistics.totalPosts
|
|
}
|
|
})
|