capo_greco
capo_greco
DDeno
Created by capo_greco on 5/6/2024 in #help
localhost workflow for BroadcastChannel?
How would one go about setting up a (multiple?) localhost workflow for implementing / testing BroadcastChannel things?
2 replies
DDeno
Created by capo_greco on 4/12/2024 in #help
Fresh: front end import map goes where?
hey team - I am trying to use threejs in my blog posts I am using this blog template: https://github.com/capogreco/blog_template where would I put an import map for front end javascript module imports? I tried putting one in the PostPage function in [slug].tsx but I don't think it likes having JSON in the JSX ? error: Uncaught (in promise) TypeError: The module's source code could not be parsed: Expected '}', got ':'
11 replies
DDeno
Created by capo_greco on 1/19/2024 in #help
Can I add properties to a websocket object?
No description
13 replies
DDeno
Created by capo_greco on 1/15/2023 in #help
deno blog without html sanitization
I want to be able to javascript Canvas API things in my blog - surely this is possible?
3 replies
DDeno
Created by capo_greco on 9/23/2022 in #help
serving two static folders and connecting to both with websockets
A lot of the youtube and medium resources available on setting serving static folders, and on setting up a websockets server, seem to be using patterns that are not compatible with each other / not harmonious with the latest version of std etc. I have a few stumbling blocks. The first is to serve my 'public' folder to the url, and serve another folder, called 'control', to URL/control, but within the one serve () call. Using a switch statement seems to break everything and I don't really understand why. Eg,
const servePublic = req => staticFiles ('public') ({
request: req,
respondWith: r => r
})

serve (req => servePublic (req), { addr: ':80' })
const servePublic = req => staticFiles ('public') ({
request: req,
respondWith: r => r
})

serve (req => servePublic (req), { addr: ':80' })
... works, whereas:
// serve public
const servePublic = req => staticFiles ('public') ({
request: req,
respondWith: r => r
})

// serve control
const serveControl = req => staticFiles (`control`) ({
request: req,
respondWith: r => r
})

serve (req => {
const url = new URL(req.url);
console.log (url.pathname)

switch (url.pathname) {
case `/control`:
return serveControl (req)
case `/`:
return servePublic (req)
}
}, { addr: ':80' })
// serve public
const servePublic = req => staticFiles ('public') ({
request: req,
respondWith: r => r
})

// serve control
const serveControl = req => staticFiles (`control`) ({
request: req,
respondWith: r => r
})

serve (req => {
const url = new URL(req.url);
console.log (url.pathname)

switch (url.pathname) {
case `/control`:
return serveControl (req)
case `/`:
return servePublic (req)
}
}, { addr: ':80' })
... does not. I feel like I am missing something vital.
Then there is websockets - trying to work out how to marry Deno.upgradeWebSocket with this serve pattern. I had gotten them all working on localhost, but Deno Deploy needs for there to be only one listener, I think
3 replies