Creating Band edit page

This commit is contained in:
2024-10-26 14:35:33 +02:00
parent fedb821a72
commit cdb3f02156
16 changed files with 377 additions and 41 deletions

View File

@@ -43,7 +43,7 @@ account.post("/login", (req: Request, res: Response) => {
})
// Creating a new user
account.post("/", (req: Request, res: Response) => {
account.post("/", async (req: Request, res: Response) => {
// Check if username is valid
if (!validateString(req.body.username, 4))
{
@@ -65,6 +65,15 @@ account.post("/", (req: Request, res: Response) => {
}
// Create account
await AccountRole.findOne({
where: {
name: "User"
}
})
.then(role => {
req.body["accountRoleId"] = role.id
})
Account.create(req.body)
.then(account => {
// Status: 201 Created

View File

@@ -133,4 +133,26 @@ band.get("/search", (req: Request, res: Response) => {
.then(bands => {
res.status(200).json(bands)
})
})
// Edit band
band.patch("/", (req: Request, res: Response) => {
Band.update(req.body, {
where: {
id: req.body.id
}
})
.then(result => {
res.status(200).json(result)
})
})
// New band
band.post("/", (req: Request, res: Response) => {
Band.create(req.body)
.then(result => {
res.status(200).json(result)
})
})