initial commit

This commit is contained in:
Kar k1
2025-08-30 18:18:57 +05:30
commit 7219108342
270 changed files with 70221 additions and 0 deletions

33
app/api/auth/me/route.ts Normal file
View File

@@ -0,0 +1,33 @@
import { NextRequest, NextResponse } from 'next/server'
import { withAuth } from '@/lib/auth-middleware'
import connectDB from '@/lib/mongodb'
import { User } from '@/models/user'
export const GET = withAuth(async (request: NextRequest & { user?: any }) => {
try {
// Connect to database
await connectDB()
// Get user details
const user = await User.findById(request.user.userId).select('-password -refreshToken')
if (!user) {
return NextResponse.json(
{ success: false, error: { message: 'User not found', code: 'USER_NOT_FOUND' } },
{ status: 404 }
)
}
return NextResponse.json({
success: true,
data: { user: user.toJSON() },
})
} catch (error) {
console.error('Get user info error:', error)
return NextResponse.json(
{ success: false, error: { message: 'Internal server error', code: 'INTERNAL_ERROR' } },
{ status: 500 }
)
}
})