This is a Micro HTTP Server template, meant to be the smallest real-use webserver, with only around 650 tree-dependencies:
tiny_http- Tiny HTTP server, handles all the HTTP stuffmatchit- A small router, meant for separating routes into functionsclap- CLI handling, bit bulky but needed to handle everything cli-relatedsea-orm- Database handler, could be swapped for SQLx or anything elsetera- Templating for the webpageshtmx- Interactivity with server-side, improves the vanilla HTML experiencealpinejs- Client-side interactivitypicocss- CSS Styling to make things look betterleaflet- For when you need a simplistic mapvite- Bundling htmx, alpinejs, picocss and leaflet so that a external CDN is not needed
In terms of dependencies, not much is needed, only really needing Rust and Node.JS to be installed.
With some small tweaks, such as removing vite, the package.json files, and replacing it's links on the views/templates/base.html template file, and removing the build.rs, can completely remove the dependency on Node.JS, at the cost of needing a external CDN for things like CSS and JS libraries you might want to use.
The actual code structure is meant to be something simplistic, while also allowing to quickly expand the codebase for new features:
src/cli- Everything related to the command-line. Can be expanded to add new commandssrc/config- General-purpose configuration for the whole applicationsrc/core- Core functionality such as error handling and routingsrc/database/migrations- Embedded migrations for the databasesrc/database/models- The database binding modelssrc/providers- Any sort of external dependency such as a external KV, a Database, Templating provider, etcsrc/services- The actual routes servedsrc/web_server- The entrypoint for the web server, initializes the providers and spawns in the http server.views- The page templates that are rendered inviews/templates- The skeleton templates that the pages uses for things like layout or reusable components
Vite. Literally, Vite. For the bundling to work, we need to set a entrypoint that not only imports the dependencies you need, but also sets them in the proper place.
At the moment, such is a two-fold work.
You first must edit the views/main.js file to import it, then add it to the window context as needed (then also do any initialization step you might need).
Then, you must add it to a chunk at the manualChunks section inside the vite.config.ts.
In future, I might find a way to condense this into a simpler method, but for now it's the best I can do :3
This, is not the project for this. You probably can do it, yet don't expect much support with it. The goal of this project is to have a minimal code-base, while leveraging Vanilla HTML/CSS/JS.
The incrementation with HTMX and Alpine.JS are meant to facilitate small things such as forms, small interactivities and others.
Without going into all the model-relationship system (which, for me, is quite redundant), SeaORM feels more akin to a query builder than a ORM itself.
Yet, this is not forced, you can simply replace it with whatever other library you'd like to handle database, edit the src/providers/database.rs file to use your library of choice instead, and go your merry way
No. Just no.
Try to nuke the target folder and recompile from scratch. Sometimes, it does that
I couldn't figure out a decent way to have hot-reloading working on this. Feel free to give it a try if you'd like, do send a PR if you can.
I'm aware of Tera's hot reloading module(tera-hot-reload), but for some god-forsaken reason, it depends on Tower for compatibility with axum and others, while not having it behind a feature-flag. Not wanting to have the entirety of axum and tower on my dependency tree when I'm not even using them.
This project is mostly meant as a 'do whatever you want, just give credits', but since the world isn't as bright as one would hope...
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.