Skip to content

Commit

Permalink
API: Use smaller image, don't log stats and health checks
Browse files Browse the repository at this point in the history
- Fix favicon crashing dev envs
  • Loading branch information
Fesaa committed Oct 6, 2024
1 parent 3cbc9de commit adeef20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mangadex/types_manga_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (a *MangaSearchData) CoverURL() string {

if fileName, ok := cover.Attributes["fileName"].(string); ok {
// Link to the proxy endpoint of the api
return fmt.Sprintf("proxy/mangadex/covers/%s/%s", a.Id, fileName)
return fmt.Sprintf("proxy/mangadex/covers/%s/%s.256.jpg", a.Id, fileName)
}

log.Debug("Cover art relationship found, but no url",
Expand Down
21 changes: 13 additions & 8 deletions startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ import (
func SetupApp(baseUrl string) *fiber.App {
app := fiber.New()

if os.Getenv("DEV") == "" {
app.Use(favicon.New(favicon.Config{File: "public/favicon.ico"}))
}

app.
Use(favicon.New(favicon.Config{File: "public/favicon.ico"})).
Use(requestid.New()).
Use(logger.New(logger.Config{
TimeFormat: "2006/01/02 15:04:05",
Format: "${time} | ${locals:requestid} | ${status} | ${latency} | ${reqHeader:X-Real-IP} ${ip} | ${method} | ${path} | ${error}\n",
Next: func(c *fiber.Ctx) bool {
return !config.I().Logging.LogHttp
},
})).
Use(recover2.New(recover2.Config{
EnableStackTrace: config.I().Logging.Level <= slog.LevelDebug,
})).
Expand All @@ -45,6 +41,15 @@ func SetupApp(baseUrl string) *fiber.App {
return c.SendStatus(fiber.StatusOK)
})

app.
Use(logger.New(logger.Config{
TimeFormat: "2006/01/02 15:04:05",
Format: "${time} | ${locals:requestid} | ${status} | ${latency} | ${reqHeader:X-Real-IP} ${ip} | ${method} | ${path} | ${error}\n",
Next: func(c *fiber.Ctx) bool {
return c.Route().Path == "/api/stats" || !config.I().Logging.LogHttp
},
}))

router := app.Group(baseUrl)
api.Setup(router)

Expand Down

0 comments on commit adeef20

Please sign in to comment.