timetracker update
This commit is contained in:
26
app/delivery/web/general/bo.go
Normal file
26
app/delivery/web/general/bo.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package general
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/timetracker/assets"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/gofiber/fiber/v3/middleware/static"
|
||||
)
|
||||
|
||||
func InitBo(app *fiber.App) {
|
||||
// static files
|
||||
app.Get("/*", static.New("", static.Config{
|
||||
FS: assets.FS(),
|
||||
// Browse: true,
|
||||
MaxAge: 60 * 60 * 24 * 30, // 30 days
|
||||
}))
|
||||
|
||||
app.Get("/*", static.New("", static.Config{
|
||||
FS: assets.FSDist(),
|
||||
// Browse: true,
|
||||
MaxAge: 60 * 60 * 24 * 30, // 30 days
|
||||
}))
|
||||
|
||||
app.Get("/*", func(c fiber.Ctx) error {
|
||||
return c.SendFile("./assets/public/dist/index.html")
|
||||
})
|
||||
}
|
||||
17
app/delivery/web/general/favicon.go
Normal file
17
app/delivery/web/general/favicon.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package general
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/timetracker/app/config"
|
||||
"git.ma-al.com/goc_marek/timetracker/assets"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
func Favicon(app *fiber.App, cfg *config.Config) {
|
||||
// Favicon check endpoint
|
||||
app.Get("/favicon.ico", func(c fiber.Ctx) error {
|
||||
return c.SendFile("img/favicon.ico", fiber.SendFile{
|
||||
FS: assets.FS(),
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
20
app/delivery/web/general/health.go
Normal file
20
app/delivery/web/general/health.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package general
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/timetracker/app/config"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
func InitHealth(app *fiber.App, cfg *config.Config) {
|
||||
// Health check endpoint
|
||||
app.Get("/health", func(c fiber.Ctx) error {
|
||||
// emailService.NewEmailService().SendVerificationEmail("goc_daniel@ma-al.com", "jakis_token", c.BaseURL(), "en")
|
||||
// emailService.NewEmailService().SendPasswordResetEmail("goc_daniel@ma-al.com", "jakis_token", c.BaseURL(), "en")
|
||||
// emailService.NewEmailService().SendNewUserAdminNotification("goc_daniel@ma-al.com", "admin", c.BaseURL())
|
||||
return c.JSON(fiber.Map{
|
||||
"status": "ok",
|
||||
"app": cfg.App.Name,
|
||||
"version": cfg.App.Version,
|
||||
})
|
||||
})
|
||||
}
|
||||
60
app/delivery/web/general/swagger.go
Normal file
60
app/delivery/web/general/swagger.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package general
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/timetracker/app/api"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/gofiber/fiber/v3/middleware/static"
|
||||
)
|
||||
|
||||
func InitSwagger(app *fiber.App) {
|
||||
// Swagger - serve OpenAPI JSON
|
||||
app.Get("/openapi.json", func(c fiber.Ctx) error {
|
||||
c.Set("Content-Type", "application/json")
|
||||
return c.SendString(api.ApenapiJson)
|
||||
})
|
||||
|
||||
// Swagger UI HTML
|
||||
app.Get("/swagger", func(c fiber.Ctx) error {
|
||||
return c.Redirect().Status(fiber.StatusFound).To("/swagger/index.html")
|
||||
})
|
||||
|
||||
app.Get("/swagger/index.html", func(c fiber.Ctx) error {
|
||||
c.Set("Content-Type", "text/html")
|
||||
return c.SendString(swaggerHTML)
|
||||
})
|
||||
|
||||
// Serve Swagger assets
|
||||
app.Get("/swagger/assets", static.New("app/api/swagger/assets"))
|
||||
}
|
||||
|
||||
// Embedded Swagger UI HTML (minimal version)
|
||||
var swaggerHTML = `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>API Documentation</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-bundle.js" charset="UTF-8"></script>
|
||||
<script src="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-standalone-preset.js" charset="UTF-8"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
window.ui = SwaggerUIBundle({
|
||||
url: "/openapi.json",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
Reference in New Issue
Block a user