mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-14 20:25:41 +00:00
18 lines
535 B
TypeScript
18 lines
535 B
TypeScript
import type {NextApiRequest, NextApiResponse} from 'next'
|
|
import {prisma} from '@/lib/prisma'
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
try {
|
|
const totalViews: { _sum: { count: any } } = await prisma.views.aggregate({
|
|
_sum: {
|
|
count: true
|
|
}
|
|
})
|
|
|
|
return res.status(200).json({
|
|
views: totalViews._sum.count.toString()
|
|
})
|
|
} catch (e: any) {
|
|
return res.status(500).json({message: e.message})
|
|
}
|
|
} |