UNPKG

@webqit/webqit.dev

Version:

webqit.dev Site

51 lines (47 loc) 1.11 kB
/** * @imports */ import { render as packageRender } from '../../common/package.js'; import { tooling } from '../../common/data.js'; /** * @var object */ const cache = {}; /** * Handles main HTTP process. * * @param object process * @param any recieved * @param function next * * @return object */ export default async function(process, recieved, next) { if (next.pathname) { var pkgName = next.pathname.split('/')[0]; if (!cache[pkgName] && !process.onHydration) { cache[pkgName] = await next(); } return cache[pkgName] || {}; } return { title: 'Web-Native Tooling', outline: tooling, }; }; /** * Creates and configures the rendering window. * * @param object data * @param window _window * @param function next * * @return window */ export async function render(data, _window, next) { const window = await next(); if (next.pathname && data && data.pkgName) { await packageRender(window, data); } return window; };