diff --git a/.github/taskfiles/taskfile.migrate.yml b/.github/taskfiles/taskfile.db.yml similarity index 93% rename from .github/taskfiles/taskfile.migrate.yml rename to .github/taskfiles/taskfile.db.yml index a557e84..441d8bd 100644 --- a/.github/taskfiles/taskfile.migrate.yml +++ b/.github/taskfiles/taskfile.db.yml @@ -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 # --------------- diff --git a/.github/taskfiles/taskfile.publish.yml b/.github/taskfiles/taskfile.log.yml similarity index 63% rename from .github/taskfiles/taskfile.publish.yml rename to .github/taskfiles/taskfile.log.yml index b1ecd9d..4daf766 100644 --- a/.github/taskfiles/taskfile.publish.yml +++ b/.github/taskfiles/taskfile.log.yml @@ -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}}" diff --git a/.github/taskfiles/taskfile.watch.yml b/.github/taskfiles/taskfile.radar.yml similarity index 100% rename from .github/taskfiles/taskfile.watch.yml rename to .github/taskfiles/taskfile.radar.yml diff --git a/.github/taskfiles/taskfile.build.yml b/.github/taskfiles/taskfile.worker.yml similarity index 66% rename from .github/taskfiles/taskfile.build.yml rename to .github/taskfiles/taskfile.worker.yml index 092c872..ddfd51f 100644 --- a/.github/taskfiles/taskfile.build.yml +++ b/.github/taskfiles/taskfile.worker.yml @@ -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 diff --git a/Taskfile.yml b/Taskfile.yml deleted file mode 100644 index e55e3dc..0000000 --- a/Taskfile.yml +++ /dev/null @@ -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 - diff --git a/cmd/radar/Taskfile.yml b/cmd/radar/Taskfile.yml new file mode 100644 index 0000000..ddfd51f --- /dev/null +++ b/cmd/radar/Taskfile.yml @@ -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 + diff --git a/cmd/worker/Makefile b/cmd/worker/Makefile index 30d7e8c..2f3ab37 100644 --- a/cmd/worker/Makefile +++ b/cmd/worker/Makefile @@ -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 diff --git a/cmd/worker/Taskfile.yml b/cmd/worker/Taskfile.yml new file mode 100644 index 0000000..ddfd51f --- /dev/null +++ b/cmd/worker/Taskfile.yml @@ -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 + diff --git a/internal/ui/dash/cards_templ.go b/internal/ui/dash/cards_templ.go index bd1f7f4..9d6ad00 100644 --- a/internal/ui/dash/cards_templ.go +++ b/internal/ui/dash/cards_templ.go @@ -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. diff --git a/internal/ui/dash/charts/area_chart_templ.go b/internal/ui/dash/charts/area_chart_templ.go index ed33f3d..72bb2ec 100644 --- a/internal/ui/dash/charts/area_chart_templ.go +++ b/internal/ui/dash/charts/area_chart_templ.go @@ -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 { diff --git a/internal/ui/dash/charts/bar_chart_templ.go b/internal/ui/dash/charts/bar_chart_templ.go index c0bad5a..1ddd8c5 100644 --- a/internal/ui/dash/charts/bar_chart_templ.go +++ b/internal/ui/dash/charts/bar_chart_templ.go @@ -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 { diff --git a/internal/ui/dash/charts/candle_chart_templ.go b/internal/ui/dash/charts/candle_chart_templ.go index 32982d3..24a029c 100644 --- a/internal/ui/dash/charts/candle_chart_templ.go +++ b/internal/ui/dash/charts/candle_chart_templ.go @@ -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. diff --git a/internal/ui/dash/charts/line_chart_templ.go b/internal/ui/dash/charts/line_chart_templ.go index 40d3650..ac19b1a 100644 --- a/internal/ui/dash/charts/line_chart_templ.go +++ b/internal/ui/dash/charts/line_chart_templ.go @@ -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 { diff --git a/internal/ui/dash/charts/pie_chart_templ.go b/internal/ui/dash/charts/pie_chart_templ.go index 0c02e19..b49b239 100644 --- a/internal/ui/dash/charts/pie_chart_templ.go +++ b/internal/ui/dash/charts/pie_chart_templ.go @@ -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 { diff --git a/internal/ui/dash/scripts_templ.go b/internal/ui/dash/scripts_templ.go index ea5f342..3dfbe16 100644 --- a/internal/ui/dash/scripts_templ.go +++ b/internal/ui/dash/scripts_templ.go @@ -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. diff --git a/internal/ui/dash/view.templ b/internal/ui/dash/view.templ index a431eea..3befa61 100644 --- a/internal/ui/dash/view.templ +++ b/internal/ui/dash/view.templ @@ -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() } @ui.Nav() { diff --git a/internal/ui/dash/view_templ.go b/internal/ui/dash/view_templ.go index 6272881..6522aed 100644 --- a/internal/ui/dash/view_templ.go +++ b/internal/ui/dash/view_templ.go @@ -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) diff --git a/internal/ui/home/view.templ b/internal/ui/home/view.templ index 77cd99a..70927dd 100644 --- a/internal/ui/home/view.templ +++ b/internal/ui/home/view.templ @@ -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() { diff --git a/internal/ui/home/view_templ.go b/internal/ui/home/view_templ.go index 1089ed5..64d713a 100644 --- a/internal/ui/home/view_templ.go +++ b/internal/ui/home/view_templ.go @@ -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 } diff --git a/internal/ui/layout_templ.go b/internal/ui/layout_templ.go index 14d4786..756f56a 100644 --- a/internal/ui/layout_templ.go +++ b/internal/ui/layout_templ.go @@ -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. diff --git a/internal/ui/login/inputs_templ.go b/internal/ui/login/inputs_templ.go index 3354013..4b0ec58 100644 --- a/internal/ui/login/inputs_templ.go +++ b/internal/ui/login/inputs_templ.go @@ -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. diff --git a/internal/ui/login/scripts_templ.go b/internal/ui/login/scripts_templ.go index f296cea..d955cab 100644 --- a/internal/ui/login/scripts_templ.go +++ b/internal/ui/login/scripts_templ.go @@ -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. diff --git a/internal/ui/login/view.templ b/internal/ui/login/view.templ index f5eb93b..42044c0 100644 --- a/internal/ui/login/view.templ +++ b/internal/ui/login/view.templ @@ -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() { diff --git a/internal/ui/login/view_templ.go b/internal/ui/login/view_templ.go index e2ec07a..d1e8206 100644 --- a/internal/ui/login/view_templ.go +++ b/internal/ui/login/view_templ.go @@ -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 } diff --git a/internal/ui/providers_templ.go b/internal/ui/providers_templ.go index ef943dc..556da3f 100644 --- a/internal/ui/providers_templ.go +++ b/internal/ui/providers_templ.go @@ -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. diff --git a/internal/ui/register/inputs_templ.go b/internal/ui/register/inputs_templ.go index ff6dab9..917e863 100644 --- a/internal/ui/register/inputs_templ.go +++ b/internal/ui/register/inputs_templ.go @@ -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. diff --git a/internal/ui/register/scripts_templ.go b/internal/ui/register/scripts_templ.go index 60937cf..8c2c324 100644 --- a/internal/ui/register/scripts_templ.go +++ b/internal/ui/register/scripts_templ.go @@ -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. diff --git a/internal/ui/register/view.templ b/internal/ui/register/view.templ index ed4f843..6271f88 100644 --- a/internal/ui/register/view.templ +++ b/internal/ui/register/view.templ @@ -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() { diff --git a/internal/ui/register/view_templ.go b/internal/ui/register/view_templ.go index 3895864..4d61606 100644 --- a/internal/ui/register/view_templ.go +++ b/internal/ui/register/view_templ.go @@ -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 } diff --git a/internal/ui/styles_templ.go b/internal/ui/styles_templ.go index 5010dca..74ef1c9 100644 --- a/internal/ui/styles_templ.go +++ b/internal/ui/styles_templ.go @@ -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. diff --git a/internal/ui/transfer/inputs_templ.go b/internal/ui/transfer/inputs_templ.go index e3d8bed..c329a60 100644 --- a/internal/ui/transfer/inputs_templ.go +++ b/internal/ui/transfer/inputs_templ.go @@ -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. diff --git a/middleware/session/ksuid.go b/middleware/session/ksuid.go new file mode 100644 index 0000000..c7c6a33 --- /dev/null +++ b/middleware/session/ksuid.go @@ -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 +} diff --git a/middleware/session/middleware.go b/middleware/session/middleware.go index 5b8a23a..b2a972e 100644 --- a/middleware/session/middleware.go +++ b/middleware/session/middleware.go @@ -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 -} diff --git a/pkg/cookies/cookies.go b/pkg/cookies/cookies.go index 85c3393..8ce9553 100644 --- a/pkg/cookies/cookies.go +++ b/pkg/cookies/cookies.go @@ -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(), diff --git a/middleware/session/metadata.templ b/pkg/metadata/metadata.templ similarity index 99% rename from middleware/session/metadata.templ rename to pkg/metadata/metadata.templ index 6de4f80..e27c227 100644 --- a/middleware/session/metadata.templ +++ b/pkg/metadata/metadata.templ @@ -1,4 +1,4 @@ -package session +package metadata import "github.com/labstack/echo/v4" diff --git a/internal/ui/metadata_templ.go b/pkg/metadata/metadata_templ.go similarity index 88% rename from internal/ui/metadata_templ.go rename to pkg/metadata/metadata_templ.go index 4ce36df..1a8bf29 100644 --- a/internal/ui/metadata_templ.go +++ b/pkg/metadata/metadata_templ.go @@ -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 {