Huge Letters
Huge Letters
Explore posts from servers
HHono
Created by Huge Letters on 6/22/2024 in #help
How to resolve relative routes
how?( i've tried / but dont see the command
10 replies
HHono
Created by Huge Letters on 6/22/2024 in #help
How to resolve relative routes
but i kinda wish this was a built-in it makes sense I would want to declare relative routes which can then be resolved to the absolute ones - my router shouldnt know where and which route it was mounted to - and I should be able to just do resolveRoute("/") and it would give me the absolute route
10 replies
HHono
Created by Huge Letters on 6/22/2024 in #help
How to resolve relative routes
/**
* Wrap your router with this function and a `basePath` var will be exposed to all of your routes.
* Base path is whatever the full path this router has been assigned to.
*
* @example
* new Hono().route(
* '/a',
* new Hono().route(
* '/b',
* withBasePath(new Hono()).get('/c', (c) => c.var.basePath // "/a/b"
* )));
*/
export function withBasePath<THono extends Hono>(app: THono) {
return app
.use(
':*{.*}',
createMiddleware<{
Variables: {
/** This will be undefined on index routes because they do not trigger this middleware */
basePath?: string;
};
}>((c, next) => {
const rest = c.req.param('*');
const path = c.req.path;

const basePath = rest ? path.replace(new RegExp(`${rest}$`), '') : path;

c.set('basePath', basePath);
return next();
}),
)
.use<{ Variables: { basePath: string } }>((c, next) => {
c.set('basePath', c.var.basePath ?? c.req.path);
return next();
});
}
/**
* Wrap your router with this function and a `basePath` var will be exposed to all of your routes.
* Base path is whatever the full path this router has been assigned to.
*
* @example
* new Hono().route(
* '/a',
* new Hono().route(
* '/b',
* withBasePath(new Hono()).get('/c', (c) => c.var.basePath // "/a/b"
* )));
*/
export function withBasePath<THono extends Hono>(app: THono) {
return app
.use(
':*{.*}',
createMiddleware<{
Variables: {
/** This will be undefined on index routes because they do not trigger this middleware */
basePath?: string;
};
}>((c, next) => {
const rest = c.req.param('*');
const path = c.req.path;

const basePath = rest ? path.replace(new RegExp(`${rest}$`), '') : path;

c.set('basePath', basePath);
return next();
}),
)
.use<{ Variables: { basePath: string } }>((c, next) => {
c.set('basePath', c.var.basePath ?? c.req.path);
return next();
});
}
improved it a bit and turned into a more reusable middleware kinda
10 replies
HHono
Created by Huge Letters on 6/22/2024 in #help
How to resolve relative routes
well of course I would solve it after posting this
.get(':p{.*}', (c) => {
const url = c.req.path.replace(c.req.param('p') ?? '', '');
return c.render(
<div>
not found. <a href={url}>go to homepage</a>
</div>,
);
})
.get(':p{.*}', (c) => {
const url = c.req.path.replace(c.req.param('p') ?? '', '');
return c.render(
<div>
not found. <a href={url}>go to homepage</a>
</div>,
);
})
hope someone would enjoy the meme at least...
10 replies
HHono
Created by Huge Letters on 6/22/2024 in #help
How to resolve relative routes
hope that helps me get an answer faster...
10 replies
DTDrizzle Team
Created by Vinny on 4/8/2024 in #help
Using sql.placeholder with limit in creating a prepared query
you could put as never there for now to test it
14 replies
DTDrizzle Team
Created by Vinny on 4/8/2024 in #help
Using sql.placeholder with limit in creating a prepared query
does it work tho? is it just a typescript error or query also doesn't work? if it's only a TS problem it's pretty easy fix - you could patch it temporarily while waiting for an update
14 replies
DTDrizzle Team
Created by Vinny on 4/8/2024 in #help
Using sql.placeholder with limit in creating a prepared query
so I think you can file an issue on gh
14 replies
DTDrizzle Team
Created by Vinny on 4/8/2024 in #help
Using sql.placeholder with limit in creating a prepared query
No description
14 replies
DTDrizzle Team
Created by Vinny on 4/8/2024 in #help
Using sql.placeholder with limit in creating a prepared query
No description
14 replies
DTDrizzle Team
Created by Headless on 4/8/2024 in #help
Issues with NextJS + Turso + DrizzleORM + LuciaAuth
i would check your nextjs(or webpack?) config first - maybe there is some setting to parse .md files(however your logs also indicate license files to be compiled) and it wasn't properly set up and this issue popped up now if not - i would ask in nextjs repo/discord server first. seems more like their issue than libsql
13 replies
DTDrizzle Team
Created by Vinny on 4/8/2024 in #help
Using sql.placeholder with limit in creating a prepared query
what drizzle version and driver are you using? i've tried this just now on the latest version with sqlite - no issues
14 replies
DTDrizzle Team
Created by Headless on 4/8/2024 in #help
Issues with NextJS + Turso + DrizzleORM + LuciaAuth
well it seems like nextjs is trying to compile readme files lol so this is either a nextjs or libsql client issue - either something wrong with nextjs build system or libsql client provides incorrect export maybe i dunno
13 replies
DTDrizzle Team
Created by tsuki on 4/8/2024 in #help
trying to create a trigger on supabase to calculate a winrate based on two other columns
btw even tho this is unwarranted advice - is winrate column even needed? you could always compute it pretty easily on demand from the other two, no?
6 replies
DTDrizzle Team
Created by tsuki on 4/8/2024 in #help
trying to create a trigger on supabase to calculate a winrate based on two other columns
you are dividing two ints - you get an int as a result(rounded down). 6 / (6 + 4) * 100 -> 6 / 10 * 100 -> 0 * 100 multiply new.wins by 1.0 (not just 1) - should help. or do a coalesce to float on one of columns new.winrate = ((1.0 * new.wins) / (new.wins + new.losses)) * 100;
6 replies
DTDrizzle Team
Created by Null on 4/8/2024 in #help
Using drizzle in docker gives [i] No changes detected
also try checking what's inside of var/Bun/drizzle where your migrations are - perhaps your image already has them?
4 replies
DTDrizzle Team
Created by Null on 4/8/2024 in #help
Using drizzle in docker gives [i] No changes detected
sorry, since you're using bun so use their alternatives - pretty sure they have something similar as well
4 replies
DTDrizzle Team
Created by Null on 4/8/2024 in #help
Using drizzle in docker gives [i] No changes detected
try logging process.cwd() and readDir of schema folder maybe from node inside drizzle.config.ts - I think it would make it more clear if inside the image this path is correct or not
4 replies