feat: ditch triplit, move to postgresql + drizzle orm

This commit is contained in:
Zoe
2026-04-08 17:03:07 -05:00
parent c341c96798
commit e2e3ac6e86
121 changed files with 6680 additions and 4373 deletions
@@ -0,0 +1,44 @@
import { and, eq } from 'drizzle-orm';
import { topics } from '~~/drizzle/schema';
import { db } from '~~/server/lib/db';
import { cancelPendingRename } from '~~/server/utils/renames';
import { userEvents } from '~~/server/utils/events';
export default defineEventHandler(async (event) => {
await protectRoute(event);
const topicId = getRouterParam(event, 'topicId')!;
const success = cancelPendingRename(topicId);
if (success) {
const res = await db.update(topics).set({
renaming: false,
}).where(and(eq(topics.id, topicId), eq(topics.userId, event.context.user!.id)));
if (res.rowCount === 0) {
throw createError({
statusCode: 400,
statusMessage: 'Invalid topic',
data: {
code: 'INVALID_TOPIC',
ok: false,
}
});
}
userEvents.emit(topicId, 'topics', {
op: 'update',
payload: {
topicId,
renaming: false,
},
});
return {
ok: true,
};
}
return {
ok: false,
};
});