Initial skeleton: React/TS frontend + Go backend structure
This commit is contained in:
35
server/cmd/server/main.go
Normal file
35
server/cmd/server/main.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"krates/server/internal/api"
|
||||
"krates/server/internal/crdt"
|
||||
"krates/server/internal/ws"
|
||||
)
|
||||
|
||||
func main() {
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8080"
|
||||
}
|
||||
|
||||
crdtProvider := crdt.NewProvider()
|
||||
|
||||
wsManager := ws.NewManager(crdtProvider)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/ws/shell", wsManager.WithWebSocket(ws.ShellHandler))
|
||||
mux.Handle("/ws/logs", wsManager.WithWebSocket(ws.LogsHandler))
|
||||
mux.Handle("/ws/watch", wsManager.WithWebSocket(ws.WatchHandler))
|
||||
mux.Handle("/ws/sync", wsManager.WithWebSocket(ws.SyncHandler))
|
||||
|
||||
apiRoutes := api.SetupRoutes(wsManager)
|
||||
mux.Handle("/api/", http.StripPrefix("/api", apiRoutes))
|
||||
|
||||
http.ListenAndServe(":"+port, mux)
|
||||
log.Printf("Server started on port %s", port)
|
||||
}
|
||||
10
server/go.mod
Normal file
10
server/go.mod
Normal file
@@ -0,0 +1,10 @@
|
||||
module krates/server
|
||||
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/yjs/y-websocket v1.2.10
|
||||
k8s.io/client-go v0.29.0
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
)
|
||||
Reference in New Issue
Block a user