added newStreamingProfile service

This commit is contained in:
SrGooglo 2023-04-10 16:19:21 +00:00
parent df7185d741
commit a04e1a7a59

View File

@ -0,0 +1,28 @@
import { StreamingProfile } from "@models"
export default async (profile = {}) => {
if (!profile.user_id) {
throw new Error("Invalid request, missing user_id")
}
if (!profile.profile_name) {
throw new Error("Invalid request, missing profile_name")
}
const newProfile = new StreamingProfile({
user_id: profile.user_id,
profile_name: profile.profile_name,
stream_key: global.nanoid(),
info: {
title: "Untitled",
description: "No description",
category: "other",
thumbnail: null,
...profile.info,
}
})
await newProfile.save()
return newProfile
}