blurSkye πŸ‡΅πŸ‡ΈπŸ‰
blurSkye πŸ‡΅πŸ‡ΈπŸ‰
HHono
Created by jubalm on 9/9/2024 in #help
basicAuth context?
To address the issue where the context c is of type any instead of the expected type with Bindings, you need to ensure that the context type is correctly inferred. This can be done by explicitly typing the context parameter in the verifyUser function.
app.post(
'/test',
basicAuth({
verifyUser: (username, password, c: Hono.Context<{ Bindings: Env }>) => {
return (username === 'admin' && password === c.env.PASS /* <-- should autocomplete now */)
}
}),
async (c) => {
return c.body('OK')
}
)
app.post(
'/test',
basicAuth({
verifyUser: (username, password, c: Hono.Context<{ Bindings: Env }>) => {
return (username === 'admin' && password === c.env.PASS /* <-- should autocomplete now */)
}
}),
async (c) => {
return c.body('OK')
}
)
Explanation: - Explicitly type the context parameter c in the verifyUser function as Hono.Context<{ Bindings: Env }> to ensure that TypeScript correctly infers the type and provides autocompletion for c.env.PASS.
3 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
or just use nodemon like tool
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
@jamesfoleythere is no feature expected to be coming from hono team regarding live reload, you will have make a adapter that reloads live for you, thats that,, so add the solved tag
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
remove bunjs specific bits like bun.serve and shit, i suppose deno doesnt need anyh of those, it works without that
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
check hono.js docs
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
well bun is just objectively superior, it is faster, no reason i see to not use bun
16 replies
HHono
Created by thai on 8/11/2024 in #help
Websockets connected clients count
add solved tag
7 replies
HHono
Created by thai on 8/11/2024 in #help
Websockets connected clients count
unfortunately you will have manually keep track of it
7 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
No description
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
dont waste time trying different watchers like me
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
btw there is a reason it doesnt use file watcher, they somehow dont always detect changes 100% the time
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
No description
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
import { createBunWebSocket, } from 'hono/bun'
import type { UpgradeWebSocket } from './node_modules/hono/dist/types/helper/websocket';
interface BunServerWebSocket<T> {
send(data: string | ArrayBufferLike, compress?: boolean): void;
close(code?: number, reason?: string): void;
data: T;
readyState: 0 | 1 | 2 | 3;
}
interface BunWebSocketHandler<T> {
open(ws: BunServerWebSocket<T>): void;
close(ws: BunServerWebSocket<T>, code?: number, reason?: string): void;
message(ws: BunServerWebSocket<T>, message: string | Uint8Array): void;
}

export interface BunWebSocketData {
connId: number;
url: URL;
protocol: string;
}

const { upgradeWebSocket, websocket }: { upgradeWebSocket: UpgradeWebSocket, websocket: BunWebSocketHandler<BunWebSocketData> } = createBunWebSocket();

export { upgradeWebSocket, websocket };
import { createBunWebSocket, } from 'hono/bun'
import type { UpgradeWebSocket } from './node_modules/hono/dist/types/helper/websocket';
interface BunServerWebSocket<T> {
send(data: string | ArrayBufferLike, compress?: boolean): void;
close(code?: number, reason?: string): void;
data: T;
readyState: 0 | 1 | 2 | 3;
}
interface BunWebSocketHandler<T> {
open(ws: BunServerWebSocket<T>): void;
close(ws: BunServerWebSocket<T>, code?: number, reason?: string): void;
message(ws: BunServerWebSocket<T>, message: string | Uint8Array): void;
}

export interface BunWebSocketData {
connId: number;
url: URL;
protocol: string;
}

const { upgradeWebSocket, websocket }: { upgradeWebSocket: UpgradeWebSocket, websocket: BunWebSocketHandler<BunWebSocketData> } = createBunWebSocket();

export { upgradeWebSocket, websocket };
16 replies
HHono
Created by jamesfoley on 8/12/2024 in #help
Live Reload With Deno
i made something like that for bun.js
16 replies
HHono
Created by rubberduckies on 6/29/2024 in #help
middleware redirect from HTTPS to HTTP
can you not enable force acme or something on your reverse proxy server(for example in nginx)?
5 replies
HHono
Created by blurSkye πŸ‡΅πŸ‡ΈπŸ‰ on 6/7/2024 in #help
websocket issue
one of the interfaces needed for websocket wasnt exported sooo i copied all the interfaces needed πŸ’€
25 replies
HHono
Created by blurSkye πŸ‡΅πŸ‡ΈπŸ‰ on 6/7/2024 in #help
websocket issue
you need a file that defines websocket, and import upgradeWebSocket in the routes and import websocket to serve in the main.ts file
25 replies
HHono
Created by blurSkye πŸ‡΅πŸ‡ΈπŸ‰ on 6/7/2024 in #help
websocket issue
ok found a way, damn how did i not think of this πŸ’€
import { createBunWebSocket, } from 'hono/bun'
import type { UpgradeWebSocket } from './node_modules/hono/dist/types/helper/websocket';
interface BunServerWebSocket<T> {
send(data: string | ArrayBufferLike, compress?: boolean): void;
close(code?: number, reason?: string): void;
data: T;
readyState: 0 | 1 | 2 | 3;
}
interface BunWebSocketHandler<T> {
open(ws: BunServerWebSocket<T>): void;
close(ws: BunServerWebSocket<T>, code?: number, reason?: string): void;
message(ws: BunServerWebSocket<T>, message: string | Uint8Array): void;
}

interface BunWebSocketData {
connId: number;
url: URL;
protocol: string;
}

const { upgradeWebSocket, websocket }: { upgradeWebSocket: UpgradeWebSocket, websocket: BunWebSocketHandler<BunWebSocketData> } = createBunWebSocket();

export { upgradeWebSocket, websocket };
import { createBunWebSocket, } from 'hono/bun'
import type { UpgradeWebSocket } from './node_modules/hono/dist/types/helper/websocket';
interface BunServerWebSocket<T> {
send(data: string | ArrayBufferLike, compress?: boolean): void;
close(code?: number, reason?: string): void;
data: T;
readyState: 0 | 1 | 2 | 3;
}
interface BunWebSocketHandler<T> {
open(ws: BunServerWebSocket<T>): void;
close(ws: BunServerWebSocket<T>, code?: number, reason?: string): void;
message(ws: BunServerWebSocket<T>, message: string | Uint8Array): void;
}

interface BunWebSocketData {
connId: number;
url: URL;
protocol: string;
}

const { upgradeWebSocket, websocket }: { upgradeWebSocket: UpgradeWebSocket, websocket: BunWebSocketHandler<BunWebSocketData> } = createBunWebSocket();

export { upgradeWebSocket, websocket };
25 replies