File tree Expand file tree Collapse file tree 3 files changed +68
-1
lines changed Expand file tree Collapse file tree 3 files changed +68
-1
lines changed Original file line number Diff line number Diff line change 11ignore :
2- - app/api/*
2+ - app/api/**/*
Original file line number Diff line number Diff line change 1+ import { NextResponse } from 'next/server' ;
2+ import { prisma } from '../../../../lib/prisma' ;
3+
4+ export async function GET (
5+ request : Request ,
6+ { params } : { params : { id : string } }
7+ ) {
8+ try {
9+ const { id } = params ;
10+ const dominion = await prisma . dominion . findUnique ( {
11+ where : { id } ,
12+ include : {
13+ posts : true , // Include posts by the dominion
14+ accounts : true , // Include dominion accounts
15+ } ,
16+ } ) ;
17+
18+ if ( ! dominion ) {
19+ return NextResponse . json ( { message : 'dominion not found' } , { status : 404 } ) ;
20+ }
21+
22+ return NextResponse . json ( dominion ) ;
23+ } catch ( error ) {
24+ console . error ( 'Error fetching dominion:' , error ) ;
25+ return NextResponse . json ( { message : 'Error fetching dominion' } , { status : 500 } ) ;
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ import { NextResponse } from 'next/server'
2+ import { prisma } from '@/lib/prisma'
3+ import { getServerSession } from 'next-auth'
4+
5+ export async function GET ( ) {
6+ const session = await getServerSession ( )
7+
8+ if ( ! session ) {
9+ return NextResponse . json ( { error : 'Unauthorized' } , { status : 401 } )
10+ }
11+
12+ try {
13+ const totaldominion = await prisma . dominion . count ( )
14+ const activedominion = await prisma . session . count ( {
15+ where : {
16+ expires : {
17+ gt : new Date ( )
18+ }
19+ }
20+ } )
21+
22+ const recentdominion = await prisma . dominion . count ( {
23+ where : {
24+ createdAt : {
25+ gte : new Date ( Date . now ( ) - 7 * 24 * 60 * 60 * 1000 ) // Last 7 days
26+ }
27+ }
28+ } )
29+
30+ return NextResponse . json ( {
31+ totaldominion,
32+ activedominion,
33+ recentdominions,
34+ timestamp : new Date ( ) . toISOString ( )
35+ } )
36+ } catch ( error ) {
37+ console . error ( 'Stats error:' , error )
38+ return NextResponse . json ( { error : 'Failed to fetch stats' } , { status : 500 } )
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments