security/main.go

67 lines
1.8 KiB
Go
Raw Normal View History

2024-03-21 20:20:24 +00:00
/*
2024-08-13 19:40:44 +00:00
* security | MatterLinux package security tracker
2024-08-13 19:25:36 +00:00
* MatterLinux 2023-2024 (https://matterlinux.xyz)
2024-03-21 20:20:24 +00:00
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2024-08-13 19:25:36 +00:00
*/
2024-03-21 20:20:24 +00:00
package main
import (
"git.matterlinux.xyz/matter/security/lib"
2024-08-13 19:40:44 +00:00
"git.matterlinux.xyz/matter/security/log"
2024-03-21 20:20:24 +00:00
"git.matterlinux.xyz/matter/security/routes"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html/v2"
)
func main() {
2024-08-13 19:25:36 +00:00
engine := html.New("./templates", ".html")
app := fiber.New(fiber.Config{
DisableStartupMessage: true,
Views: engine,
})
err := lib.LoadDatabase()
if err != nil {
2024-08-13 19:40:44 +00:00
log.Error("Failed to load database: %s", err.Error())
return
2024-08-13 19:25:36 +00:00
}
app.Static("/", "./public")
2024-08-13 19:40:44 +00:00
app.Get("/", routes.GET_Index)
app.Get("/details/:id", routes.GET_Details)
2024-08-13 19:25:36 +00:00
2024-08-13 19:40:44 +00:00
app.Get("/login", routes.GET_Login)
app.Post("/login", routes.POST_Login)
2024-08-13 19:25:36 +00:00
app.Use("/manage", routes.MiddleAuth)
2024-08-13 19:40:44 +00:00
app.Get("/manage", routes.GET_Manage)
app.Get("/manage/logout", routes.GET_Logout)
app.Post("/manage/new", routes.POST_New)
app.Post("/manage/status", routes.POST_Status)
2024-08-13 19:25:36 +00:00
app.Get("*", func(c *fiber.Ctx) error {
return lib.RenderError(c, 404)
})
2024-08-13 19:40:44 +00:00
log.Info("Starting MatterLinux security tracker on port 9876")
if err = app.Listen(":9876"); err != nil {
log.Info("Error starting server: %s", err)
2024-08-13 19:25:36 +00:00
}
2024-03-21 20:20:24 +00:00
}