main
Last change
on this file since 87c9f1e was 87c9f1e, checked in by Naum Shapkarovski <naumshapkarovski@…>, 5 weeks ago |
update the seed script. update the prisma schema, use mapping
|
-
Property mode
set to
100644
|
File size:
802 bytes
|
Rev | Line | |
---|
[87c9f1e] | 1 | import { NextResponse } from 'next/server';
|
---|
| 2 | import { authenticateRequest } from 'src/lib/auth-middleware';
|
---|
| 3 | import { type NextRequest } from 'next/server';
|
---|
| 4 | import prisma from 'src/lib/prisma';
|
---|
| 5 |
|
---|
| 6 | export async function GET(request: NextRequest) {
|
---|
| 7 | try {
|
---|
| 8 | const authResult = await authenticateRequest(request);
|
---|
| 9 |
|
---|
| 10 | if (authResult instanceof NextResponse) {
|
---|
| 11 | return authResult;
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 | // Get user from Prisma
|
---|
| 15 | const user = await prisma.user.findUnique({
|
---|
| 16 | where: {
|
---|
| 17 | id: authResult.userId,
|
---|
| 18 | },
|
---|
| 19 | });
|
---|
| 20 |
|
---|
| 21 | if (!user) {
|
---|
| 22 | return NextResponse.json({ error: 'User not found' }, { status: 404 });
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | return NextResponse.json(user);
|
---|
| 26 | } catch (error) {
|
---|
| 27 | console.error(error);
|
---|
| 28 | return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
---|
| 29 | }
|
---|
| 30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.