Remove code related to demo button in backend
This commit is contained in:
		
							parent
							
								
									fe6942aa81
								
							
						
					
					
						commit
						4683dd459a
					
				
					 2 changed files with 6 additions and 22 deletions
				
			
		| 
						 | 
					@ -34,8 +34,6 @@ type GlobalState interface {
 | 
				
			||||||
	// UpdateCollection(c *fiber.Ctx) error     // To update a collection
 | 
						// UpdateCollection(c *fiber.Ctx) error     // To update a collection
 | 
				
			||||||
	// DeleteCollection(c *fiber.Ctx) error     // To delete a collection
 | 
						// DeleteCollection(c *fiber.Ctx) error     // To delete a collection
 | 
				
			||||||
	// SignCollection(c *fiber.Ctx) error       // To sign 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
 | 
						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
 | 
						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
 | 
						ProjectRoleChange(c *fiber.Ctx) error   // To change a users role in a project
 | 
				
			||||||
| 
						 | 
					@ -43,20 +41,10 @@ type GlobalState interface {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// "Constructor"
 | 
					// "Constructor"
 | 
				
			||||||
func NewGlobalState(db database.Database) GlobalState {
 | 
					func NewGlobalState(db database.Database) GlobalState {
 | 
				
			||||||
	return &GState{Db: db, ButtonCount: 0}
 | 
						return &GState{Db: db}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// The global state, which implements all the handlers
 | 
					// The global state, which implements all the handlers
 | 
				
			||||||
type GState struct {
 | 
					type GState struct {
 | 
				
			||||||
	Db database.Database
 | 
						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})
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,11 +61,6 @@ func main() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Register our unprotected routes
 | 
						// Register our unprotected routes
 | 
				
			||||||
	server.Post("/api/register", gs.Register)
 | 
						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)
 | 
						server.Post("/api/login", gs.Login)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Every route from here on will require a valid JWT
 | 
						// Every route from here on will require a valid JWT
 | 
				
			||||||
| 
						 | 
					@ -73,6 +68,7 @@ func main() {
 | 
				
			||||||
		SigningKey: jwtware.SigningKey{Key: []byte("secret")},
 | 
							SigningKey: jwtware.SigningKey{Key: []byte("secret")},
 | 
				
			||||||
	}))
 | 
						}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Protected routes (require a valid JWT bearer token authentication header)
 | 
				
			||||||
	server.Post("/api/submitReport", gs.SubmitWeeklyReport)
 | 
						server.Post("/api/submitReport", gs.SubmitWeeklyReport)
 | 
				
			||||||
	server.Get("/api/getUserProjects", gs.GetUserProjects)
 | 
						server.Get("/api/getUserProjects", gs.GetUserProjects)
 | 
				
			||||||
	server.Post("/api/loginrenew", gs.LoginRenew)
 | 
						server.Post("/api/loginrenew", gs.LoginRenew)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue