Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: updated Hono to 3.2.7 #261

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .devcontainer/Dockerfile

This file was deleted.

44 changes: 30 additions & 14 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.1/containers/deno
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "ultra-dev",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Debian OS version: bullseye, buster
"args": {
"VARIANT": "bullseye"
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers-contrib/features/deno:1": {
"version": "1.35.0"
}
},
// This will install the vscode-deno extension
"extensions": [
"denoland.vscode-deno",
"GitHub.vscode-pull-request-github",
"eamodio.gitlens"
],
"remoteUser": "vscode"
"customizations": {
"vscode": {
"extensions": [
"denoland.vscode-deno",
"GitHub.vscode-pull-request-github",
"eamodio.gitlens"
]
}
}
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"dev": "deno run -A tools/dev.ts",
"test": "deno task test:unit && deno task test:fixture && deno task test:examples",
"test:unit": "deno test -A ./test/unit",
"test:fixture": "cd ./test/fixture && deno test -A",
"test:fixture": "deno run -A ./test/fixture.ts",
"test:examples": "deno run -A ./tools/test-examples.ts basic with-csr with-unocss with-wouter",
"version-bump:minor": "deno run -A tools/patch.ts --release=minor",
"version-bump:patch": "deno run -A tools/patch.ts --release=patch"
Expand Down
8 changes: 4 additions & 4 deletions lib/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export { StringReader } from "https://deno.land/std@0.176.0/io/string_reader.ts"

export { wait } from "https://deno.land/x/wait@0.1.12/mod.ts";

export { type Context, Hono } from "https://deno.land/x/hono@v2.5.1/mod.ts";
export { getFilePath } from "https://deno.land/x/hono@v2.5.1/utils/filepath.ts";
export { getMimeType } from "https://deno.land/x/hono@v2.5.1/utils/mime.ts";
export { logger } from "https://deno.land/x/hono@v2.5.1/middleware.ts";
export { type Context, Hono } from "https://deno.land/x/hono@v3.2.7/mod.ts";
export { getFilePath } from "https://deno.land/x/hono@v3.2.7/utils/filepath.ts";
export { getMimeType } from "https://deno.land/x/hono@v3.2.7/utils/mime.ts";
export { logger } from "https://deno.land/x/hono@v3.2.7/middleware/logger/index.ts";
12 changes: 3 additions & 9 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import type { Context as HonoContext } from "https://deno.land/x/hono@v2.5.1/mod.ts";
import type { Environment } from "https://deno.land/x/hono@v2.5.1/types.ts";
export type { Next } from "https://deno.land/x/hono@v2.5.1/types.ts";
export type { StatusCode } from "https://deno.land/x/hono@v2.5.1/utils/http-status.ts";
export type { Context } from "https://deno.land/x/hono@v3.2.7/mod.ts";
export type { Next } from "https://deno.land/x/hono@v3.2.7/types.ts";
export type { StatusCode } from "https://deno.land/x/hono@v3.2.7/utils/http-status.ts";

export type Mode = "development" | "production";

export type Context<
RequestParamKeyType extends string = string,
E extends Partial<Environment> = Environment,
> = HonoContext<RequestParamKeyType, E>;

export type CreateServerOptions = {
mode?: Mode;
/**
Expand Down
28 changes: 28 additions & 0 deletions test/fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { serve } from "https://deno.land/std@0.193.0/http/server.ts";
import { serveDir } from "https://deno.land/std@0.193.0/http/file_server.ts";
import { join } from "https://deno.land/std@0.193.0/path/mod.ts";

const abortController = new AbortController();

serve((request) => {
return serveDir(request, {
fsRoot: Deno.cwd(),
});
}, {
port: 3000,
signal: abortController.signal,
async onListen() {
const test = await new Deno.Command(Deno.execPath(), {
args: [
"test",
"-A",
],
cwd: join(Deno.cwd(), "test", "fixture"),
}).spawn();

const status = await test.status;
abortController.abort();

Deno.exit(status.code);
},
});
28 changes: 14 additions & 14 deletions test/fixture/importMap.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"imports": {
"react": "https://esm.sh/react@18.2.0?dev",
"react/": "https://esm.sh/react@18.2.0&dev/",
"react-dom": "https://esm.sh/react-dom@18.2.0?dev",
"react-dom/": "https://esm.sh/react-dom@18.2.0&dev/",
"@tanstack/react-query": "https://esm.sh/@tanstack/react-query@4.13.0?external=react",
"@tanstack/react-query-devtools": "https://esm.sh/@tanstack/react-query-devtools@4.13.0?external=react,@tanstack/react-query&dev",
"@trpc/server": "https://esm.sh/@trpc/server@10.0.0-rc.1",
"@trpc/server/": "https://esm.sh/@trpc/server@10.0.0-rc.1/",
"@trpc/client": "https://esm.sh/*@trpc/client@10.0.0-rc.1",
"@trpc/client/": "https://esm.sh/*@trpc/client@10.0.0-rc.1/",
"@trpc/react-query": "https://esm.sh/*@trpc/react-query@10.0.0-rc.1",
"react": "https://esm.sh/v122/react@18.2.0?dev",
"react/": "https://esm.sh/v122/react@18.2.0&dev/",
"react-dom": "https://esm.sh/v122/react-dom@18.2.0?dev",
"react-dom/": "https://esm.sh/v122/react-dom@18.2.0&dev/",
"@tanstack/react-query": "https://esm.sh/v122/@tanstack/react-query@4.13.0?external=react",
"@tanstack/react-query-devtools": "https://esm.sh/v122/@tanstack/react-query-devtools@4.13.0?external=react,@tanstack/react-query&dev",
"@trpc/server": "https://esm.sh/v122/@trpc/server@10.33.1",
"@trpc/server/": "https://esm.sh/v122/@trpc/server@10.33.1/",
"@trpc/client": "https://esm.sh/v122/*@trpc/client@10.33.1",
"@trpc/client/": "https://esm.sh/v122/*@trpc/client@10.33.1/",
"@trpc/react-query": "https://esm.sh/v122/*@trpc/react-query@10.33.1",
"zod": "https://deno.land/x/zod@v3.19.1/mod.ts",
"twind": "https://esm.sh/twind@0.16.17",
"twind/sheets": "https://esm.sh/twind@0.16.17/sheets",
"ultra/": "https://denopkg.com/exhibitionist-digital/ultra@main/",
"twind": "https://esm.sh/v122/twind@0.16.17",
"twind/sheets": "https://esm.sh/v122/twind@0.16.17/sheets",
"ultra/": "http://localhost:3000/",
"@ultra/qrcode/": "https://deno.land/x/qrcode@v2.0.0/"
}
}
2 changes: 2 additions & 0 deletions test/fixture/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Deno.test(
const response = await server.request("http://localhost/");
const content = await response.text();

assertEquals(response.headers.get("x-foo"), "bar");

await t.step("it can render the homepage", () => {
assertEquals(response.status, 200);
assertEquals(
Expand Down
7 changes: 6 additions & 1 deletion test/fixture/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ const server = await createServer({
browserEntrypoint: import.meta.resolve("./client.tsx"),
});

server.use("*", async (context, next) => {
context.header("x-foo", "bar");
await next();
});

server.all("/api/trpc/:path", (context) => {
return fetchRequestHandler({
endpoint: "/api/trpc",
req: context.req as Request,
req: context.req.raw,
router: appRouter,
createContext: () => ({}),
});
Expand Down