forked from manabie-com/togo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (40 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
package main
import (
"database/sql"
"fmt"
"log"
"net/http"
"togo/internal/services"
pg "togo/internal/storages/postgres"
sqllite "togo/internal/storages/sqlite"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
)
const (
pgHost = "localhost"
pgPort = 5432
pgUser = "postgres"
pgPassword = "changeme"
pgDbname = "pg_db"
)
type userAuthKey int8
func main() {
db, err := sql.Open("sqlite3", "./data.db")
if err != nil {
log.Fatal("error opening db", err)
}
psqlconn := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", pgHost, pgPort, pgUser, pgPassword, pgDbname)
dbPg, err := sql.Open("postgres", psqlconn)
if err != nil {
log.Fatalf("connect postgres: %s\n", err)
}
http.ListenAndServe(":5050", &services.ToDoService{
JWTKey: "wqGyEBBfPK9w3Lxw",
Store: &sqllite.LiteDB{
DB: db,
},
StorePg: &pg.ProstgresDB{
DB: dbPg,
},
})
}