A few things have changed in the Nim webdev community since I last wrote in 2021</a>. The main update is that Jester is effectively in maintenance mode, and has some issues with the latest version of Nim. All of the other libraries/frameworks are still being actively developed (or are stable on the latest versions of Nim), which is a healthy sign.</p>
If you’re someone who would much rather browse through code, I have a small sample app using this stack that can be found here</a>.</p>
Since Jester is gone, I’ve switched to mummy</a>. It uses threads (instead of async/await), which leads to simpler code and even easier debugging due to stack traces. The author of mummy wrote a post on the Nim forum</a> that I recommend reading through on how he’s using it in production. It’s remarkably fast and stable - I’ve been running it on my web server uninterrupted for several months, and there have been absolutely no memory leaks or crashes in that time. I also used it to build sakura.arhamjain.com</a>, which saw traffic spikes during Sakura-Con (in Seattle), and never had any issues with scaling.</p>
For routing, I wrote my own (very small) library,</a> inspired by Roda instead of using the router that Mummy ships with. I find that specifying a routing tree is more natural for resource based URL schemes, and it makes it easy to add hooks and middleware without introducing callbacks/registration.</p>
I’ve switched from Norm</a> to debby</a>. This isn’t because of any issues with Norm, it’s mostly because I like using libraries written by treeform and guzba - if a Nim library ends in “y”, there’s a 90% chance one of them wrote it. Debby is much more hands off compared to Norm - it can generate tables and query them, but it doesn’t handle joins or most complicated SQL syntax. Instead, it specializes in mapping the results of a SQL query to a Nim object in a typesafe way.</p>
Web server</a>
</h2>
import</span> mummy, mummy</span>/</span>routers</span></span>
</span>
proc</span> indexHandler</span>(request</span>:</span> Request</span>)</span> =</span> </span></span>
var</span> headers</span>:</span> HttpHeaders</span></span>
headers[</span>"</span>Content-Type</span>"</span>] </span>=</span> "</span>text/plain</span>"</span> </span></span>
request</span>.</span>respond</span>(</span>200</span>, headers, </span>"</span>Hello, World\!</span>"</span>)</span></span>
</span>
var</span> router</span>:</span> Router</span> </span></span>
router</span>.</span>get</span>(</span>"</span>/</span>"</span>, indexHandler)</span></span>
</span>
let</span> server </span>=</span> newServer</span>(router) </span></span>
echo</span> "</span>Serving on http://localhost:8080</span>"</span> </span></span>
server</span>.</span>serve</span>(</span>Port</span>(</span>8080</span>))</span></span></code></pre>
import</span> mummy, rody</span></span>
</span>
let</span> handler </span>=</span> route</span>:</span> </span></span>
headers[</span>"</span>Content-Type</span>"</span>] </span>=</span> "</span>text/html</span>"</span> </span></span>
at </span>"</span>/</span>"</span>:</span> </span></span>
get</span>:</span> </span></span>
resp “</span>hello </span>world”</span></span>
</span>
echo</span> "</span>Serving on http://localhost:8080</span>"</span> </span></span>
newServer</span>(handler)</span>.</span>serve</span>(</span>Port</span>(</span>8080</span>))</span></span></code></pre>ORM</a>
</h2>
import</span> debby</span>/</span>sqlite</span></span>
let</span> db </span>=</span> openDatabase</span>(</span>"</span>cars.db</span>"</span>)</span></span>
</span>
type</span> Car</span> =</span> ref</span> object</span> </span></span>
id</span>:</span> int</span> </span></span>
make</span>:</span> string</span> </span></span>
model</span>:</span> string</span> </span></span>
year</span>:</span> int</span></span>
</span>
db</span>.</span>createTable</span>(</span>Car</span>)</span></span>
</span>
var</span> car </span>=</span> Car</span>(</span></span>
make</span>:</span> "</span>Chevrolet</span>"</span>,</span></span>
model</span>:</span> "</span>Camaro Z28</span>"</span>,</span></span>
year</span>:</span> 1970</span> </span></span>
)</span></span>
db</span>.</span>insert</span>(car)</span></span>
car </span>=</span> db</span>.</span>get</span>(</span>Car</span>, car</span>.</span>id)</span></span>
car</span>.</span>
This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.
A few things have changed in the Nim webdev community since I last wrote in 2021 . The main update is that Jester is effectively in maintenance mode, and has some issues with the latest version of Nim. All of the other libraries/frameworks are still being actively developed (or are stable on the latest versions of Nim), which is a healthy sign. If you’re someone who would much rather browse…
