-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (35 loc) · 841 Bytes
/
main.go
File metadata and controls
40 lines (35 loc) · 841 Bytes
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
package main
import (
"log"
"os"
"strconv"
"github.com/Hyperloop-UPV/cloud-logs/pkg/api"
"github.com/Hyperloop-UPV/cloud-logs/pkg/store"
"github.com/joho/godotenv"
)
func main() {
db, err := store.InitDb()
if err != nil {
log.Fatal(err)
}
defer db.Close()
// Load configuration from environment variables
_ = godotenv.Load()
passwordHash := os.Getenv("AUTH_PASSWORD_HASH")
if passwordHash == "" {
log.Fatal("AUTH_PASSWORD_HASH is required")
}
jwtSecret := os.Getenv("JWT_SECRET")
if jwtSecret == "" {
log.Fatal("JWT_SECRET is required")
}
v := os.Getenv("JWT_TTL_SECONDS")
jwtTTLSeconds, err := strconv.ParseInt(v, 10, 64)
if err != nil {
log.Fatal("JWT_TTL_SECONDS is required")
}
r := api.NewRouter(db, passwordHash, jwtSecret, jwtTTLSeconds)
if err := r.Run(":8080"); err != nil {
log.Fatal(err)
}
}