/
main.go
51 lines (38 loc) · 922 Bytes
/
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
package main
import (
"fmt"
"log"
"net"
"github.com/14jasimmtp/auth-svc/pkg/config"
"github.com/14jasimmtp/auth-svc/pkg/db"
"github.com/14jasimmtp/auth-svc/pkg/helper"
"github.com/14jasimmtp/auth-svc/pkg/pb"
"github.com/14jasimmtp/auth-svc/pkg/services"
"google.golang.org/grpc"
)
func main() {
c, err := config.NewConfig()
if err != nil {
log.Fatalln("Failed at config", err)
}
h := db.Connection(c.DB_URL)
jwt := helper.JwtWrapper{
SecretKey: c.JWTSecretKey,
Issuer: "go-grpc-auth-svc",
ExpirationHours: 24 * 365,
}
lis, err := net.Listen("tcp", c.Port)
if err != nil {
log.Fatalln("Failed to listing:", err)
}
fmt.Println("Auth Svc on", c.Port)
s := services.Server{
H: h,
Jwt: jwt,
}
grpcServer := grpc.NewServer()
pb.RegisterAuthServiceServer(grpcServer, &s)
if err := grpcServer.Serve(lis); err != nil {
log.Fatalln("Failed to serve:", err)
}
}