add v1 GET endpoints

This commit is contained in:
Stanislaw
2022-12-25 23:14:45 +01:00
parent 3f17d6e985
commit 92ece902f7
12 changed files with 258 additions and 33 deletions

21
main.go
View File

@@ -1,33 +1,22 @@
package main
import (
"os"
"gractwo-api/database"
"gractwo-api/router"
"github.com/joho/godotenv"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
func main() {
//line valid only on dev. ignore
godotenv.Load("local.env")
//database connection
db, err := gorm.Open(postgres.Open(os.Getenv("DATABASE_URL")), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
db.AutoMigrate(
&database.Quote{},
&database.QuoteLine{},
&database.Image{})
//init database
database.CreateConnection()
//Init api
router := router.InitRouter()
err = router.Run(":2021")
err := router.Run(":2021")
if err != nil {
panic("failed to connect database")
}