-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
57 lines (47 loc) · 1.64 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
55
56
57
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/ilyakaznacheev/cleanenv"
"github.com/mahdidl/golang_boilerplate/Common/Config"
token "github.com/mahdidl/golang_boilerplate/Common/Token"
"github.com/mahdidl/golang_boilerplate/Router"
)
// @title Golang Monolithic Boilerplate
// @version 1.0
// @description Golang Monolithic Boilerplate
// @contact.name Supnex
// @contact.url https://supnex.com/
// @contact.email team@supnex.com
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
// @host localhost:3000
// @BasePath /api/v1
func main() {
// Open Config file
config := Config.EnvironmentConfig{}
if parseError := cleanenv.ReadConfig(".test.env", &config); parseError != nil {
fmt.Errorf("parsing config: %w", parseError)
}
// Config logger
Config.NewLogger("Polaris Storage Service", config.DB.Host)
// connect to mongodb
Config.MongoDatabaseOpen(Config.MongoDB{Url: config.MongoDB.Url, DBname: config.MongoDB.DBname})
// disconnect client mongodb
defer Config.CloseClientDB()
// Create new token maker
token.NewPasetoMaker(config.Token.TokenSymmetricKey)
// Create new token maker
Config.RedisConnection(config)
// Run server
app := gin.Default()
app.MaxMultipartMemory = 8 << 20
app.Static("/assets/", "./public")
Router.Routes(app)
errorChannel := make(chan error)
func() {
Config.Logger.Infow("Project Running On PORT", config.Api.ApiHost)
errorChannel <- app.Run(config.Api.ApiHost)
}()
}