2023-03-07 18:52:37 +07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"git.nochill.in/nochill/naice_pos/api"
|
|
|
|
db "git.nochill.in/nochill/naice_pos/db/sqlc"
|
2023-03-08 15:22:57 +07:00
|
|
|
"git.nochill.in/nochill/naice_pos/util"
|
2023-03-07 18:52:37 +07:00
|
|
|
_ "github.com/lib/pq"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-03-08 15:22:57 +07:00
|
|
|
config, err := util.LoadConfig(".")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal("cannot load config: ", err)
|
|
|
|
}
|
|
|
|
dbConn, err := sql.Open(config.DBDriver, config.DBSource)
|
2023-03-07 18:52:37 +07:00
|
|
|
if err != nil {
|
2023-03-14 17:39:40 +07:00
|
|
|
log.Fatal("cannot connect to db: ", err)
|
2023-03-07 18:52:37 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
store := db.NewStore(dbConn)
|
2023-03-14 17:39:40 +07:00
|
|
|
server, err := api.NewServer(config, store)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal("cannot make server: ", err)
|
|
|
|
}
|
2023-03-07 18:52:37 +07:00
|
|
|
|
2023-03-08 15:22:57 +07:00
|
|
|
err = server.Start(config.ServerAddress)
|
2023-03-07 18:52:37 +07:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal("cannot start server: ", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|