'use strict' // Notice no certs, one thing I have thought // for a long time is that frameworks should // directly have support for spinning up with // a cert if none was provided. require('h3xt')() .get('/', (req) => { // Access the associated session // req.session // No need to check if can push, frameworks does this // The framework has something like a ROOT so you can // resolve static files, but the content type negotiation // is something I think belongs in the underlying core api req.pushFile('favicon.ico') req.pushJSON('/foo.json', { message: await req.body() }) // Frameworks could do whatever templating they saw fit, // delivering the resulting string/buffer to `req.respond()` // In this example I am assuming a "return response" approach, // and the `.sendFile` call would return a `Response` // object, and the middleware/routing layer would use that // object to actually send return req.sendFile('index.html', { // template data }) }) .listen(8443)