Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
thebkht committed Oct 30, 2023
1 parent cba2191 commit b17c67a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
10 changes: 7 additions & 3 deletions app/api/feed/route.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import postgres from '@/lib/postgres'
import { NextRequest, NextResponse } from 'next/server'

export async function POST(req: NextRequest) {
const { page = 0, tag, id } = await req.json()
if (!id) {
export async function GET(req: NextRequest) {
const pageString = req.nextUrl.searchParams.get('page') || 0
const page = Number(pageString)
const tag = req.nextUrl.searchParams.get('tag')
const idString = req.nextUrl.searchParams.get('id')
if (!idString) {
return NextResponse.json({ error: 'No user found' }, { status: 500 })
}
const id = Number(idString)
if (tag) {
const postTags = await postgres.postTag.findMany({
select: { postId: true },
Expand Down
16 changes: 2 additions & 14 deletions app/api/session/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { config } from "@/app/auth";
import postgres from "@/lib/postgres";
import { getServerSession } from "next-auth";
import { NextRequest, NextResponse } from "next/server";

export async function POST(req: NextRequest) {
Expand All @@ -15,22 +14,12 @@ export async function POST(req: NextRequest) {
include: {
Followers: {
include: {
follower: {
include: {
Followers: true,
Followings: true,
},
},
follower: true,
},
},
Followings: {
include: {
following: {
include: {
Followers: true,
Followings: true,
},
},
following: true,
},
},
bookmarks: {
Expand All @@ -42,7 +31,6 @@ export async function POST(req: NextRequest) {
}
}
},
posts: true,
notifications: true,
settings: true,
tagfollower: {
Expand Down
9 changes: 3 additions & 6 deletions components/feed/get-feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import { getSessionUser } from "../get-session-user";
export const fetchFeed = async ({ page = 0, tag }: { page?: number, tag?: string | undefined }) => {
const user = await getSessionUser();

const result = await fetch(process.env.DOMAIN + "/api/feed", {
method: "POST",
body: JSON.stringify({ page, tag, id: user?.id }),
headers: {
"Content-Type": "application/json",
const result = await fetch(process.env.DOMAIN + "/api/feed?page=" + page + "?tag=" + "?id=" + user?.id , {
method: "GET",
},
}).then((res) => res.json());
).then((res) => res.json());

return result?.feed;
}

0 comments on commit b17c67a

Please sign in to comment.