Start on mysql

This commit is contained in:
viktorstrate
2020-01-30 14:49:39 +01:00
parent 9d95b7bead
commit 494d880771
5 changed files with 63 additions and 2 deletions

View File

@@ -5,18 +5,29 @@ import (
"net/http"
"os"
"github.com/joho/godotenv"
"github.com/viktorstrate/photoview/api/database"
"github.com/99designs/gqlgen/handler"
photoview_graphql "github.com/viktorstrate/photoview/api/graphql"
)
const defaultPort = "8080"
const defaultPort = "4001"
func main() {
port := os.Getenv("PORT")
if err := godotenv.Load(); err != nil {
log.Println("No .env file found")
}
port := os.Getenv("API_PORT")
if port == "" {
port = defaultPort
}
database.SetupDatabase()
http.Handle("/", handler.Playground("GraphQL playground", "/query"))
http.Handle("/query", handler.GraphQL(photoview_graphql.NewExecutableSchema(photoview_graphql.Config{Resolvers: &photoview_graphql.Resolver{}})))