Lazuee
Lazuee
Explore posts from servers
HHono
Created by Lazuee on 10/19/2024 in #help
Context is not finalized
No description
8 replies
HHono
Created by Lazuee on 10/19/2024 in #help
Context is not finalized
await requestHandler(c.req.raw, loadContext instanceof Promise ? await loadContext : loadContext);
await requestHandler(c.req.raw, loadContext instanceof Promise ? await loadContext : loadContext);
this is the cause of the error and it didn't catch any error when I do try-catch. Also, the response is okay but i'm wondering why do i get Context is not finalized?
8 replies
HHono
Created by Lazuee on 10/19/2024 in #help
Context is not finalized
// index.ts
import { Hono } from "hono";
import { logger } from "hono/logger";
import { reactRouter } from "./middleware";
import routes from "./routes";

declare module "react-router" {
export interface AppLoadContext {
readonly nonce?: string;
readonly clientIp?: string;
readonly env: typeof env;
}
}
declare module "react-router" {
interface LoaderFunctionArgs {
context: AppLoadContext;
}
}

const createServer = async () => {
const build = await getServerBuild();
const app = new Hono().use(
logger(),
reactRouter({
build,
mode: env.IS_PRODUCTION_BUILD ? "production" : "development",
getLoadContext: (ctx) => ({
clientIp: ctx.var.clientIp,
nonce: ctx.var.nonce,
env: env,
}),
}),
)
// index.ts
import { Hono } from "hono";
import { logger } from "hono/logger";
import { reactRouter } from "./middleware";
import routes from "./routes";

declare module "react-router" {
export interface AppLoadContext {
readonly nonce?: string;
readonly clientIp?: string;
readonly env: typeof env;
}
}
declare module "react-router" {
interface LoaderFunctionArgs {
context: AppLoadContext;
}
}

const createServer = async () => {
const build = await getServerBuild();
const app = new Hono().use(
logger(),
reactRouter({
build,
mode: env.IS_PRODUCTION_BUILD ? "production" : "development",
getLoadContext: (ctx) => ({
clientIp: ctx.var.clientIp,
nonce: ctx.var.nonce,
env: env,
}),
}),
)
// middleware/react-router.ts
import { createRequestHandler } from "react-router";

import type { AppLoadContext, ServerBuild } from "react-router";
import { type Context, type Env } from "hono";
import { createMiddleware } from "hono/factory";

export interface RemixMiddlewareOptions {
build: ServerBuild;
mode?: "development" | "production";
getLoadContext?(c: Context): Promise<AppLoadContext> | AppLoadContext;
}
export function reactRouter<TEnv extends Env>({ build, mode, getLoadContext }: RemixMiddlewareOptions) {
const requestHandler = createRequestHandler(build, mode);
return createMiddleware<TEnv>(async (c) => {
const loadContext = getLoadContext?.(c);
return await requestHandler(c.req.raw, loadContext instanceof Promise ? await loadContext : loadContext);
// ^^ the cause of error,.
});
}
// middleware/react-router.ts
import { createRequestHandler } from "react-router";

import type { AppLoadContext, ServerBuild } from "react-router";
import { type Context, type Env } from "hono";
import { createMiddleware } from "hono/factory";

export interface RemixMiddlewareOptions {
build: ServerBuild;
mode?: "development" | "production";
getLoadContext?(c: Context): Promise<AppLoadContext> | AppLoadContext;
}
export function reactRouter<TEnv extends Env>({ build, mode, getLoadContext }: RemixMiddlewareOptions) {
const requestHandler = createRequestHandler(build, mode);
return createMiddleware<TEnv>(async (c) => {
const loadContext = getLoadContext?.(c);
return await requestHandler(c.req.raw, loadContext instanceof Promise ? await loadContext : loadContext);
// ^^ the cause of error,.
});
}
8 replies
HHono
Created by Lazuee on 10/19/2024 in #help
Context is not finalized
8 replies
DIAdiscord.js - Imagine an app
Created by Lazuee on 8/7/2023 in #djs-questions
SlashCommandBuilder#addStringOption: set(Min/Max)Length is unnecessary when using setChoices
setMinLength and setMaxLength should NOT be use when using setChoices.. setMinLength and setMaxLength should be omitted on the addStringOption typings when using setChoices..
6 replies
DIAdiscord.js - Imagine an app
Created by Lazuee on 8/7/2023 in #djs-questions
SlashCommandBuilder#addStringOption: set(Min/Max)Length is unnecessary when using setChoices
oooh,. setMinLength and setMaxLength validates the setChoices value length. my bad
6 replies
DIAdiscord.js - Imagine an app
Created by Lazuee on 8/7/2023 in #djs-questions
SlashCommandBuilder#addStringOption: set(Min/Max)Length is unnecessary when using setChoices
If it's really unnecessary then setMinLength and setMaxLength should be omitted when using setChoices on the typings.
6 replies
DIAdiscord.js - Imagine an app
Created by Lazuee on 8/6/2023 in #djs-questions
Type 'X' is not comparable to type 'APIApplicationCommandOption'.
it should be option.type not option
6 replies
DIAdiscord.js - Imagine an app
Created by Lazuee on 8/6/2023 in #djs-questions
Type 'X' is not comparable to type 'APIApplicationCommandOption'.
6 replies
DIAdiscord.js - Imagine an app
Created by Lazuee on 8/6/2023 in #djs-questions
Type 'X' is not comparable to type 'APIApplicationCommandOption'.
6 replies
DIAdiscord.js - Imagine an app
Created by Lazuee on 8/6/2023 in #djs-questions
Type 'X' is not comparable to type 'APIApplicationCommandOption'.
discord.js: 14.12.1 node: v18.16.1
6 replies