-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (42 loc) · 1.13 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"log"
"github.com/joho/godotenv"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"github.com/ladydascalie/quakes/app"
"github.com/ladydascalie/quakes/app/handlers"
"github.com/ladydascalie/quakes/config"
"github.com/ladydascalie/quakes/db/mongo"
"github.com/ladydascalie/quakes/templates"
"github.com/ladydascalie/quakes/workers"
)
func main() {
log.SetFlags(log.Lshortfile | log.LstdFlags | log.LUTC)
if err := godotenv.Load(".env"); err != nil {
log.Fatalln(err)
}
// setup the app config
config.Setup()
// create a new instance of Echo and configure it
e := echo.New()
e.HideBanner = true
e.Renderer = templates.New()
// configure middlewares
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Use(middleware.Secure())
e.Use(middleware.Gzip())
// configure static assets folder
e.Static("static", "static")
// Create a new database connection
db := mongo.Begin()
go workers.Run(db)
// go bot.Begin()
// Create the server and start it
server := app.NewServer(db, e)
// register the routes
handlers.RegisterRoutes(server)
// start the server
server.Start()
}