Upgraded to latest aero version
This commit is contained in:
24
main.go
24
main.go
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
nanostore "github.com/aerogo/session-store-nano"
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/assets"
|
||||
"github.com/animenotifier/notify.moe/auth"
|
||||
@ -44,9 +45,10 @@ func configure(app *aero.Application) *aero.Application {
|
||||
|
||||
// Middleware
|
||||
app.Use(
|
||||
middleware.Log(),
|
||||
middleware.Session(),
|
||||
middleware.UserInfo(),
|
||||
middleware.OpenGraph,
|
||||
middleware.Log,
|
||||
middleware.Session,
|
||||
middleware.UserInfo,
|
||||
)
|
||||
|
||||
// API
|
||||
@ -54,9 +56,8 @@ func configure(app *aero.Application) *aero.Application {
|
||||
|
||||
// Development server configuration
|
||||
if arn.IsDevelopment() {
|
||||
app.Config.Domain = "beta.notify.moe"
|
||||
app.Config.Title += " - Beta"
|
||||
assets.Manifest.Name = app.Config.Title
|
||||
assets.Domain = "beta.notify.moe"
|
||||
assets.Manifest.Name += " - Beta"
|
||||
}
|
||||
|
||||
// Authentication
|
||||
@ -68,6 +69,11 @@ func configure(app *aero.Application) *aero.Application {
|
||||
// Close the database node on shutdown
|
||||
app.OnEnd(arn.Node.Close)
|
||||
|
||||
// Show errors in the console
|
||||
app.OnError(func(ctx aero.Context, err error) {
|
||||
color.Red(err.Error())
|
||||
})
|
||||
|
||||
// Check that this is the server
|
||||
if !arn.Node.IsServer() && !arn.IsTest() {
|
||||
panic("Another program is currently running as the database server")
|
||||
@ -77,13 +83,13 @@ func configure(app *aero.Application) *aero.Application {
|
||||
arn.DB.Prefetch()
|
||||
|
||||
// Do not use HTTP/2 push on service worker requests
|
||||
app.AddPushCondition(func(ctx *aero.Context) bool {
|
||||
return !strings.Contains(ctx.Request().Header().Get("Referer"), "/service-worker")
|
||||
app.AddPushCondition(func(ctx aero.Context) bool {
|
||||
return !strings.Contains(ctx.Request().Header("Referer"), "/service-worker")
|
||||
})
|
||||
|
||||
// Specify test routes
|
||||
for route, examples := range routetests.All() {
|
||||
app.Test(route, examples)
|
||||
app.Test(route, examples...)
|
||||
}
|
||||
|
||||
return app
|
||||
|
Reference in New Issue
Block a user