32
loading...
This website collects cookies to deliver better user experience
unknown
type. That way, I have to write more types manually, but at least TypeScript reminds me to do so. Accept
header wouldn't include application/json
.async function(request) {
const query = generateQuery(request);
const data = await queryDb(query);
const app = <html>
<title>{data.title}</title>
</html>;
const html = renderToString(app);
return new Response(html, {
status: 200,
headers: {"Content-Type": "text/html" }
});
}
api
.match(request => true)
.auth(async request => true)
.load(async request => rawData)
.format(rawData => data)
.render(data => response);
request
, authentication/authorization and data-loading can be async in needed, and I can drop out before rendering HTML if the Accept
header requires it.32