subbed
subbed
DDeno
Created by subbed on 2/2/2025 in #help
deno compile optimizations
i'm relatively new to deno and find the compilation part interesting. reading the reference, it seems to bundle the deno runtime in the binary. my question is, is there anything else the compilation does? are there any form of ahead-of-time optimizations done? i'm looking into compiling my hono apps and am wondering of all the potential benefits of doing so. thank you.
2 replies
DDeno
Created by subbed on 12/15/2024 in #help
Deno error on Hono Swagger UI
Hello. I am receiving a Deno error on the following snippet:
import { randomInt } from "node:crypto";
import { type Context, Hono } from "hono";
import { logger } from "hono/logger";
import { swaggerUI } from "@hono/swagger-ui";

const rootHandler = (ctx: Context): Response => {
return ctx.json({
r256: randomInt(0, 256),
});
};

const subHandler = (ctx: Context): Response => {
return ctx.json({
sub: ctx.req.param("sub"),
r256: randomInt(0, 256),
});
};

const app = new Hono();

app.use(logger());
app.get("/ui", swaggerUI({ url: "/doc" }));

app.get("/", rootHandler);
app.get("/:sub", subHandler);

Deno.serve({ port: 3000 }, app.fetch);
import { randomInt } from "node:crypto";
import { type Context, Hono } from "hono";
import { logger } from "hono/logger";
import { swaggerUI } from "@hono/swagger-ui";

const rootHandler = (ctx: Context): Response => {
return ctx.json({
r256: randomInt(0, 256),
});
};

const subHandler = (ctx: Context): Response => {
return ctx.json({
sub: ctx.req.param("sub"),
r256: randomInt(0, 256),
});
};

const app = new Hono();

app.use(logger());
app.get("/ui", swaggerUI({ url: "/doc" }));

app.get("/", rootHandler);
app.get("/:sub", subHandler);

Deno.serve({ port: 3000 }, app.fetch);
The problematic line is apparently this one: app.get("/ui", swaggerUI({ url: "/doc" }));. The error presented during deno check is:
error: TS2769 [ERROR]: No overload matches this call.
The last overload gave the following error.
Argument of type 'MiddlewareHandler<Env>' is not assignable to parameter of type 'H<BlankEnv, "/ui", BlankInput, HandlerResponse<any>>'.
Type 'MiddlewareHandler<Env>' is not assignable to type 'MiddlewareHandler<BlankEnv, "/ui", BlankInput>'.
Types of parameters 'c' and 'c' are incompatible.
Type 'Context<BlankEnv, "/ui", BlankInput>' is not assignable to type 'Context<Env, string, {}>'.
Property '#private' in type 'Context' refers to a different member that cannot be accessed from within type 'Context'.
app.get("/ui", swaggerUI({ url: "/doc" }));
~~~~~~~~~~~~~~~~~~~~~~~~~~
at file:///home/.../dev/core/hono/src/main.ts:22:16

TS2771 [ERROR]: The last overload is declared here.
at https://jsr.io/@hono/hono/4.6.4/src/types.ts:657:60
error: TS2769 [ERROR]: No overload matches this call.
The last overload gave the following error.
Argument of type 'MiddlewareHandler<Env>' is not assignable to parameter of type 'H<BlankEnv, "/ui", BlankInput, HandlerResponse<any>>'.
Type 'MiddlewareHandler<Env>' is not assignable to type 'MiddlewareHandler<BlankEnv, "/ui", BlankInput>'.
Types of parameters 'c' and 'c' are incompatible.
Type 'Context<BlankEnv, "/ui", BlankInput>' is not assignable to type 'Context<Env, string, {}>'.
Property '#private' in type 'Context' refers to a different member that cannot be accessed from within type 'Context'.
app.get("/ui", swaggerUI({ url: "/doc" }));
~~~~~~~~~~~~~~~~~~~~~~~~~~
at file:///home/.../dev/core/hono/src/main.ts:22:16

TS2771 [ERROR]: The last overload is declared here.
at https://jsr.io/@hono/hono/4.6.4/src/types.ts:657:60
This is the imports field in my deno.json:
"imports": {
"@hono/swagger-ui": "npm:@hono/swagger-ui@0.5.0",
"hono": "jsr:@hono/hono@4.6.4"
}
"imports": {
"@hono/swagger-ui": "npm:@hono/swagger-ui@0.5.0",
"hono": "jsr:@hono/hono@4.6.4"
}
The Swagger UI example is taken directly from Hono's docs.
3 replies
DDeno
Created by subbed on 10/16/2024 in #help
how to specify lint rules in deno.json?
hello. how can i specify the deno lint rules inside the deno.json file? if that is not possible, and they can only be passed via the cli, is there some other way to specify multiple of them in a single command? i would prefer not to write 105 flags.
18 replies
DDeno
Created by subbed on 10/15/2024 in #help
deno check does not accept noImplicitReturns
hello. i have the following config inside deno.json:
{
"compilerOptions": {
"strict": true,
"noImplicitReturns": true
},
...
}
{
"compilerOptions": {
"strict": true,
"noImplicitReturns": true
},
...
}
running deno check still allows function signatures without the return type. how can i enforce the deno check to fail if no return type is present?
15 replies