SaturnFramework / Saturn

Opinionated, web development framework for F# which implements the server-side, functional MVC pattern
https://saturnframework.org
MIT License
707 stars 108 forks source link

Documentation: Getting started and Composition #243

Closed 0x53A closed 4 years ago

0x53A commented 4 years ago

Saturn is neat, but for me the getting started experience isn't perfect.

I really like to see some minimal working code, a hello world, not a link to a template I have to install.

I don't think there is an example of an application in the docs? At least I didn't find it.

The second thing I am missing a little bit in the documentation is how to combine the different things.

For example, much of Saturn is opt-in piece-by-piece (which is great!). If I have an existing giraffe application, I don't have to replace the existing initialization, I can just plug in one controller as an HttpHandler.

So I think it would maybe make sense to differentiate between creating a new application (use the application CE) and extending an existing application (just create a new controller).

The other way around, I recently needed to plug a Giraffe HttpHandler into a Saturn application, similar to choose. I found forward "" httpHandler after a bit of looking at all the options, but it wasn't really intuitive. Is that even the correct way?

Thanks!

MicaelMor commented 4 years ago

There used to be one https://github.com/SaturnFramework/Saturn.Template but it is clearly outdated.

That being said it is an easy fix I was able to quickly do it to test some deployment to the server yesterday https://github.com/MicaelMor/SaturnSample (this might have some changes that I don't remember making), that being said the sample itself does seem to contain an error when using it as an api provider, something I just created an issue for https://github.com/SaturnFramework/Saturn/issues/244 EDITED: Just fixed it and pushed the fix to this sample project, just in case anyone finds it and decides to use it.

From my point of view the bigger problem with the sample is that at least for me it could have been more useful as an actual learning tool. The best example I have found for how Saturn (or at least Giraffe) is useful is not really a Saturn sample but a SAFE one, https://github.com/CompositionalIT/SAFE-Dojo that project had exercises that I could follow (while also providing a full completed service if needed), and it showed me realistic real world use for it where Saturn was used in the way one would expect it to be.

The sample for me feels a bit more of a forced use case, since the Saturn project is being used as both the server and the client, while also doing work in databases, when in reality I would expect most people that are interested in using Saturn are only interested in knowing how Saturn can be used as a server, as in how to create routes to serve content, what are the best ways to consume those routes and so on.

Essentially I believe the sample should be a solution containing 2 projects, one client project and one server project, where the client is quite simple and doesn't use any technology that is more outside of F#, since the focus should be on how to best interact with the server from the client, and then the Server is where more of the focus of the sample should be, where the Server does the things a server should do and none that I believe we wouldn't really find in a server, so for example show how authentication might be handled, or how to provide data based on a simple model and a more complex model, those kinds of things.

In the end it should be said doing a sample for something like Saturn is complicated because Saturn isn't really a backend and a frontend so it is hard to do a sample that perfectly shows Saturn without potentially bringing some complications into it on the frontend side.

Anyway the sample folder of the project contains some useful examples even if they aren't standalone applications:

https://github.com/SaturnFramework/Saturn/blob/master/sample/

isaacabraham commented 4 years ago

I put a bare bones repo here for just this purpose. But yes, some more docs wouldn't go amiss and a walkthrough.