JavaDad
JavaDad
Explore posts from servers
CDCloudflare Developers
Created by JavaDad on 4/15/2024 in #workers-help
Can not enable Log Push
Tried logout and login and no @Lubo I have not. I resorted to using a Tail worker which sends messages to my chat app… not ideal since it’s very noisy.
3 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
Yeah I think this would make sense. And if you don’t pass the generic then it just stays as any, that shouldn’t be breaking?
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
The docs here seem to indicate there is a way to do this though - https://hono.dev/api/context#contextvariablemap
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
Its only an issue when you are trying to type variables in existing middleware
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
not jwt
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
But the middelware JWT plugin sets a variable called jwtPayload
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
Yes this works
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
it also requires anywhere in the code that c.get() is used for the developer to know what type they should be expecting as there will be no inference
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
as CustomType will work because I am casting the result but this isn't exactly type safe because if the type changes or is unexpexted this won't catch it or give any errors.
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
The types are not throwing errors this way, they are just not being inferred. If I check the type of id from the jwtPayload its type is any
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
@Nico here is the thread, thanks!
23 replies
HHono
Created by JavaDad on 4/10/2024 in #help
Typing Middleware JWT and others
// ====================================

// types.ts

export type Bindings = {
DATABASE_URL: string;
DATABASE_AUTH_TOKEN: string;
GOOGLE_AUTH_CLIENT_ID: string;
GOOGLE_AUTH_CLIENT_SECRET: string;
SERVER_URL: string;
CLIENT_URL: string;
};

export type Variables = {
token: {
token: string;
expires_in: number;
};
"granted-scopes": string[];
"user-google": GoogleUserInfo;
};

export type JWTPayload = {
id: string;
email: string;
name: string;
profilePicture: string;
role: Role;
};
// ====================================

// types.ts

export type Bindings = {
DATABASE_URL: string;
DATABASE_AUTH_TOKEN: string;
GOOGLE_AUTH_CLIENT_ID: string;
GOOGLE_AUTH_CLIENT_SECRET: string;
SERVER_URL: string;
CLIENT_URL: string;
};

export type Variables = {
token: {
token: string;
expires_in: number;
};
"granted-scopes": string[];
"user-google": GoogleUserInfo;
};

export type JWTPayload = {
id: string;
email: string;
name: string;
profilePicture: string;
role: Role;
};
23 replies
DTDrizzle Team
Created by JavaDad on 12/22/2023 in #help
How to select part of a string in Drizzle?
Update: Seems like this is the solution.
const timers = await db
.select()
.from(timerSchema)
.where(sql`timer_date like ${`%${queryDayString}%`}`);
const timers = await db
.select()
.from(timerSchema)
.where(sql`timer_date like ${`%${queryDayString}%`}`);
4 replies
CDCloudflare Developers
Created by JavaDad on 4/28/2023 in #pages-help
Cloudflare Pages Function CORS error
That seems to work if I just return the headers in every Response! Thank you so much.
4 replies
CDCloudflare Developers
Created by JavaDad on 3/1/2023 in #workers-help
Can't Work with Queues and D1 in the same project
cc @massadas
3 replies
CDCloudflare Developers
Created by JavaDad on 3/1/2023 in #workers-help
Can't Work with Queues and D1 in the same project
Ill open this issue with workers-qb, this is good to know, thank you!
3 replies
CDCloudflare Developers
Created by JavaDad on 1/27/2023 in #workers-help
How to bind to services
@Cyb3r-Jok3 thanks, this lead me in the correct direction. For anyone else that gets this error, you have to make sure the name in the TypeScript interface matches your binding name. This example helped me figure that out. https://developers.cloudflare.com/d1/get-started/#write-queries-within-your-worker In my wrangler.toml my binding was DB but in the TypeScript interface I had DATABASE
8 replies