🚀 Announcing Serverino 0.6.0! 🎉

aberba karabutaworld at gmail.com
Sun Mar 10 21:04:05 UTC 2024


On Thursday, 7 March 2024 at 21:00:03 UTC, Andrea Fontana wrote:
> Performance has been boosted once again, and those pesky little 
> bugs? Squashed! Plus, there are fresh examples to try out and 
> even a sleek new logo to admire!
>
> Ready to dive in? Just spin up a new project using the provided 
> template:
>
> ```
> dub init -t serverino my_wonderful_project
> cd my_wonderful_project
> dub
> ```
>
> And voilà! Your hello world will be up and running in **a 
> couple of seconds**! 🌐
>
>
> Have fun!
> Andrea Fontana
>
> (I know some of you are already on board, but how many are 
> sailing in secret? Come out of the shadows and let me know! 
> Your feedback is the wind in serverino's sails)
>
> Repository: https://github.com/trikko/serverino
> Docs: https://trikko.github.io/serverino
> Examples: 
> https://github.com/trikko/serverino/tree/master/examples
> Tips: https://github.com/trikko/serverino/wiki/

I'm a heavy user of big express (js) library and I like what I'm 
seeing. Looks simple and clean. Here are some suggestions:

     1) I'm not sure I like concat (~=)
      style used on `Output output` and how it can determine the 
order routes are invoked. I would expect that to be explicitly 
defined by Dev using a catch-all route or else the sever returns 
404 by default. That's going to prevent the chances of invoking 
the wrong route especially when it does something 
important/dangerous/unexpected.


2) instead of doing:

     ```d
     if (request.method != Request.Method.Get)
     		output.status = 405;
     ```

to determine the request method, why not use a UDA similar to 
`@route` ...like `@method(Request.Method.post)`? The use of UDA 
is so much cleaner and easier to deal with.


3) would be nice to have an `output.json()` function which both 
sets the response header and also calls `output.write()`

4. I can't build anything significant in any http server library 
without support for middleware. Preferably support for multiple 
middlewares functions. A middleware would be a function that runs 
after the @onServerInit but BEFORE any route handler. It will be 
used to intercept all incoming requests for things like 
authentication, rate limiting, CORS, etc. Preferably provide a 
way to pass data to the target route e.g. user session, user 
permission, etc...like output.locals.set("userId", 123). The 
route will then be able to access this data.


All in all, everything else looks good. I would prefer something 
like:

     ```d
     void hello (Request req, Response res) {
         res.write("hello");
     }
     ```
     ...but `Output` is also fine... just a small nitpick.



More information about the Digitalmars-d-announce mailing list