Mave frontend data to base api root
Because many times we don't have a session
This commit is contained in:
parent
544ac78a3b
commit
839abcbd28
4 changed files with 20 additions and 11 deletions
18
api/api.go
18
api/api.go
|
|
@ -1,6 +1,7 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
|
@ -8,9 +9,12 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/config"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/resource"
|
||||
//"github.com/gorilla/mux"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
|
@ -267,3 +271,17 @@ func parseTime(x string) (*time.Time, error) {
|
|||
created := time.UnixMilli(created_epoch)
|
||||
return &created, nil
|
||||
}
|
||||
|
||||
type about struct {
|
||||
Environment string `json:"environment"`
|
||||
SentryDSN string `json:"sentry_dsn"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
func getRoot(ctx context.Context, r *http.Request, q resource.QueryParams) (*about, *nhttp.ErrorWithStatus) {
|
||||
return &about{
|
||||
Environment: config.Environment,
|
||||
SentryDSN: config.SentryDSNFrontend,
|
||||
Version: version,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ func AddRoutes(r *mux.Router) {
|
|||
router := resource.NewRouter(r)
|
||||
//r.Use(render.SetContentType(render.ContentTypeJSON))
|
||||
// Unauthenticated endpoints
|
||||
r.HandleFunc("/", handlerJSON(getRoot))
|
||||
r.HandleFunc("/signin", handlerJSONPost(postSignin))
|
||||
r.Handle("/signout", authenticatedHandlerBasic(postSignout))
|
||||
r.HandleFunc("/signup", handlerJSONPost(postSignup))
|
||||
|
|
|
|||
1
main.go
1
main.go
|
|
@ -19,6 +19,7 @@ import (
|
|||
"github.com/Gleipnir-Technology/nidus-sync/llm"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/middleware"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/resource"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/rmo"
|
||||
nidussync "github.com/Gleipnir-Technology/nidus-sync/sync"
|
||||
"github.com/getsentry/sentry-go"
|
||||
|
|
|
|||
|
|
@ -30,17 +30,11 @@ type organization struct {
|
|||
|
||||
type session struct {
|
||||
Impersonating *string `json:"impersonating"`
|
||||
Frontend sessionFrontend `json:"frontend"`
|
||||
NotificationCounts sessionNotificationCounts `json:"notification_counts"`
|
||||
Organization organization `json:"organization"`
|
||||
Self user `json:"self"`
|
||||
URLs sessionURL `json:"urls"`
|
||||
}
|
||||
type sessionFrontend struct {
|
||||
Environment string `json:"environment"`
|
||||
SentryDSN string `json:"sentry_dsn"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
type sessionNotificationCounts struct {
|
||||
Communications uint `json:"communication"`
|
||||
Home uint `json:"home"`
|
||||
|
|
@ -89,11 +83,6 @@ func (res *sessionR) Get(ctx context.Context, r *http.Request, user platform.Use
|
|||
}
|
||||
return &session{
|
||||
Impersonating: impersonating,
|
||||
Frontend: sessionFrontend{
|
||||
Environment: config.Environment,
|
||||
SentryDSN: config.SentryDSNFrontend,
|
||||
Version: version,
|
||||
},
|
||||
NotificationCounts: sessionNotificationCounts{
|
||||
Communications: counts.Communications,
|
||||
Home: counts.Home,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue