Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package main |
||
2 | |||
3 | import ( |
||
4 | "log" |
||
5 | "memnixrest/app/database" |
||
6 | "memnixrest/app/models" |
||
7 | "memnixrest/pkg/routes" |
||
8 | |||
9 | _ "github.com/arsmn/fiber-swagger/v2" |
||
10 | ) |
||
11 | |||
12 | // @title Memnix |
||
13 | // @version 1.0 |
||
14 | // @description This is a sample swagger for Fiber |
||
15 | // @termsOfService http://swagger.io/terms/ |
||
16 | // @contact.name API Support |
||
17 | // @contact.email [email protected] |
||
18 | // @license.name Apache 2.0 |
||
19 | // @license.url http://www.apache.org/licenses/LICENSE-2.0.html |
||
20 | // @host localhost:1813 |
||
21 | // @BasePath /api |
||
22 | func main() { |
||
23 | // Try to connect to the database |
||
24 | if err := database.Connect(); err != nil { |
||
25 | log.Panic("Can't connect database:", err.Error()) |
||
26 | } |
||
27 | |||
28 | var migrates []interface{} |
||
29 | _ = append(migrates, models.Access{}, models.Card{}, models.Deck{}, |
||
30 | models.User{}, models.Mem{}, models.Answer{}, models.MemDate{}, models.DeckLogs{}, |
||
31 | models.CardLogs{}, models.UserLogs{}, models.Logs{}, models.Rating{}) |
||
32 | |||
33 | // AutoMigrate models |
||
34 | for i := 0; i < len(migrates); i++ { |
||
35 | err := database.DBConn.AutoMigrate(&migrates[i]) |
||
36 | if err != nil { |
||
37 | return |
||
38 | } |
||
39 | } |
||
40 | |||
41 | // Create the app |
||
42 | app := routes.New() |
||
43 | // Listen to port 1812 |
||
44 | log.Fatal(app.Listen(":1813")) |
||
45 | } |
||
46 |