Scaffold admin app

This commit is contained in:
David Stotijn 2019-11-30 12:43:55 +01:00
parent e4f5f2278a
commit 94363fe196
13 changed files with 5559 additions and 3 deletions

5
admin/.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
/node_modules
/.next
/build
*.log*

16
admin/package.json Normal file
View file

@ -0,0 +1,16 @@
{
"name": "gurp-admin",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"export": "next build && next export -o build"
},
"dependencies": {
"next": "9.1.4",
"react": "16.12.0",
"react-dom": "16.12.0"
}
}

3
admin/pages/index.js Normal file
View file

@ -0,0 +1,3 @@
const Page = () => <div>Gurp</div>
export default Page

BIN
admin/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

5499
admin/yarn.lock Normal file

File diff suppressed because it is too large Load diff

View file

@ -6,13 +6,18 @@ import (
"flag" "flag"
"log" "log"
"net/http" "net/http"
"net/http/httputil"
"net/url"
"github.com/dstotijn/gurp/proxy" "github.com/dstotijn/gurp/pkg/proxy"
"github.com/gorilla/mux"
) )
var ( var (
caCertFile = flag.String("cert", "", "CA certificate file path") caCertFile = flag.String("cert", "", "CA certificate file path")
caKeyFile = flag.String("key", "", "CA private key file path") caKeyFile = flag.String("key", "", "CA private key file path")
dev = flag.Bool("dev", false, "Run in development mode")
adminPath = flag.String("adminPath", "", "File path to admin build")
) )
func main() { func main() {
@ -47,9 +52,27 @@ func main() {
} }
}) })
router := mux.NewRouter().SkipClean(true)
adminRouter := router.Host("gurp.proxy")
if *dev {
adminURL, err := url.Parse("http://localhost:3000")
if err != nil {
log.Fatalf("[FATAL] Invalid admin URL: %v", err)
}
adminRouter.Handler(httputil.NewSingleHostReverseProxy(adminURL))
} else {
if *adminPath == "" {
log.Fatal("[FATAL] `adminPath` must be set")
}
adminRouter.Handler(http.FileServer(http.Dir(*adminPath)))
}
router.PathPrefix("").Handler(p)
s := &http.Server{ s := &http.Server{
Addr: ":8080", Addr: ":8080",
Handler: p, Handler: router,
TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){}, // Disable HTTP/2 TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){}, // Disable HTTP/2
} }

2
go.mod
View file

@ -1,3 +1,5 @@
module github.com/dstotijn/gurp module github.com/dstotijn/gurp
go 1.13 go 1.13
require github.com/gorilla/mux v1.7.3

2
go.sum
View file

@ -0,0 +1,2 @@
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=

View file

@ -1,6 +1,12 @@
@cert = $HOME/.ssh/gurp_cert.pem @cert = $HOME/.ssh/gurp_cert.pem
@key = $HOME/.ssh/gurp_key.pem @key = $HOME/.ssh/gurp_key.pem
@dev = false
@adminPath = $PWD/admin/build
**/*.go { **/*.go {
daemon +sigterm: go run . -cert @cert -key @key daemon +sigterm: go run ./cmd \
-cert=@cert \
-key=@key \
-dev=@dev \
-adminPath=@adminPath
} }