add docker files & nginx config
This commit is contained in:
11
api/main.go
11
api/main.go
@@ -69,9 +69,7 @@ func sendApiError(w http.ResponseWriter, msg string, err error, status int) {
|
||||
var jwtSecretKey []byte
|
||||
|
||||
func init() {
|
||||
if err := godotenv.Load(); err != nil {
|
||||
panic("couldn't parse env")
|
||||
}
|
||||
godotenv.Load()
|
||||
|
||||
s := os.Getenv("JWT_SECRET")
|
||||
if s == "" {
|
||||
@@ -143,7 +141,12 @@ func handler(mux *http.ServeMux) http.HandlerFunc {
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
db, err := sqlx.Connect("sqlite3", "./sqlite.db")
|
||||
dbPath := os.Getenv("DB_PATH")
|
||||
if dbPath == "" {
|
||||
panic("no DB_PATH env")
|
||||
}
|
||||
|
||||
db, err := sqlx.Connect("sqlite3", dbPath)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to connect to db: %v\n", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user