mirror of
https://github.com/cf-sonr/motr.git
synced 2026-01-12 02:59:13 +00:00
refactor: improve task management and logging
This commit is contained in:
@@ -6,9 +6,8 @@ vars:
|
||||
GIT_ROOT:
|
||||
sh: git rev-parse --show-toplevel
|
||||
|
||||
|
||||
tasks:
|
||||
db-init:
|
||||
initialize:
|
||||
cmds:
|
||||
- task: accounts:up
|
||||
- task: credentials:up
|
||||
@@ -42,6 +41,23 @@ tasks:
|
||||
- task: fear_greed_index
|
||||
- task: crypto_listings
|
||||
|
||||
reset:
|
||||
cmds:
|
||||
- task: accounts:down
|
||||
- task: credentials:down
|
||||
- task: profiles:down
|
||||
- task: vaults:down
|
||||
- task: assets:down
|
||||
- task: prices:down
|
||||
- task: price_conversions:down
|
||||
- task: blockchains:down
|
||||
- task: services:down
|
||||
- task: activities:down
|
||||
- task: health:down
|
||||
- task: global_market:down
|
||||
- task: fear_greed_index:down
|
||||
- task: crypto_listings:down
|
||||
|
||||
# ---------------
|
||||
# Main Tasks
|
||||
# ---------------
|
||||
@@ -7,41 +7,25 @@ vars:
|
||||
sh: git rev-parse --show-toplevel
|
||||
|
||||
tasks:
|
||||
worker:
|
||||
dir: "{{.GIT_ROOT}}/cmd/worker"
|
||||
env:
|
||||
GOOS: js
|
||||
GOARCH: wasm
|
||||
cmds:
|
||||
- go build -ldflags="-s -w" -o ./build/app.wasm .
|
||||
|
||||
# ---------------
|
||||
# Main Tasks
|
||||
# ---------------
|
||||
|
||||
# ---------------
|
||||
# Internal Helpers
|
||||
# ---------------
|
||||
|
||||
logi-*:
|
||||
info-*:
|
||||
internal: true
|
||||
vars:
|
||||
TEXT: "{{index .MATCH 0}}"
|
||||
cmd: gum log -l info {{.TEXT}}
|
||||
|
||||
logw-*:
|
||||
warn-*:
|
||||
internal: true
|
||||
vars:
|
||||
TEXT: "{{index .MATCH 0}}"
|
||||
cmd: gum log -l warn {{.TEXT}}
|
||||
|
||||
loge-*:
|
||||
error-*:
|
||||
internal: true
|
||||
vars:
|
||||
TEXT: "{{index .MATCH 0}}"
|
||||
cmd: gum log -l error {{.TEXT}}
|
||||
|
||||
logd-*:
|
||||
debug-*:
|
||||
internal: true
|
||||
vars:
|
||||
TEXT: "{{index .MATCH 0}}"
|
||||
@@ -8,9 +8,16 @@ tasks:
|
||||
worker:
|
||||
dir: "{{.GIT_ROOT}}/cmd/worker"
|
||||
cmd: make build
|
||||
sources:
|
||||
- "main.go"
|
||||
generates:
|
||||
- build/app.wasm
|
||||
|
||||
radar:
|
||||
dir: "{{.GIT_ROOT}}/cmd/radar"
|
||||
cmd: make build
|
||||
|
||||
sources:
|
||||
- "main.go"
|
||||
generates:
|
||||
- build/app.wasm
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# yaml-language-server: $schema=https://taskfile.dev/schema.json
|
||||
version: "3"
|
||||
|
||||
includes:
|
||||
build: ./.github/taskfiles/taskfile.build.yml
|
||||
migrate: ./.github/taskfiles/taskfile.migrate.yml
|
||||
publish: ./.github/taskfiles/taskfile.publish.yml
|
||||
|
||||
23
cmd/radar/Taskfile.yml
Normal file
23
cmd/radar/Taskfile.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
# yaml-language-server: $schema=https://taskfile.dev/schema.json
|
||||
version: "3"
|
||||
vars:
|
||||
GIT_ROOT:
|
||||
sh: git rev-parse --show-toplevel
|
||||
|
||||
tasks:
|
||||
worker:
|
||||
dir: "{{.GIT_ROOT}}/cmd/worker"
|
||||
cmd: make build
|
||||
sources:
|
||||
- "main.go"
|
||||
generates:
|
||||
- build/app.wasm
|
||||
|
||||
radar:
|
||||
dir: "{{.GIT_ROOT}}/cmd/radar"
|
||||
cmd: make build
|
||||
sources:
|
||||
- "main.go"
|
||||
generates:
|
||||
- build/app.wasm
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
templ:
|
||||
go run github.com/a-h/templ/cmd/templ generate
|
||||
|
||||
generate:
|
||||
assets:
|
||||
go run github.com/syumai/workers/cmd/workers-assets-gen -mode=go
|
||||
|
||||
build: generate
|
||||
|
||||
23
cmd/worker/Taskfile.yml
Normal file
23
cmd/worker/Taskfile.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
# yaml-language-server: $schema=https://taskfile.dev/schema.json
|
||||
version: "3"
|
||||
vars:
|
||||
GIT_ROOT:
|
||||
sh: git rev-parse --show-toplevel
|
||||
|
||||
tasks:
|
||||
worker:
|
||||
dir: "{{.GIT_ROOT}}/cmd/worker"
|
||||
cmd: make build
|
||||
sources:
|
||||
- "main.go"
|
||||
generates:
|
||||
- build/app.wasm
|
||||
|
||||
radar:
|
||||
dir: "{{.GIT_ROOT}}/cmd/radar"
|
||||
cmd: make build
|
||||
sources:
|
||||
- "main.go"
|
||||
generates:
|
||||
- build/app.wasm
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package dash
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package charts
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@@ -44,7 +44,7 @@ func AreaChart(data []DateValue) templ.Component {
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(d.Date)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/charts/area_chart.templ`, Line: 14, Col: 61}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/dash/charts/area_chart.templ`, Line: 14, Col: 61}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -57,7 +57,7 @@ func AreaChart(data []DateValue) templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", d.Value))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/charts/area_chart.templ`, Line: 15, Col: 81}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/dash/charts/area_chart.templ`, Line: 15, Col: 81}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package charts
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@@ -45,7 +45,7 @@ func BarChart(data []KeyValue) templ.Component {
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(d.Key)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/charts/bar_chart.templ`, Line: 15, Col: 60}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/dash/charts/bar_chart.templ`, Line: 15, Col: 60}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -58,7 +58,7 @@ func BarChart(data []KeyValue) templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", d.Value))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/charts/bar_chart.templ`, Line: 16, Col: 81}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/dash/charts/bar_chart.templ`, Line: 16, Col: 81}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package charts
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package charts
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@@ -39,7 +39,7 @@ func LineChart(data []DateValue) templ.Component {
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(d.Date)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/charts/line_chart.templ`, Line: 9, Col: 61}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/dash/charts/line_chart.templ`, Line: 9, Col: 61}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -52,7 +52,7 @@ func LineChart(data []DateValue) templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", d.Value))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/charts/line_chart.templ`, Line: 10, Col: 81}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/dash/charts/line_chart.templ`, Line: 10, Col: 81}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package charts
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@@ -46,7 +46,7 @@ func PieChart(data []CategoryValue) templ.Component {
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(d.Category)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/charts/pie_chart.templ`, Line: 16, Col: 65}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/dash/charts/pie_chart.templ`, Line: 16, Col: 65}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -59,7 +59,7 @@ func PieChart(data []CategoryValue) templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", d.Value))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/charts/pie_chart.templ`, Line: 17, Col: 81}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/dash/charts/pie_chart.templ`, Line: 17, Col: 81}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package dash
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -2,7 +2,7 @@ package dash
|
||||
|
||||
import (
|
||||
"github.com/sonr-io/motr/internal/ui"
|
||||
"github.com/sonr-io/motr/middleware/session"
|
||||
"github.com/sonr-io/motr/pkg/metadata"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ func ConsoleView(d time.Time) templ.Component {
|
||||
templ consoleComponent(d time.Time) {
|
||||
@ui.HTML() {
|
||||
@ui.Head() {
|
||||
@session.DefaultMetaComponent()
|
||||
@metadata.DefaultMetaComponent()
|
||||
}
|
||||
<sl-tab-group>
|
||||
@ui.Nav() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package dash
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@@ -10,6 +10,7 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"github.com/sonr-io/motr/internal/ui"
|
||||
"github.com/sonr-io/motr/pkg/metadata"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -62,6 +63,10 @@ func consoleComponent(d time.Time) templ.Component {
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Err = metadata.DefaultMetaComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
templ_7745c5c3_Err = ui.Head().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package home
|
||||
|
||||
import "github.com/sonr-io/motr/internal/ui"
|
||||
import "github.com/sonr-io/motr/middleware/session"
|
||||
import "github.com/sonr-io/motr/pkg/metadata"
|
||||
|
||||
func HomeView() templ.Component {
|
||||
return homeComponent()
|
||||
@@ -10,7 +10,7 @@ func HomeView() templ.Component {
|
||||
templ homeComponent() {
|
||||
@ui.HTML() {
|
||||
@ui.Head() {
|
||||
@session.DefaultMetaComponent()
|
||||
@metadata.DefaultMetaComponent()
|
||||
}
|
||||
@ui.Nav() {
|
||||
@ui.NavLeft() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package home
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@@ -9,6 +9,7 @@ import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import "github.com/sonr-io/motr/internal/ui"
|
||||
import "github.com/sonr-io/motr/pkg/metadata"
|
||||
|
||||
func HomeView() templ.Component {
|
||||
return homeComponent()
|
||||
@@ -59,7 +60,7 @@ func homeComponent() templ.Component {
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Err = ui.DefaultMetaComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = metadata.DefaultMetaComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package ui
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package login
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package login
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package login
|
||||
|
||||
import "github.com/sonr-io/motr/internal/ui"
|
||||
import "github.com/sonr-io/motr/middleware/session"
|
||||
import "github.com/sonr-io/motr/pkg/metadata"
|
||||
|
||||
templ LoginView() {
|
||||
@ui.HTML() {
|
||||
@ui.Head() {
|
||||
@session.DefaultMetaComponent()
|
||||
@metadata.DefaultMetaComponent()
|
||||
}
|
||||
@ui.Nav() {
|
||||
@ui.NavLeft() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package login
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@@ -9,6 +9,7 @@ import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import "github.com/sonr-io/motr/internal/ui"
|
||||
import "github.com/sonr-io/motr/pkg/metadata"
|
||||
|
||||
func LoginView() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
@@ -55,7 +56,7 @@ func LoginView() templ.Component {
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Err = ui.DefaultMetaComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = metadata.DefaultMetaComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package ui
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package register
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package register
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package register
|
||||
|
||||
import "github.com/sonr-io/motr/internal/ui"
|
||||
import "github.com/sonr-io/motr/middleware/session"
|
||||
import "github.com/sonr-io/motr/pkg/metadata"
|
||||
|
||||
templ RegisterView() {
|
||||
@ui.HTML() {
|
||||
@ui.Head() {
|
||||
@session.DefaultMetaComponent()
|
||||
@metadata.DefaultMetaComponent()
|
||||
}
|
||||
@ui.Nav() {
|
||||
@ui.NavLeft() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package register
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@@ -9,6 +9,7 @@ import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import "github.com/sonr-io/motr/internal/ui"
|
||||
import "github.com/sonr-io/motr/pkg/metadata"
|
||||
|
||||
func RegisterView() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
@@ -55,7 +56,7 @@ func RegisterView() templ.Component {
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Err = ui.DefaultMetaComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = metadata.DefaultMetaComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package ui
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
// templ: version: v0.3.857
|
||||
package transfer
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
72
middleware/session/ksuid.go
Normal file
72
middleware/session/ksuid.go
Normal file
@@ -0,0 +1,72 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package session
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/segmentio/ksuid"
|
||||
"github.com/sonr-io/motr/middleware/kvstore"
|
||||
"github.com/sonr-io/motr/pkg/cookies"
|
||||
)
|
||||
|
||||
const kDefaultSessionTTL = 1 * time.Hour
|
||||
|
||||
func DetermineID(c echo.Context) string {
|
||||
if ok := cookies.SessionID.Exists(c); ok {
|
||||
c.Echo().Logger.Debug("Has session ID in cookie")
|
||||
if checkSessionTTL(c) {
|
||||
sessionID, err := cookies.SessionID.Read(c)
|
||||
if err != nil {
|
||||
sessionID = initNewID(c)
|
||||
}
|
||||
return sessionID
|
||||
}
|
||||
c.Echo().Logger.Debug("Session TTL expired, writing new session ID to cookie")
|
||||
cookies.SessionID.Write(c, initNewID(c))
|
||||
return getIDFromCookie(c)
|
||||
}
|
||||
c.Echo().Logger.Debug("Has session ID in cookie")
|
||||
sessionID, err := cookies.SessionID.Read(c)
|
||||
if err != nil {
|
||||
sessionID = initNewID(c)
|
||||
}
|
||||
return sessionID
|
||||
}
|
||||
|
||||
func initNewID(c echo.Context) string {
|
||||
id := ksuid.New().String()
|
||||
cookies.SessionID.Write(c, id)
|
||||
ttl := time.Now().Add(kDefaultSessionTTL)
|
||||
kvstore.Sessions().SetInt(id, int(ttl.Unix()))
|
||||
c.Echo().Logger.Debug("Wrote new session ID to cookie")
|
||||
return id
|
||||
}
|
||||
|
||||
func checkSessionTTL(c echo.Context) bool {
|
||||
ttl := getSessionTTL(c)
|
||||
if ttl < int(time.Now().Unix()) {
|
||||
c.Echo().Logger.Debug("Session TTL expired")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func getIDFromCookie(c echo.Context) string {
|
||||
sessionID, err := cookies.SessionID.Read(c)
|
||||
if err != nil {
|
||||
sessionID = initNewID(c)
|
||||
}
|
||||
return sessionID
|
||||
}
|
||||
|
||||
func getSessionTTL(c echo.Context) int {
|
||||
ttl, err := kvstore.Sessions().GetInt(getIDFromCookie(c))
|
||||
if err != nil {
|
||||
ttl = int(time.Now().Add(kDefaultSessionTTL).Unix())
|
||||
kvstore.Sessions().SetInt(getIDFromCookie(c), ttl)
|
||||
}
|
||||
return ttl
|
||||
}
|
||||
@@ -5,8 +5,6 @@ package session
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/segmentio/ksuid"
|
||||
"github.com/sonr-io/motr/pkg/cookies"
|
||||
)
|
||||
|
||||
// Context is a session context
|
||||
@@ -37,24 +35,3 @@ func Unwrap(c echo.Context) *Context {
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
func DetermineID(c echo.Context) string {
|
||||
if ok := cookies.SessionID.Exists(c); ok {
|
||||
c.Echo().Logger.Debug("Has session ID in cookie")
|
||||
sessionID, err := cookies.SessionID.Read(c)
|
||||
if err != nil {
|
||||
sessionID = ksuid.New().String()
|
||||
cookies.SessionID.Write(c, sessionID)
|
||||
c.Echo().Logger.Debug("Failed to read session ID from cookie, wrote new one")
|
||||
}
|
||||
return sessionID
|
||||
}
|
||||
c.Echo().Logger.Debug("Has session ID in cookie")
|
||||
sessionID, err := cookies.SessionID.Read(c)
|
||||
if err != nil {
|
||||
sessionID = ksuid.New().String()
|
||||
cookies.SessionID.Write(c, sessionID)
|
||||
c.Echo().Logger.Debug("Failed to read session ID from cookie, wrote new one")
|
||||
}
|
||||
return sessionID
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func (k CookieKey) ReadUnsafe(c echo.Context) string {
|
||||
return ck.Value
|
||||
}
|
||||
|
||||
// Write sets the cookie value for the Key.
|
||||
// Write sets the cooie value for the Key.
|
||||
func (k CookieKey) Write(c echo.Context, value string) {
|
||||
cookie := &http.Cookie{
|
||||
Name: k.String(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package session
|
||||
package metadata
|
||||
|
||||
import "github.com/labstack/echo/v4"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.865
|
||||
package ui
|
||||
// templ: version: v0.3.857
|
||||
package metadata
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -113,7 +113,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(m.Title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 76, Col: 17}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 76, Col: 17}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -126,7 +126,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(m.Favicon)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 77, Col: 51}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 77, Col: 51}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -139,7 +139,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(m.Description)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 78, Col: 49}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 78, Col: 49}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -152,7 +152,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(m.Keywords)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 79, Col: 43}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 79, Col: 43}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -165,7 +165,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(m.Author)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 80, Col: 39}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 80, Col: 39}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -178,7 +178,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(m.Robots)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 81, Col: 39}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 81, Col: 39}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -191,7 +191,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(m.Googlebot)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 82, Col: 45}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 82, Col: 45}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -204,7 +204,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(m.Google)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 83, Col: 39}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 83, Col: 39}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -217,7 +217,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(m.Title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 84, Col: 44}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 84, Col: 44}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -230,7 +230,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(m.Description)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 85, Col: 56}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 85, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -243,7 +243,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(m.OGImage)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 86, Col: 46}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 86, Col: 46}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -256,7 +256,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(m.OGURL)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 87, Col: 42}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 87, Col: 42}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -269,7 +269,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var15 string
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(m.OGSiteName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 88, Col: 53}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 88, Col: 53}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -282,7 +282,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var16 string
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(m.TwitterSite)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 92, Col: 50}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 92, Col: 50}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -295,7 +295,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(m.TwitterCreator)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 93, Col: 56}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 93, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -308,7 +308,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var18 string
|
||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(m.Title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 94, Col: 45}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 94, Col: 45}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -321,7 +321,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var19 string
|
||||
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(m.Description)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 95, Col: 57}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 95, Col: 57}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -334,7 +334,7 @@ func MetaComponent(m Metadata) templ.Component {
|
||||
var templ_7745c5c3_Var20 string
|
||||
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(m.TwitterImage)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/ui/metadata.templ`, Line: 96, Col: 52}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 96, Col: 52}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
Reference in New Issue
Block a user