feat: add dashboard as a submodule and register embed and routing in account api

This commit is contained in:
Derrick Hammer 2024-03-16 17:13:29 -04:00
parent f6b28b0ee0
commit cc1efd5d85
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 17 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "api/account/app"]
path = api/account/app
url = https://git.lumeweb.com/LumeWeb/portal-dashboard.git

View File

@ -3,7 +3,9 @@ package account
import (
"context"
"crypto/ed25519"
"embed"
_ "embed"
"io/fs"
"net/http"
"time"
@ -27,6 +29,9 @@ import (
//go:embed swagger.yaml
var swagSpec []byte
//go:embed app/build/client/build
var appFs embed.FS
var (
_ registry.API = (*AccountAPI)(nil)
_ router.RoutableAPI = (*AccountAPI)(nil)
@ -328,6 +333,13 @@ func (a AccountAPI) Routes() (*httprouter.Router, error) {
Purpose: account.JWTPurposeLogin,
})
appFiles, _ := fs.Sub(appFs, "app")
appServ := http.FileServer(http.FS(appFiles))
appHandler := func(c jape.Context) {
appServ.ServeHTTP(c.ResponseWriter, c.Request)
}
routes := map[string]jape.Handler{
"POST /api/auth/ping": middleware.ApplyMiddlewares(a.ping, pingAuthMw, middleware.ProxyMiddleware),
"POST /api/auth/login": middleware.ApplyMiddlewares(a.login, loginAuthMw2fa, middleware.ProxyMiddleware),
@ -340,6 +352,7 @@ func (a AccountAPI) Routes() (*httprouter.Router, error) {
"POST /api/auth/password-reset/request": middleware.ApplyMiddlewares(a.passwordResetRequest, middleware.ProxyMiddleware),
"POST /api/auth/password-reset/confirm": middleware.ApplyMiddlewares(a.passwordResetConfirm, middleware.ProxyMiddleware),
"GET /api/account": middleware.ApplyMiddlewares(a.accountInfo, authMw, middleware.ProxyMiddleware),
"GET /*path": middleware.ApplyMiddlewares(appHandler, middleware.ProxyMiddleware),
}
routes, err := swagger.Swagger(swagSpec, routes)

1
api/account/app Submodule

@ -0,0 +1 @@
Subproject commit 7d25a7a63e7b196ff903c7b9202d975aef1a98e1