Is full stack F# superb? I'm still working that out.
- Set Up
- Architecture
- Develop
- Build
- API:
dotnet build
|dotnet clean
- Client:
yarn build
|yarn clean
- GraphQL:
dotnet snowflaqe --generate
- API:
- Run
- API:
dotnet run --project src/SuperbApi/SuperbApi.fsproj --launch-profile https:watch
- Client:
yarn start
- API:
- Format
- API:
dotnet fantomas src/**/*.fs
- API:
- Analyze
- API:
dotnet fsharplint lint Superb.sln
- API:
- Audit
- API:
dotnet paket ...
(auditing occurs w/ normal usage) - Client:
yarn npm audit
- API:
- Test
- API:
dotnet test
- API:
- Build
Instructions written on a machine running macOS 14.5.
-
Install system dependencies necessary to build/run the app.
dotnet
- Homebrew | Microsoft: Install .NET on macOSasdf
- asdf: Getting Started Guide
-
Next, add the
nodejs
plugin forasdf
, and then installnodejs
itself.asdf plugin add nodejs asdf install
-
After installing system dependencies, and the
asdf
plugin, install runtime/project dependencies. Restore dotnet tools, install NuGet packages using Paket, and then install NPM packages.dotnet tool restore dotnet paket install # The first two commands may not be necessary - listing # pending further reading. corepack enable asdf reshim yarn
-
Finally, take the optional step of generating dev certificates to support developing with SSL (https) locally. Accept/trust the generated development certificate if prompted. Find more on this in an ASP.net Core Web API tutorial.
dotnet dev-certs https --trust
Superb is broken into four projects.
- SuperbApp (
src/SuperbApp/SuperbApp.fsproj
)- Brain of Superb.
- Provides primary types, data, and business logic.
- No dependencies on other projects.
- SuperbApi (
src/SuperbApi/SuperbApi.fsproj
)- Server/API for Superb.
- Provides a GraphQL endpoint.
- Depends on
SuperbApp
.
- SuperbGraphQL (
src/SuperbGraphQL/SuperbGraphQL.fsproj
)- Queries, mutations, and types for GraphQL consumption on the frontend.
- Besides
.graphql
queries and mutations, the code in this project is mostly generated. - No dependencies on other projects.
- SuperbUi (
src/SuperbUi/SuperbUi.fsproj
)- Frontend UI for Superb.
- React application, powered by Feliz and Fable.
- Depends on
SuperbGraphQL
. Implicitly depends onSuperbApp
andSuperbApi
.
-
Build or clean app/API artifacts (as well as some client artifacts):
dotnet build dotnet clean
-
Build or clean client artifacts (note that this also builds any necessary/missing client .NET artifacts):
yarn build yarn clean
-
Generate GraphQL artifacts for the client:
dotnet snowflaqe --generate
- NOTE: This is necessary after updating the GraphQL schema or GraphQL operations.
Building or cleaning the app/api/client is generally not necessary in development. However, both actions can be useful, as a troubleshooting step, if anything is failing to run. It is necessary to build GraphQL artifacts for the client after updating the GraphQL schema/operations.
-
App/API (automatically rebuilds when relevant code changes):
dotnet watch --project src/SuperbApi/SuperbApi.fsproj --launch-profile https
- https://localhost:7011/graphql/ should open in the browser upon running this.
-
Client (also rebuilds when relevant code changes):
yarn start
- Once
vite
finishes any set up, presso
to open http://localhost:5173/ in the browser.
- Once
-
Format F# code with Fantomas. There are editor integrations available to streamline this.
dotnet fantomas **/*.fs
-
Fantomas does a great job formatting code automatically, but it doesn't cover more nuanced style issues. FSharpLint helps in this arena.
dotnet fsharplint lint Superb.sln
-
.NET dependencies are managed with Paket, and sourced from NuGet. Restoring/installing packages automatically scans for known vulnerabilities, and if any are found, reports them. The article Auditing package dependencies for security vulnerabilities covers this in more detail.
-
JS packages can be audited with:
yarn npm audit
-
Run API tests:
dotnet test