Skip to content

zhaoyul/clojure-clr-dotnet-api

 
 

Repository files navigation

clojure-clr-dotnet-api

Example of using clojure-clr and dotnet 7 minimal api 100% async - interoping with System.Threading.Tasks.Task using clojure core.async.

Quickstart (Dockerfile)

  1. build the image: docker build -t clojure-clr-api .
  2. docker-compose up (launches postgres and the application)

Development Setup

  • Install .NET 7 and Docker
  • Install potion - a clojure clr tool as a tool: dotnet tool install --global potion -- must be version 1.0.5+
  • Run dotnet restore to install the nuget packages specified in CljApi.csproj
  • docker-compose up using the docker-compose in /dev

Start & Connect to a repl

From the terminal:

  1. start a clojure nrepl: potion repl
  2. connect with a nrepl compatible editor, e.g. VSCode using the Calva extension.
  3. Eval code via the repl 💠 - main.cljr contains a comment block where you can start and stop the application via the repl.

Run the application

potion -m clj-api.main

Routes

GET - /
GET - /users - returns all users
POST - /user - create a user
GET - /healthz - returns health check status

Features

  • System composition using integrant ✅
  • Routing ✅
  • Db Access ✅
  • Add routes that accepts json, returns json ✅
  • Health Checks ✅
  • Structured Logging with Serilog ✅
  • Background jobs
  • Metrics
  • Swagger Docs
  • Request Validation
  • CI - build a Docker image from a Dockerfile

Limitations

  • Can't produce a standalone DLL with clojure-clr for .NET Core 3.1+

About

Using .NET 7

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Clojure 99.7%
  • Dockerfile 0.3%