feat: Added team creation, closes #22
All checks were successful
Build and Deploy / Deploy Web (push) Successful in 1m1s
Build and Deploy / Deploy Discord Bot (push) Successful in 42s

This commit is contained in:
Xeovalyte 2023-06-06 14:29:05 +02:00
parent e68097d813
commit 9510e8a407
3 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,12 @@
export default defineEventHandler(async (event) => {
const { name, color } = await readBody(event)
const team = new TeamModel({
name,
color
})
await team.save()
return team
})

View File

@ -27,5 +27,14 @@ const whitelistSchema = new Schema({
code: { type: String, required: true, unique: true, length: 6 } code: { type: String, required: true, unique: true, length: 6 }
}) })
const teamSchema = new Schema({
name: { type: String, required: true, minLength: 3, maxLength: 16, unique: true, match: /^[a-zA-Z0-9]+$/ },
color: { type: String, required: true, match: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/ },
amount: { type: Number, required: true, default: 1 },
textChannelId: { type: String, required: false },
voiceChannelId: { type: String, required: false }
})
export const UserModel = model<IUser>('User', userSchema) export const UserModel = model<IUser>('User', userSchema)
export const WhitelistModel = model<IWhitelist>('Whitelist', whitelistSchema) export const WhitelistModel = model<IWhitelist>('Whitelist', whitelistSchema)
export const TeamModel = model<ITeam>('Team', teamSchema)

View File

@ -31,4 +31,13 @@ declare global {
connected: boolean, connected: boolean,
code: string code: string
} }
interface ITeam {
_id: string,
name: string,
color: string,
amount: number,
textChannelId: string,
voiceChannelId: string
}
} }