-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
94 lines (87 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import (
"fmt"
"github.com/joho/godotenv"
"golang-server/api"
"golang-server/db"
"log"
"net/http"
"os"
)
func main() {
// If env is not prod, use read env from local.env
if os.Getenv("ENV") != "PROD" {
log.Printf("[env] Reading from local.env")
err := godotenv.Load("local.env")
if err != nil {
log.Fatalf("Some err occured. Err: %s", err)
}
}
// Init API and DB
dbInst, err := db.NewDB()
if err != nil {
panic(err)
}
port := os.Getenv("PORT")
log.Printf("[main] We're up and running!")
//// USERS TEST
//if !db.MockGetUser(dbInst) {
// panic(err)
//}
//if !db.MockCreateUser(dbInst) {
// panic(err)
//}
//if !db.MockUpdateUser(dbInst) {
// panic(err)
//}
//if !db.MockUpsertUserExists(dbInst) {
// panic(err)
//}
//if !db.MockUpsertUserDoesNotExists(dbInst) {
// panic(err)
//}
//
//// MERCHANTS TEST
//if !db.MockGetMerchant(dbInst) {
// panic(err)
//}
//if !db.MockCreateMerchant(dbInst) {
// panic(err)
//}
//
//// NFTS TEST
//if !db.MockGetNft(dbInst) {
// panic(err)
//}
//if !db.MockCreateNft(dbInst) {
// panic(err)
//}
//
//// CAMPAIGNS TEST
//if !db.MockGetCampaign(dbInst) {
// panic(err)
//}
//if !db.MockCreateCampaign(dbInst) {
// panic(err)
//}
//
//// REWARSDS TEST
//if !db.MockGetReward(dbInst) {
// panic(err)
//}
//if !db.MockCreateReward(dbInst) {
// panic(err)
//}
//if !db.MockGetRewardsByMerchantId(dbInst) {
// panic(err)
//}
//if !db.MockUpdateReward(dbInst) {
// panic(err)
//}
//Start server
router := api.NewAPI(dbInst)
err = http.ListenAndServe(fmt.Sprintf(":%s", port), router)
if err != nil {
log.Printf("err from router: %v\n", err)
}
}