-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Valen. H edited this page May 30, 2019
·
1 revision
- Middlewares
- Propagating
- Builtin / Custom
- Content-Type mapping
- Path-URL mapping customization
- Port customization
- Templating/Indexing
- Event-Oriented
- Caching
- fix - Fixes incorrect URLs
- TODO: .xjs -> .jsx etc...
- directory - Serves index or performs directory indexing
- .noindex (customisable) - empty to block indexing, fill to block specific files
- files starting with '__' (customisable) - blocked from indexing by default
- TODOs: .notmpl - no templating (for .jsx files mostly), and a special request to fetch raw and bypass translation
- static - Serves raw content and compiles templated content
- TODO: Add caching
- Templated content: .xjs, .htmx, .htmlx, .cssx
- end - Applies appropriate headers and ends requests
- TODO: secure - Prevents bruteforcing / DoS (-> HTTP 429)
Templated content example.htmx:
Hello $$usr$$!
. Translated during serving, change templating characters through server options.
const server = require("vale-server-ii").Server,
classes = require("../dist/lib/Classes").Classes;
async function start() {
srv = await server.setup({ }); /**@param {Classes.Options.ServerOptions} opts - leave empty fields for default*/
await srv.bind(); //listen()
await srv.bind(new classes.Middleware("test", [ "end" ], [ "static" ], async function body(req, res, event) {
event.server._debug(event.reqcntr, "(TEST.TS) PASSED.");
return event.pass("passed");
}
)); //bind custom middleware
console.debug("Server started...");
srv.on("log", console.log);
srv.on("request", (req, res) => console.debug("(INDEX.JS) REQ:", req.url));
} //start
start();
Enable builtin middlewares with the
allowmw
option.
Also take a look inClasses
to see how things work