Augustin Sorel
Augustin Sorel
Explore posts from servers
HHono
Created by Augustin Sorel on 9/4/2024 in #help
server static file + caching
Hey guys, I am serving a static folder called public and it's all working well, I can access my files, eg styles.css. Here is the code for it:
app
.use("*", validateRequest)
.use("/public/*", serveStatic({ root: "./" }))
app
.use("*", validateRequest)
.use("/public/*", serveStatic({ root: "./" }))
However I didn't realize that hono wasn't caching the assets in /public by default. Is there any way to tell hono to cache that directory ?
15 replies
HHono
Created by Augustin Sorel on 8/10/2024 in #help
Error per route
Hello everyone, this is a very basic question but I couldn't find any help online. I was just wondering if it was possible to have any error handling callback per route. For example with this code, how would you handle this error only for this route ? I know I can use .onError but that would be global right ? Any help is very much appricated 🙌
app.get('/idk', (c)=>{
if(Math.random()>0.5){
throw new Error('idk')
}
return c.text('success', 200);
})
app.get('/idk', (c)=>{
if(Math.random()>0.5){
throw new Error('idk')
}
return c.text('success', 200);
})
7 replies