refactor(backend): split stream routes into focused modules
This commit is contained in:
27
Backend/services/recordings.ts
Normal file
27
Backend/services/recordings.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
import { db } from '../db/client';
|
||||
import { recordings, streamSessions } from '../db/schema';
|
||||
|
||||
export const createRecordingForStream = async (streamSessionId: string): Promise<void> => {
|
||||
const stream = await db.query.streamSessions.findFirst({ where: eq(streamSessions.id, streamSessionId) });
|
||||
|
||||
if (!stream) {
|
||||
return;
|
||||
}
|
||||
|
||||
const existing = await db.query.recordings.findFirst({ where: eq(recordings.streamSessionId, stream.id) });
|
||||
|
||||
if (existing) {
|
||||
return;
|
||||
}
|
||||
|
||||
await db.insert(recordings).values({
|
||||
ownerUserId: stream.ownerUserId,
|
||||
streamSessionId: stream.id,
|
||||
cameraDeviceId: stream.cameraDeviceId,
|
||||
requesterDeviceId: stream.requesterDeviceId,
|
||||
status: 'awaiting_upload',
|
||||
updatedAt: new Date(),
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user