Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
heapwolf committed Apr 15, 2024
1 parent 299bb12 commit 09d9abd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class AppView extends Tonic {

async reloadPreviewWindows () {
if (!this.state.currentProject) return
if (this.state.currentProject.id === 'home') return

clearTimeout(this.debounce)
this.debounce = setTimeout(() => {
Expand Down Expand Up @@ -284,7 +285,7 @@ class AppView extends Tonic {
}

const subcluster = await socket.subcluster({ sharedKey: project.sharedKey })
console.log(`Initialized cluster for ${project.label}`)
// console.log(`Initialized network cluster for ${project.label}`)

subcluster.on('patch', async (value, packet) => {
if (!packet.verified) return // gtfoa
Expand Down
19 changes: 16 additions & 3 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,21 @@ export default async function (req, env, ctx) {

const p = path.join(navigatorPath, route.pathname.groups[0])
const params = url.searchParams
const res = await fetch(p)
const data = await res.text()

let data = ''

try {
const res = await fetch(p)

if (res.ok && res.status === 200) {
data = await res.text()
} else if (!res.ok || res.status === 404) {
data = '<h1>Not Found</h1>'
}
} catch (err) {
data = err.message
}

const windows = await application.getWindows()
const w = Object.values(windows)[0]

Expand Down Expand Up @@ -86,7 +99,7 @@ export default async function (req, env, ctx) {
const type = types[0]?.mime ?? ''

const headers = {
'Content-Type': type,
'Content-Type': type || 'text/html',
'Cache-Control': 'no-cache',
'Access-Control-Allow-Origin': '*'
}
Expand Down

0 comments on commit 09d9abd

Please sign in to comment.