function ResourceItem({ name, length }) {
return `
/${name}
${length ? `${length}x` : 'object'}
`
}
function ResourceList({ db }) {
return `
${Object.keys(db)
.map((name) =>
ResourceItem({
name,
length: Array.isArray(db[name]) && db[name].length,
}),
)
.join('')}
`
}
function NoResources() {
return `No resources found
`
}
function ResourcesBlock({ db }) {
return `
Resources
${Object.keys(db).length ? ResourceList({ db }) : NoResources()}
`
}
window
.fetch('db')
.then((response) => response.json())
.then(
(db) =>
(document.getElementById('resources').innerHTML = ResourcesBlock({ db })),
)
function CustomRoutesBlock({ customRoutes }) {
const rules = Object.keys(customRoutes)
if (rules.length) {
return `
Custom Routes
${rules
.map(
(rule) =>
`
${rule} |
⇢ ${customRoutes[rule]} |
`,
)
.join('')}
`
}
}
window
.fetch('__rules')
.then((response) => response.json())
.then(
(customRoutes) =>
(document.getElementById('custom-routes').innerHTML = CustomRoutesBlock({
customRoutes,
})),
)