File tree Expand file tree Collapse file tree 7 files changed +68
-30
lines changed
Expand file tree Collapse file tree 7 files changed +68
-30
lines changed Original file line number Diff line number Diff line change 1919 uses : actions/setup-node@v4
2020 with :
2121 node-version : 18
22+ - name : Set up buf
23+ uses : bufbuild/buf-setup-action@v1.28.1
24+ with :
25+ github_token : ${{ secrets.GITHUB_TOKEN }}
2226 - name : Build Backend
23- run : go build -v ./...
27+ run : |
28+ go generate ./...
29+ go build -v ./...
2430 - name : Test Backend
2531 run : go test -v -coverprofile=coverage.cov -coverpkg ./... -covermode=atomic ./...
2632 - name : Upload coverage reports to Codecov
Original file line number Diff line number Diff line change 1+ FROM golang as builder
2+
3+ WORKDIR /build
4+
5+ RUN apt update && apt install -y nodejs npm
6+
7+ ADD go.mod .
8+ ADD go.sum .
9+
10+ RUN go install github.com/bufbuild/buf/cmd/buf@latest
11+
12+ ADD . .
13+
14+ RUN go generate ./...
15+ RUN go build ./cmd/moneyd
16+
17+ FROM debian:stable-slim
18+
19+ COPY --from=builder /build/moneyd /
20+
21+ ENTRYPOINT [ "./moneyd" ]
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import (
3434 "github.com/oxisto/money-gopher/persistence"
3535 "github.com/oxisto/money-gopher/service/portfolio"
3636 "github.com/oxisto/money-gopher/service/securities"
37+ "github.com/oxisto/money-gopher/ui"
3738)
3839
3940var cmd moneydCmd
@@ -85,6 +86,7 @@ func (cmd *moneydCmd) Run() error {
8586 },
8687 )))
8788 mux .Handle (portfoliov1connect .NewSecuritiesServiceHandler (securities .NewService (db )))
89+ mux .Handle ("/" , ui .SvelteKitHandler ("/" ))
8890
8991 err = http .ListenAndServe (
9092 "localhost:8080" ,
Original file line number Diff line number Diff line change 1+ package ui
2+
3+ import (
4+ "embed"
5+ "errors"
6+ "io/fs"
7+ "log"
8+ "net/http"
9+ "os"
10+ "strings"
11+ )
12+
13+ //go:generate npm i
14+ //go:generate npm run build
15+ //go:embed all:build
16+ var files embed.FS
17+
18+ func SvelteKitHandler (path string ) http.Handler {
19+ fsys , err := fs .Sub (files , "build" )
20+ if err != nil {
21+ log .Fatal (err )
22+ }
23+ filesystem := http .FS (fsys )
24+
25+ return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
26+ path := strings .TrimPrefix (r .URL .Path , path )
27+ _ , err := filesystem .Open (path )
28+ if errors .Is (err , os .ErrNotExist ) {
29+ path = "index.html"
30+ }
31+ r .URL .Path = path
32+ http .FileServer (filesystem ).ServeHTTP (w , r )
33+ })
34+ }
Original file line number Diff line number Diff line change 1616 "@connectrpc/connect-web" : " ^1.1.3" ,
1717 "@steeze-ui/heroicons" : " ^2.2.3" ,
1818 "@steeze-ui/svelte-icon" : " ^1.5.0" ,
19- "@sveltejs/adapter-auto" : " ^2.0.0" ,
2019 "@sveltejs/adapter-static" : " ^2.0.3" ,
2120 "@sveltejs/kit" : " ^1.20.4" ,
2221 "@tailwindcss/forms" : " ^0.5.4" ,
Original file line number Diff line number Diff line change 1- import adapter from '@sveltejs/adapter-auto ' ;
1+ import adapter from '@sveltejs/adapter-static ' ;
22import { vitePreprocess } from '@sveltejs/kit/vite' ;
33
44/** @type {import('@sveltejs/kit').Config } */
@@ -8,10 +8,9 @@ const config = {
88 preprocess : vitePreprocess ( ) ,
99
1010 kit : {
11- // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
12- // If your environment is not supported or you settled on a specific environment, switch out the adapter.
13- // See https://kit.svelte.dev/docs/adapters for more information about adapters.
14- adapter : adapter ( )
11+ adapter : adapter ( {
12+ fallback : 'index.html'
13+ } )
1514 }
1615} ;
1716
You can’t perform that action at this time.
0 commit comments