···106106 ))}
107107 </div>
108108109109- <p>The 88x31 buttons are the property of their respective owners, check their websites out!</p>
109109+ <p>Check out these cool people!</p>
110110 </>
111111 );
112112}
+35
app/api/v1/post/[slug]/comment/route.ts
···11+import { db } from '@/lib/db/drizzle';
22+import { commentsTable, postsTable } from '@/lib/db/schema';
33+import { eq } from 'drizzle-orm';
44+import { NextRequest } from 'next/server';
55+66+export async function GET(
77+ req: NextRequest,
88+ ctx: RouteContext<'/api/v1/post/[slug]'>
99+) {
1010+ const { slug } = await ctx.params;
1111+1212+ const post = await db
1313+ .select()
1414+ .from(postsTable)
1515+ .where(eq(postsTable.slug, slug))
1616+ .limit(1);
1717+1818+ if (post.length < 1)
1919+ return Response.json(
2020+ {
2121+ error: 404,
2222+ message: `Post with slug \`${slug}\` not found.`
2323+ },
2424+ {
2525+ status: 404
2626+ }
2727+ );
2828+2929+ const comments = await db
3030+ .select()
3131+ .from(commentsTable)
3232+ .where(eq(commentsTable.post, post[0].id));
3333+3434+ return Response.json(comments);
3535+}
+30
app/api/v1/post/[slug]/route.ts
···11+import { db } from '@/lib/db/drizzle';
22+import { postsTable } from '@/lib/db/schema';
33+import { eq } from 'drizzle-orm';
44+import { NextRequest } from 'next/server';
55+66+export async function GET(
77+ req: NextRequest,
88+ ctx: RouteContext<'/api/v1/post/[slug]'>
99+) {
1010+ const { slug } = await ctx.params;
1111+1212+ const post = await db
1313+ .select()
1414+ .from(postsTable)
1515+ .where(eq(postsTable.slug, slug))
1616+ .limit(1);
1717+1818+ if (post.length < 1)
1919+ return Response.json(
2020+ {
2121+ error: 404,
2222+ message: `Post with slug \`${slug}\` not found.`
2323+ },
2424+ {
2525+ status: 404
2626+ }
2727+ );
2828+2929+ return Response.json(post[0]);
3030+}
+45
app/api/v1/user/[id]/route.ts
···11+import { db } from '@/lib/db/drizzle';
22+import { usersTable } from '@/lib/db/schema';
33+import { eq, getTableColumns } from 'drizzle-orm';
44+import { NextRequest } from 'next/server';
55+66+export async function GET(
77+ req: NextRequest,
88+ ctx: RouteContext<'/api/v1/user/[id]'>
99+) {
1010+ const { id } = await ctx.params;
1111+1212+ try {
1313+ BigInt(id);
1414+ } catch (e: unknown) {
1515+ return Response.json(
1616+ {
1717+ error: 400,
1818+ message: `\`id\` was not a BigInt.`
1919+ },
2020+ {
2121+ status: 400
2222+ }
2323+ );
2424+ }
2525+2626+ const { password, email, ...rest } = getTableColumns(usersTable);
2727+ const user = await db
2828+ .select({ ...rest })
2929+ .from(usersTable)
3030+ .where(eq(usersTable.id, BigInt(id)))
3131+ .limit(1);
3232+3333+ if (user.length < 1)
3434+ return Response.json(
3535+ {
3636+ error: 404,
3737+ message: `User with id \`${id}\` not found.`
3838+ },
3939+ {
4040+ status: 404
4141+ }
4242+ );
4343+4444+ return Response.json(user[0]);
4545+}