-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (34 loc) · 1.2 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
package main
import (
"time"
"github.com/anirudhgray/balkan-assignment/config"
_ "github.com/anirudhgray/balkan-assignment/docs"
"github.com/anirudhgray/balkan-assignment/infra/database"
"github.com/anirudhgray/balkan-assignment/infra/logger"
"github.com/anirudhgray/balkan-assignment/migrations"
"github.com/anirudhgray/balkan-assignment/routers"
"github.com/spf13/viper"
)
// @title Secure Bookstore API
// @version 1.0
// @description Securely buy and review books.
// @contact.name anirudhgray
// @host http://bookstore.anrdhmshr.tech
// @BasePath /api/v1
func main() {
//set timezone
viper.SetDefault("SERVER_TIMEZONE", "Asia/Calcutta")
loc, _ := time.LoadLocation(viper.GetString("SERVER_TIMEZONE"))
time.Local = loc
if err := config.SetupConfig(); err != nil {
logger.Fatalf("config SetupConfig() error: %s", err)
}
masterDSN, replicaDSN := config.DbConfiguration()
if err := database.DbConnection(masterDSN, replicaDSN); err != nil {
logger.Fatalf("database DbConnection error: %s", err)
}
migrations.Migrate()
router := routers.SetupRoute()
logger.Fatalf("%v", router.Run(config.ServerConfig()))
}
// TODO You trusted all proxies, this is NOT safe. We recommend you to set a value.