Skip to content

Commit e4b5561

Browse files
home api
1 parent ec2e5f8 commit e4b5561

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pages/api/index.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { NextApiRequest, NextApiResponse } from 'next';
2+
import prisma from '@/lib/prisma';
3+
4+
export default async function handler(
5+
req: NextApiRequest,
6+
res: NextApiResponse
7+
) {
8+
const feed = await prisma.post.findMany({
9+
where: { published: true },
10+
include: {
11+
author: {
12+
select: { name: true, image: true }
13+
}
14+
}
15+
});
16+
17+
const users = await prisma.user.findMany({
18+
take: 10,
19+
select: { id: true, name: true, email: true, image: true }
20+
});
21+
22+
res.json({ feed, users });
23+
}

0 commit comments

Comments
 (0)