mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
added newStreamingProfile
service
This commit is contained in:
parent
df7185d741
commit
a04e1a7a59
28
packages/server/src/services/newStreamingProfile/index.js
Normal file
28
packages/server/src/services/newStreamingProfile/index.js
Normal 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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user