From 90515f6aa4b74f98e638dca825d5298119ccfc60 Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Wed, 15 Jul 2020 18:20:08 -0500 Subject: [PATCH] feature: add web & migrate commands --- .gitignore | 3 + cmd/citadel/main.go | 56 +- conf/app.toml | 21 +- frontend/package.json | 1 + frontend/public/index.html | 6 +- frontend/src/Admin/index.tsx | 337 ++++----- frontend/src/App/TopNavbar.tsx | 40 +- frontend/src/App/index.tsx | 32 +- frontend/src/Auth/index.tsx | 20 +- frontend/src/index.tsx | 24 +- .../shared/components/Admin/Admin.stories.tsx | 15 +- .../src/shared/components/Admin/index.tsx | 697 +++++++++--------- go.mod | 7 +- go.sum | 48 ++ internal/commands/commands.go | 40 + internal/commands/migrate.go | 68 ++ internal/commands/web.go | 52 ++ internal/config/config.go | 58 ++ internal/db/querier.go | 1 + internal/db/query/user_accounts.sql | 3 + internal/db/user_accounts.sql.go | 27 + internal/graph/generated.go | 246 +++++++ internal/graph/graph.go | 4 +- internal/graph/models_gen.go | 10 + internal/graph/resolver.go | 2 + internal/graph/schema.graphqls | 11 + internal/graph/schema.resolvers.go | 13 +- internal/graph/schema/user.gql | 11 + internal/route/avatar.go | 14 + internal/route/route.go | 58 +- magefile.go | 15 + 31 files changed, 1300 insertions(+), 640 deletions(-) create mode 100644 internal/commands/commands.go create mode 100644 internal/commands/migrate.go create mode 100644 internal/commands/web.go create mode 100644 internal/config/config.go diff --git a/.gitignore b/.gitignore index 7c1722d..08280a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ node_modules uploads/* !uploads/.keep + +internal/frontend/frontend_generated.go +citadel diff --git a/cmd/citadel/main.go b/cmd/citadel/main.go index ff9db8b..a263872 100644 --- a/cmd/citadel/main.go +++ b/cmd/citadel/main.go @@ -1,62 +1,10 @@ package main import ( - "fmt" + "github.com/jordanknott/project-citadel/api/internal/commands" _ "github.com/lib/pq" - "io/ioutil" - "net/http" - "time" - - "github.com/BurntSushi/toml" - "github.com/jmoiron/sqlx" - "github.com/jordanknott/project-citadel/api/internal/route" - log "github.com/sirupsen/logrus" ) -type Database struct { - Host string - Name string - User string - Password string -} -type AppConfig struct { - Database Database -} - func main() { - dat, err := ioutil.ReadFile("conf/app.toml") - if err != nil { - panic(err) - } - - var appConfig AppConfig - _, err = toml.Decode(string(dat), &appConfig) - if err != nil { - panic(err) - } - - Formatter := new(log.TextFormatter) - Formatter.TimestampFormat = "02-01-2006 15:04:05" - Formatter.FullTimestamp = true - log.SetFormatter(Formatter) - log.SetLevel(log.InfoLevel) - connection := fmt.Sprintf("user=%s password=%s host=%s dbname=%s sslmode=disable", - appConfig.Database.User, - appConfig.Database.Password, - appConfig.Database.Host, - appConfig.Database.Name, - ) - db, err := sqlx.Connect("postgres", connection) - if err != nil { - log.Panic(err) - } - db.SetMaxOpenConns(25) - db.SetMaxIdleConns(25) - db.SetConnMaxLifetime(5 * time.Minute) - - defer db.Close() - fmt.Println("starting graphql server on http://localhost:3333") - fmt.Println("starting graphql playground on http://localhost:3333/__graphql") - r, _ := route.NewRouter(db) - http.ListenAndServe(":3333", r) + commands.Execute() } diff --git a/conf/app.toml b/conf/app.toml index ffee241..1741aad 100644 --- a/conf/app.toml +++ b/conf/app.toml @@ -1,5 +1,24 @@ +[general] +host = '0.0.0.0:3333' + +[email_notifications] +enabled = true +display_name = "No Reply" +from_address = "example.com" + +[storage] +storage_system = 'local_storage' +upload_dir_path = 'uploads' + [database] host = '0.0.0.0' -name = 'citadel' +name = 'citadel_test' user = 'postgres' password = 'test' + +[smtp] +username = 'admin@example.com' +password = 'example' +server = 'mail.example.com' +port = 465 +connection_security = 'STARTTLS' diff --git a/frontend/package.json b/frontend/package.json index 162a905..68e5aab 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -70,6 +70,7 @@ "styled-components": "^5.0.1", "typescript": "~3.7.2" }, + "proxy": "http://localhost:3333", "scripts": { "start": "react-scripts start", "build": "react-scripts build", diff --git a/frontend/public/index.html b/frontend/public/index.html index 4176852..86d27fb 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -2,19 +2,19 @@ - + - + - +