StarlioX/main.go

62 lines
1.4 KiB
Go
Raw Normal View History

2022-09-18 19:29:08 +03:00
package main
import (
"github.com/Redume/EveryNasa/api/controllers"
"github.com/Redume/EveryNasa/functions"
"github.com/Redume/EveryNasa/web/page"
2022-09-19 13:23:39 +03:00
"github.com/getlantern/systray"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
2022-09-18 19:29:08 +03:00
)
func main() {
go functions.Database()
go systray.Run(functions.Tray, functions.Quit)
go functions.StartWallpaper()
app := fiber.New()
app.Static("/static", "./web/static")
app.Use(cors.New())
2022-10-02 12:24:00 +03:00
app.Get("/", func(c *fiber.Ctx) error {
return page.Gallery(c)
})
app.Get("/settings", func(c *fiber.Ctx) error {
return page.Settings(c)
})
app.Get("/about", func(c *fiber.Ctx) error {
return page.About(c)
})
2022-10-02 12:24:00 +03:00
app.Post("/api/update/settings", func(c *fiber.Ctx) error {
return controllers.SettingsUpdate(c)
})
app.Post("/api/update/wallpaper", func(c *fiber.Ctx) error {
return controllers.WallpaperUpdate(c)
})
app.Post("/api/update/startup", func(c *fiber.Ctx) error {
return controllers.Startup(c)
})
app.Post("/api/create/label", func(c *fiber.Ctx) error {
return controllers.CreateLabel(c)
})
2022-10-02 12:24:00 +03:00
app.Get("/api/get/settings", func(c *fiber.Ctx) error {
return controllers.SettingsGet(c)
})
2022-09-18 19:29:08 +03:00
app.Use(func(c *fiber.Ctx) error {
err := c.SendStatus(404)
2022-09-18 19:29:08 +03:00
if err != nil {
2022-09-25 11:10:27 +03:00
functions.Logger(err.Error())
2022-09-18 19:29:08 +03:00
}
return c.SendFile("./web/errors/404.html")
})
2022-09-18 19:29:08 +03:00
err := app.Listen(":3000")
2022-09-18 19:29:08 +03:00
if err != nil {
return
2022-09-18 19:29:08 +03:00
}
}