feat: migrate to Better Auth for authentication, update environment variables, and enhance database schema with accounts and sessions

This commit is contained in:
2025-12-20 11:00:00 +00:00
parent 377836d1fa
commit 7bff6b0f91
13 changed files with 183 additions and 205 deletions

View File

@@ -46,16 +46,16 @@ router.post('/upload-url', async (req, res) => {
return;
}
const user = req.user;
const authSession = req.auth;
if (!user) {
if (!authSession?.user) {
res.status(401).json({ message: 'Unauthorized' });
return;
}
await ensureMinioBucket();
const objectKey = buildObjectKey(user.userId, parsed.data.fileName, parsed.data.prefix);
const objectKey = buildObjectKey(authSession.user.id, parsed.data.fileName, parsed.data.prefix);
const uploadUrl = await minioClient.presignedPutObject(minioBucket, objectKey, minioPresignedExpirySeconds);
const now = new Date();
const expiresAt = new Date(now.getTime() + minioPresignedExpirySeconds * 1000);
@@ -63,7 +63,7 @@ router.post('/upload-url', async (req, res) => {
const [videoRecord] = await db
.insert(videos)
.values({
userId: user.userId,
userId: authSession.user.id,
objectKey,
bucket: minioBucket,
uploadUrl,