Remove code related to demo button in backend

This commit is contained in:
Imbus 2024-03-18 20:56:00 +01:00
parent fe6942aa81
commit 4683dd459a
2 changed files with 6 additions and 22 deletions

View file

@ -34,29 +34,17 @@ type GlobalState interface {
// UpdateCollection(c *fiber.Ctx) error // To update a collection
// DeleteCollection(c *fiber.Ctx) error // To delete a collection
// SignCollection(c *fiber.Ctx) error // To sign a collection
GetButtonCount(c *fiber.Ctx) error // For demonstration purposes
IncrementButtonCount(c *fiber.Ctx) error // For demonstration purposes
ListAllUsers(c *fiber.Ctx) error // To get a list of all users in the application database
ListAllUsersProject(c *fiber.Ctx) error // To get a list of all users for a specific project
ProjectRoleChange(c *fiber.Ctx) error // To change a users role in a project
ListAllUsers(c *fiber.Ctx) error // To get a list of all users in the application database
ListAllUsersProject(c *fiber.Ctx) error // To get a list of all users for a specific project
ProjectRoleChange(c *fiber.Ctx) error // To change a users role in a project
}
// "Constructor"
func NewGlobalState(db database.Database) GlobalState {
return &GState{Db: db, ButtonCount: 0}
return &GState{Db: db}
}
// The global state, which implements all the handlers
type GState struct {
Db database.Database
ButtonCount int
}
func (gs *GState) GetButtonCount(c *fiber.Ctx) error {
return c.Status(200).JSON(fiber.Map{"pressCount": gs.ButtonCount})
}
func (gs *GState) IncrementButtonCount(c *fiber.Ctx) error {
gs.ButtonCount++
return c.Status(200).JSON(fiber.Map{"pressCount": gs.ButtonCount})
Db database.Database
}

View file

@ -61,11 +61,6 @@ func main() {
// Register our unprotected routes
server.Post("/api/register", gs.Register)
// Register handlers for example button count
server.Get("/api/button", gs.GetButtonCount)
server.Post("/api/button", gs.IncrementButtonCount)
server.Post("/api/login", gs.Login)
// Every route from here on will require a valid JWT
@ -73,6 +68,7 @@ func main() {
SigningKey: jwtware.SigningKey{Key: []byte("secret")},
}))
// Protected routes (require a valid JWT bearer token authentication header)
server.Post("/api/submitReport", gs.SubmitWeeklyReport)
server.Get("/api/getUserProjects", gs.GetUserProjects)
server.Post("/api/loginrenew", gs.LoginRenew)