Since .NET 8's release and the subsequent release of SAFE v5 - using the new version of .NET and F#, we here at Compositional IT have been upgrading our various SAFE resources, including the SAFE Dojo! The new version is available here. It is perhaps worth noting that many of the SAFE projects have switched to TailwindCSS for their UI but that is not the case for the SAFE Dojo.
The SAFE Dojo
The SAFE Dojo is a simple project designed to help people get to grips with the SAFE stack. It consists of a series of small exercises which mirror the sort of tasks that are often undertaken when working with SAFE.
Task 1.1
For a sample of the poject let's take a peek at the first task, found in Api.fs
.
(* Task 1.1 CRIME: Bind the getCrimeReport function to the GetCrimes method to
return crime data. Use the above GetDistance field as an example. *)
GetCrimes = fun postcode -> async { return Array.empty }
Earlier in the Api.fs
the function getCrimeReport
is already defined, which takes a postcode and asynchronously returns an array of CrimeResponse
which is exactly what this API is expecting. That means that the hard part is already taken care of for us, and all that's left to do is to hook it up in the dojoApi
object.
(* Task 1.1 CRIME: Bind the getCrimeReport function to the GetCrimes method to
return crime data. Use the above GetDistance field as an example. *)
GetCrimes = getCrimeReport
Since the UI was already primed to handle this UI data, we can immediately see the results in the browser.
That's just the first exercise. At the end of the dojo, you will have added code that is shared between the client and server, added a map to the UI, and added a whole new weather endpoint to the app! To give it a go yourself, head over to the SAFE Dojo repository.