File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { NextResponse } from "next/server" ;
2+ import { PrismaClient } from "@prisma/client" ;
3+
4+ const prisma = new PrismaClient ( ) ;
5+
6+ export async function GET ( ) {
7+ try {
8+ const events = await prisma . event . findMany ( {
9+ include : {
10+ savedBy : {
11+ include : {
12+ user : {
13+ include : {
14+ pushSubscriptions : true
15+ }
16+ }
17+ }
18+ }
19+ } ,
20+ orderBy : { createdAt : 'desc' } ,
21+ take : 5
22+ } ) ;
23+
24+ const users = await prisma . user . findMany ( {
25+ include : {
26+ pushSubscriptions : true
27+ } ,
28+ take : 5
29+ } ) ;
30+
31+ return NextResponse . json ( {
32+ serverTime : new Date ( ) . toISOString ( ) ,
33+ recentEvents : events ,
34+ recentUsers : users ,
35+ envVars : {
36+ hasVapidPublic : ! ! process . env . NEXT_PUBLIC_VAPID_PUBLIC_KEY ,
37+ hasVapidPrivate : ! ! process . env . VAPID_PRIVATE_KEY ,
38+ vapidSubject : process . env . VAPID_SUBJECT ,
39+ }
40+ } ) ;
41+ } catch ( error : any ) {
42+ return NextResponse . json ( { error : error . message } , { status : 500 } ) ;
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments