Replace PostgreSQL and Docker deployment with embedded Turso, Drizzle relational queries v2, native systemd deployment on port 43821, and fresh SQLite migrations.

Hop-State: A_06FP5KEDBTB4A9ZT7QB498G
Hop-Proposal: R_06FP5KDWMCKVVMQZT4MVZ28
Hop-Task: T_06FP5DZ7T0G45FG93PT90B8
Hop-Attempt: AT_06FP5DZ7T0PKQW99V27JCV8
This commit is contained in:
2026-07-14 15:44:42 -07:00
committed by Hop
184 changed files with 8375 additions and 53944 deletions
+16 -24
View File
@@ -95,7 +95,7 @@ export async function GET(request: Request, context: RouteContext) {
}
const user = await db.query.users.findFirst({
where: eq(users.handle, cleanHandle),
where: { handle: cleanHandle },
});
const isRemotePlaceholder = user && cleanHandle.includes('@');
@@ -121,30 +121,29 @@ export async function GET(request: Request, context: RouteContext) {
return NextResponse.json({ error: 'User not found' }, { status: 404 });
}
let whereConditions = and(
eq(posts.userId, user.id),
eq(posts.isRemoved, false),
or(isNotNull(posts.replyToId), isNotNull(posts.swarmReplyToId)),
);
let cursorDate: Date | undefined;
if (cursor) {
const cursorPost = await db.query.posts.findFirst({
where: eq(posts.id, cursor),
where: { id: cursor },
});
if (cursorPost) {
whereConditions = and(
eq(posts.userId, user.id),
eq(posts.isRemoved, false),
or(isNotNull(posts.replyToId), isNotNull(posts.swarmReplyToId)),
lt(posts.createdAt, cursorPost.createdAt),
);
cursorDate = cursorPost.createdAt;
}
}
let replyPosts: any[] = await db.query.posts.findMany({
where: whereConditions,
where: {
userId: user.id,
isRemoved: false,
OR: [
{ replyToId: { isNotNull: true } },
{ swarmReplyToId: { isNotNull: true } },
],
...(cursorDate ? { createdAt: { lt: cursorDate } } : {}),
},
with: replyRelations,
orderBy: [desc(posts.createdAt)],
orderBy: () => [desc(posts.createdAt)],
limit,
});
@@ -158,21 +157,14 @@ export async function GET(request: Request, context: RouteContext) {
const viewerLikes = postIds.length > 0
? await db.query.likes.findMany({
where: and(
eq(likes.userId, viewer.id),
inArray(likes.postId, postIds),
),
where: { AND: [{ userId: viewer.id }, { postId: { in: postIds } }] },
})
: [];
const likedPostIds = new Set(viewerLikes.map((like) => like.postId));
const viewerReposts = postIds.length > 0
? await db.query.posts.findMany({
where: and(
eq(posts.userId, viewer.id),
inArray(posts.repostOfId, postIds),
eq(posts.isRemoved, false),
),
where: { AND: [{ userId: viewer.id }, { repostOfId: { in: postIds } }, { isRemoved: false }] },
})
: [];
const repostedPostIds = new Set(viewerReposts.map((post) => post.repostOfId));