tylermmorton / torque Goto Github PK
View Code? Open in Web Editor NEW`torque` is a web framework for building hypermedia driven applications in Go
Home Page: https://lbft.dev/
`torque` is a web framework for building hypermedia driven applications in Go
Home Page: https://lbft.dev/
You can use htmx with pocketnbase, but why ?
PB gives you the data layer that is reactive.
PB can code gen typed golang code from the a running PB, so then its easy to then use torque on top to build you GUI.
PB uses SSE to emit events to the GUI.
https://pocketbase.io/docs/use-as-framework/
https://pocketbase.io/docs/go-database/
The Golang code gen off PB aspects are here:
https://github.com/alexisvisco/pocketpase-gen
and
pocketbase/pocketbase#2697 (comment)
With the addition of the EventSource
route module type, there is also basic support for the htmx sse extension in the torque/pkg/htmx
sub-package as of 94a167a.
TODO:
EventSource
route module type in conjunction with htmx
In the current version of the torque
API, Loader
and Renderer
simply use the any
type to describe the loader data.
type Loader interface {
Load(req *http.Request) (any, error)
}
type Renderer interface {
Render(wr http.ResponseWriter, req *http.Request, loaderData any) error
}
It would be great for API ergonomics to be able to declare them using a generic combination interface:
Illustration:
type GenericRenderer[T any] interface {
Load(req *http.Request) (T, error)
Render(wr http.ResponseWriter, req *http.Request, loaderData T) error
}
Rough outline of solution:
The torque framework has its own htmx
package, mostly containing logic to wire up WebSockets and SSE into torque.
Recently a new package was released called htmx-go
that is a much more comprehensive implementation of htmx related features.
We should determine which logic in the torque htmx package can be deprecated and replaced.
Tasks:
htmx-go
package and update the docsite implementation to use it.Problem:
I often find myself configuring a rate-limiter guard for every route I register with a torque
app. I think this is a good use case for the Guard
API but if users end up registering the same guard on all of their endpoints, perhaps that is a sign that the guard logic should be implemented internally to torque.
torque.WithRouteModule("/login",
&login.RouteModule{
AuthService: authService,
},
torque.WithGuard(guards.ThrottleGuard(
throttled.PerHour(25),
)),
),
Rough outline of solution
Problem
Whenever a panic is left uncaught in server.go a log is printed to the console and nothing is written to the response body. This results in a blank screen in the browser.
In development environments it might be useful to render some HTML to the browser containing details about the error such as message & stack trace.
Rough outline of solution
handlePanic
of server.go, write the new error page to the response bodySaw that SSE is getting turned on.
Is there a chat app example or in fact any examples yet ?
The torque framework has some APIs for decoding form data. It might be useful to include support for honeypot fields, as described by Kent Dodds on his blog:
Another useful thing you can do along with the honeypot field is to add a field that will allow you to determine when the form was generated. So if the form is submitted too quickly, you can be pretty confident that it's a bot.
The time stamp based field sounds particularly useful and very possible for SSR based applications.
The form API is located here:
https://github.com/tylermmorton/torque/blob/master/form.go
Rough outline of solution:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.