Bix.Cloudflare 1.0.0-beta-002

This is a prerelease version of Bix.Cloudflare.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Bix.Cloudflare --version 1.0.0-beta-002                
NuGet\Install-Package Bix.Cloudflare -Version 1.0.0-beta-002                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bix.Cloudflare" Version="1.0.0-beta-002" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bix.Cloudflare --version 1.0.0-beta-002                
#r "nuget: Bix.Cloudflare, 1.0.0-beta-002"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Bix.Cloudflare as a Cake Addin
#addin nuget:?package=Bix.Cloudflare&version=1.0.0-beta-002&prerelease

// Install Bix.Cloudflare as a Cake Tool
#tool nuget:?package=Bix.Cloudflare&version=1.0.0-beta-002&prerelease                

Bix

the "Bix" name is just a codename for now (until I decide it's good to go).

An F# microframework that provides a router and http handler abstractions for web frameworks that work with a Request -> Response http server model.

Examples of runtimes that work with this model:

This microframework is heavily inspired by Giraffe, and Saturn frameworks from F# land so if you have ever used that server model then Bix will feel fairly similar.

An hypotetical example could be like the following code:

// define a function that takes HttpHandlers to satisfy existing handler constrains
let authenticateOrRedirect (authenticatedRoute: HttpHandler, notAuthenticatedRoute: HttpHandler) =
    Handlers.authenticateUser
        authenticatedRoute
        notAuthenticatedRoute

// compose different handlers for code reusability
// and granular control of handler execution
let checkAdminCredentials successRoute =
    authenticateOrRedirect (successRoute, Admin.Login)
    >=> Handlers.requiresAdmin

let checkUserCredentials successRoute =
    authenticateOrRedirect (successRoute, Views.Login)
    >=> Handlers.requiresUserOrAbove

// define routes for this application
let routes =
    Router.Empty
    |> Router.get("/", authenticateOrRedirect >=> Views.Landing)
    |> Router.get ("/login", authenticateOrRedirect >=> Views.Login)
    |> Router.get ("/me", checkUserCredentials(Views.Login))
    |> Router.get ("/portal", checkUserCredentials(Views.Portal))
    |> Router.get ("/admin", checkAdminCredentials(Admin.Portal))
    |> Router.post ("/users", checkAdminCredentials(Api.Users.Create >=> negotiateContent))
    |> Router.patch ("/users/:id", checkAdminCredentials(Api.Users.Update >=> negotiateContent))

// Start the web server
Server.Empty
|> Server.withPort 5000
|> Server.withDevelopment true
|> Server.withRouter routes
|> Server.run

The idea is to create simple and single purposed functions that work like middleware so you can organize and re-use

Adapters

Bix currently has two adapters

  • Bix.Deno
  • Bix.Bun

Adapters under investigation:

  • Bix.ServiceWorker
  • Bix.CloudflareWorker

Development

This project is developed with VSCode in Linux/Windows/WSL but either rider, and visual studio should work just fine.

Requirements

Try the samples

Depending on what you want to try change the directory to your selected sample, example: cd samples/Bix.Bun.Sample and run one of the following commands

  1. dotnet tool restore (run once per clone)
  2. start the project
    • bun start
    • deno task start

both commands will restore the projects and run fable, bun/deno in watch mode.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-beta-006 63 5/22/2024
1.0.0-beta-004 106 7/10/2023
1.0.0-beta-003 122 7/22/2022
1.0.0-beta-002 125 7/18/2022