76 lines
1.4 KiB
Go
Raw Normal View History

2016-11-09 11:32:19 +00:00
package main
import (
2016-11-09 13:11:49 +00:00
"github.com/aerogo/aero"
2017-10-28 01:53:12 +00:00
"github.com/aerogo/session-store-nano"
2017-06-08 21:26:58 +00:00
"github.com/animenotifier/arn"
2017-06-16 23:32:47 +00:00
"github.com/animenotifier/notify.moe/auth"
"github.com/animenotifier/notify.moe/components/css"
2017-06-15 21:03:55 +00:00
"github.com/animenotifier/notify.moe/layout"
2017-06-16 23:12:28 +00:00
"github.com/animenotifier/notify.moe/middleware"
2017-11-07 15:49:56 +00:00
"github.com/animenotifier/notify.moe/pages"
2016-11-09 11:32:19 +00:00
)
var app = aero.New()
func main() {
2017-06-22 14:08:34 +00:00
// Configure and start
configure(app).Run()
}
func configure(app *aero.Application) *aero.Application {
2016-12-02 15:23:05 +00:00
// HTTPS
2016-12-06 03:36:31 +00:00
app.Security.Load("security/fullchain.pem", "security/privkey.pem")
2016-12-02 15:23:05 +00:00
2017-06-11 09:13:59 +00:00
// CSS
app.SetStyle(css.Bundle())
2017-06-11 09:13:59 +00:00
2017-06-17 20:19:26 +00:00
// Sessions
2017-07-14 02:58:21 +00:00
app.Sessions.Duration = 3600 * 24 * 30 * 6
2017-10-31 11:12:21 +00:00
app.Sessions.Store = nanostore.New(arn.DB.Collection("Session"))
2017-06-08 21:26:58 +00:00
// Layout
2017-06-15 21:03:55 +00:00
app.Layout = layout.Render
2016-11-09 11:32:19 +00:00
2017-11-07 15:49:56 +00:00
// Pages
pages.Configure(app)
2017-07-14 21:50:34 +00:00
2017-10-02 00:09:05 +00:00
// Assets
configureAssets(app)
2017-10-01 22:31:44 +00:00
// Rewrite
2017-10-02 00:09:05 +00:00
app.Rewrite(rewrite)
2017-10-01 22:31:44 +00:00
2017-06-16 23:12:28 +00:00
// Middleware
2017-10-14 15:18:32 +00:00
app.Use(
middleware.Firewall(),
middleware.Log(),
middleware.Session(),
2017-10-15 18:19:45 +00:00
middleware.UserInfo(),
2017-10-14 15:18:32 +00:00
)
2017-06-12 19:11:20 +00:00
2017-06-16 23:12:28 +00:00
// API
2017-10-05 05:22:14 +00:00
arn.API.Install(app)
2017-06-12 19:11:20 +00:00
2017-06-16 23:12:28 +00:00
// Domain
2017-06-23 17:22:39 +00:00
if arn.IsDevelopment() {
2017-06-16 23:12:28 +00:00
app.Config.Domain = "beta.notify.moe"
}
2017-06-03 23:17:00 +00:00
2017-06-15 17:56:09 +00:00
// Authentication
2017-06-16 23:32:47 +00:00
auth.Install(app)
2017-06-15 17:56:09 +00:00
2017-11-02 03:08:45 +00:00
// Close the database node on shutdown
app.OnShutdown(arn.Node.Close)
2017-11-07 16:00:09 +00:00
// Prefetch all collections
2017-11-06 18:12:03 +00:00
arn.DB.Prefetch()
2017-11-02 03:08:45 +00:00
2017-10-01 22:31:44 +00:00
// Specify test routes
for route, examples := range routeTests {
app.Test(route, examples)
}
2017-06-22 14:08:34 +00:00
return app
2016-11-09 11:32:19 +00:00
}