feat: Added team creation, closes #22
This commit is contained in:
parent
e68097d813
commit
9510e8a407
12
webv2/server/api/teams/index.post.ts
Normal file
12
webv2/server/api/teams/index.post.ts
Normal 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
|
||||
})
|
@ -27,5 +27,14 @@ const whitelistSchema = new Schema({
|
||||
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 WhitelistModel = model<IWhitelist>('Whitelist', whitelistSchema)
|
||||
export const TeamModel = model<ITeam>('Team', teamSchema)
|
||||
|
9
webv2/types/global.d.ts
vendored
9
webv2/types/global.d.ts
vendored
@ -31,4 +31,13 @@ declare global {
|
||||
connected: boolean,
|
||||
code: string
|
||||
}
|
||||
|
||||
interface ITeam {
|
||||
_id: string,
|
||||
name: string,
|
||||
color: string,
|
||||
amount: number,
|
||||
textChannelId: string,
|
||||
voiceChannelId: string
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user