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
DTDrizzle Team
Created by Augustin Sorel on 5/22/2024 in #help
Order by in a query clause
Hey guys, I am trying to retrieve a list of exercises and it's data + grid position (join) from my database. I also want this array of result to be ordered by it's grid position. Here is what I came up with (the following code works just fine however notice the javascript .sort rather than using the drizzle orderBy).
const getExercises = () =>{
return (
await ctx.db.query.exercises.findMany({
with: {
data: { orderBy: (data, { asc }) => [asc(data.doneAt)] },
position: true,
},
})
).sort((a, b) => b.position.gridPosition - a.position.gridPosition);
//^ how could I move this logic to an orderBy clause ?
}
const getExercises = () =>{
return (
await ctx.db.query.exercises.findMany({
with: {
data: { orderBy: (data, { asc }) => [asc(data.doneAt)] },
position: true,
},
})
).sort((a, b) => b.position.gridPosition - a.position.gridPosition);
//^ how could I move this logic to an orderBy clause ?
}
So how could I order my final result by it's grid position ? I have tried the following but without any luck:
const getExercises = () =>{
return (
await ctx.db.query.exercises.findMany({
with: {
data: { orderBy: (data, { asc }) => [asc(data.doneAt)] },
position: true,
},
orderBy: () => sql`exercises.grid_position`,
})
);
}
const getExercises = () =>{
return (
await ctx.db.query.exercises.findMany({
with: {
data: { orderBy: (data, { asc }) => [asc(data.doneAt)] },
position: true,
},
orderBy: () => sql`exercises.grid_position`,
})
);
}
2 replies
DTDrizzle Team
Created by Augustin Sorel on 10/5/2023 in #help
Drizzle update enum
No description
1 replies