DEV Community

Juan Carlos
Juan Carlos

Posted on

Self-Firejailing Web Framework

The Nonconformism

Once upon a time a bored Developer was looking for new cool Web Frameworks,
and the adventure begins...

Not far from the starting point some very Trendy frameworks appear on the horizon,
their homepage have super state-of-the-art CSS and a lot of Sponsor companies,
then to evaluate the list of Features I turn to its official Documentation,
very surprised I found most of them (if not all) tend to use basic plain text Auth,
saying that you must use that or implement your own, and is up to you.
Similar story with any means of security too, none of the Features was too deep,
the addition of new parts was kinda Glue-Code it up,
because Trendy framework moves too fast they do not have time for that.

...I was wondering, so they wasted all the Sponsors money on CSS and Marketing?

Sometimes you just have to make a pause, drink some Mate or coffee,
take some distance and look at the landscape from far, and think.

We are in 2019, I think it should be possible to do it different,
even if is not so Hipster and Trendy, and we got no sponsors.

I do not care too much how fast you say your language move if its a kaleidoscope of tiny pieces by different magicians.

Ones say single-threading is the future, others say a global-lock is the future,
we think you should be able to squeeze all the hardware you payed for,
even more nowadays with 32 CPU Cores, Raspberry Pi will have 8 Cores,
if its a rented Cloud you are literally paying for CPU and RAM usage too.

The Jester and the Beast

Back to GitHub, we have the best tools for the job, the Nim programming language.

1 language for the whole stack, Backend & Frontend,
including high performance modules, scripting, devops, deploy.
From WebAssembly to Assembly. Python modules and JavaScript.

From a humble blank text file the new web framework was born,
Nim Website Creator its name, inspired by previous experiences, but copying none.

Building the new framework, brick by brick, on top of Jester and the Beast,
for Authentication we use 2 Factor Authentication (TOTP), available from Nimble,
the 2FA is enabled by default, so you can use it right away, because we are on 2019.

ReCaptcha built-in (optional), BCrypt+Salt passwords, Postgres or SQLite,
JavaScript framework agnostic, Auto-Rotating file Logger, Server Status Page.
Edit main config file (INI format) directly from browser for Admins.

We made a "DevOps" folder on the repo with useful resources.

The Dance of Nim and Fire

Looking to improve the security we went trekking on the land of the Linux kernel,
we hunt down a really nice tool named Firejail (Pure C, no dependencies),
then wrap it on a library, uploaded to Nimble, to integrate it on the core,
finally the framework Firejails itself.

This allows the Admin of the site to control the security,
isolating software to the very bare minimum that it should "see" of the server to run,
it can run with no-root, no-Shell, no file system visible,
and also it comes with hardware level isolation and control,
the Admin can control how much CPU & RAM & Cores the framework can use,
other smaller features like auto-restart, high availability, Net isolation, etc.

Firejail is 100% Optional, you can compile NimWC without the Firejail integration.

Selfie

Libravatar is an Open Source alternative to Gravatar, that also supports Gravatar,
support is built-in and ready to be used by Plugin developers to display avatars.

Also a local custom uploaded image file can be used too.
Private and public files and images uploads and downloads with counter is built-in.

WebP automatic image and photo optimizations.

WebP is optional, you can compile without the WebP feature.

The Silk Road

The framework comes with a graphical Plugin Store integrated,
so you can add your own custom features and functionalities,
directly from the browser from a friendly UI. A feature, a click.

Each Plugin has name, MarkDown/RST description, version, author, license, tags,
buttons to install/uninstall, update, talk to the developer, even the authors photo.
You can have Plugins installed but Disabled too.

The store works backed by Git, so you can use your GitHub or GitLab, Free or Pro.

We would love to make Open Source Self-Sustainable (will you help us?),
so theres a field were you can put your Bitcoin or Patreon or LiberaPay address,
and it will be rendered on the Plugin Store as a button,
so users can Subscribe to you if they love your Plugin!.

Upload your Plugin to the Store today!.

Army of Skeletons

NimWC has a Skeleton creator built-in,
the Plugin Skeleton creator makes a new plugin (empty) for you,
some basic plugin information is written to a JSON file
(to generate a pretty UI on the Store for your Plugin),
and some files and folders are created (HTML, CSS, JS, Nim, etc),
the files will have useful comments with help, docs and links,
its like a project template or cookiecutter on other languages.

Making a plugin is coding vanilla HTML,
CSS with Bulma or Bootstrap or manual,
JS with Nim or other language,
Templating with Nims standard library templating engine,
you can use Karax or React or other language,
you can even use Nim's Web Assembly.

You can check the documentation for Plugins and peek at the existing Plugin code.

Create your Skeleton and code your ideas into features.

Hello World

  • So... How to make a web Hello World?.
routes:
  get "/":
    resp "Hello World"

Yes, that is actual valid Nim lang code :)

Nim compiles to tiny single-file dependency-free optimized native binary executable.

A more complete example.

Video or didnt happen

Live Demo

There's an official public free access instance running to showcase the framework.

We added a limited Demo mode, optional via compile-time flag.

Presentation

Nim Website Creator Presentation Slides

Futurology

Most of the issues are feature plannings or related. This is just a peek into NimWC.

Some incoming stuff is Material Design, better UI/UX, more Docs and Plugins!.

Community

There's bridged Gitter, Matrix, Telegram, IRC, Discord for Nim, come say Hi.

Learn Nim today.
NimWC on Nimble.
NimWC on GitHub.
Python Modules on PyPI written 100% on Nim.
Nim Sticker Pack.
Grupo de Telegram en Español.

We don't have Crabs, we don't have squinting Rats, we have a friendly community,
we have the Performance of C with Python-like syntax, come to the Nim side...
👑

Top comments (0)