mirror of https://github.com/MaxLeiter/Drift
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
544 B
TypeScript
22 lines
544 B
TypeScript
import { parseQueryParam } from "@lib/server/parse-query-param"
|
|
import { getPostsByUser } from "app/prisma"
|
|
import { NextApiRequest, NextApiResponse } from "next"
|
|
|
|
export default async function handle(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse
|
|
) {
|
|
switch (req.method) {
|
|
case "GET":
|
|
const userId = parseQueryParam(req.query.userId)
|
|
if (!userId) {
|
|
return res.status(400).json({ error: "Missing userId" })
|
|
}
|
|
|
|
const posts = await getPostsByUser(userId)
|
|
return res.json(posts)
|
|
default:
|
|
return res.status(405).end()
|
|
}
|
|
}
|