Blankeos
Blankeos
Explore posts from servers
HHono
Created by Blankeos on 6/22/2024 in #help
Have you guys ever gotten websockets to work on Hono + `@hono/vite-dev-server` plugin?
This occurs for Bun and Node. 1. On Bun, I can serve websockets using import { createBunWebSocket } from 'hono/bun'; https://github.com/honojs/vite-plugins/issues/148 2. On Node, I can serve websockets using ws and import { serve } from '@hono/node-server' __ But the issues are: 1. On Bun, the websocket handler gets stuck. No idea why: https://github.com/honojs/vite-plugins/issues/140. Had some hypothesis that it conflicts with vite, but not too sure. 2. On Node, I can't even run the websocket handler because the mechanism is completely different when running it in dev. In particular, you'd have to get the server first, then attach it there.
5 replies
HHono
Created by Blankeos on 5/17/2024 in #help
Proper error logging and tracing?
Do you guys have an example repo that properly sets up error logs and trace? It seems too difficult to trace here (in the image). As you can see it only traces back to the library-code that threw the error. I kinda have to to manually trace which function actually threw that error in my code. Which was around here:
// src/server/s3.ts
export async function transferFileFromTempToPermanent(uniqueId: string) {
const oldKey = `temp/${uniqueId}`;
const newKey = `permanent/${uniqueId}`;

// Copy the object to the new location.
await s3Client.send(
new CopyObjectCommand({
Bucket: privateConfig.s3.BUCKET_NAME,
CopySource: `${privateConfig.s3.BUCKET_NAME}/${oldKey}`,
Key: newKey,
})
);

// Delete from old location.
await s3Client.send(
new DeleteObjectCommand({
Bucket: privateConfig.s3.BUCKET_NAME,
Key: oldKey,
})
);
// src/server/s3.ts
export async function transferFileFromTempToPermanent(uniqueId: string) {
const oldKey = `temp/${uniqueId}`;
const newKey = `permanent/${uniqueId}`;

// Copy the object to the new location.
await s3Client.send(
new CopyObjectCommand({
Bucket: privateConfig.s3.BUCKET_NAME,
CopySource: `${privateConfig.s3.BUCKET_NAME}/${oldKey}`,
Key: newKey,
})
);

// Delete from old location.
await s3Client.send(
new DeleteObjectCommand({
Bucket: privateConfig.s3.BUCKET_NAME,
Key: oldKey,
})
);
2 replies
HHono
Created by Blankeos on 5/1/2024 in #help
When there's an error on my typescript code on Hono, Vite Dev Server crashes, and doesn't restart
Problem: - Error? Crash the dev server and not wait for file changes. Ideal experience: - Error? Say it's an error and wait for file changes. It kinda feels iffy that I need to run npm run dev again just to run the dev server. Any fixes for this or maybe just something I missed? My config looks like this:
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import Icons from "unplugin-icons/vite";
import { defineConfig } from "vite";

// Vike
import vike from "vike/plugin";
import vikeSolid from "vike-solid/vite";

// Hono
import devServer from "@hono/vite-dev-server";

// Vite
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const root = resolve(__dirname, ".");

export default defineConfig({
plugins: [
vike(),
vikeSolid(),
devServer({
entry: "./src/server/index.ts",
exclude: [
/^\/@.+$/,
/.*\.(ts|tsx|vue)($|\?)/,
/.*\.(s?css|less)($|\?)/,
/^\/favicon\.ico$/,
/.*\.(svg|png)($|\?)/,
/^\/(public|assets|static)\/.+/,
/^\/node_modules\/.*/,
],
injectClientScript: false,
}),
Icons({
compiler: "solid",
}),
],
server: {
port: 3000,
},
preview: {
port: 3000,
},
resolve: {
alias: {
"@": resolve(root, "src"),
},
},
});
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import Icons from "unplugin-icons/vite";
import { defineConfig } from "vite";

// Vike
import vike from "vike/plugin";
import vikeSolid from "vike-solid/vite";

// Hono
import devServer from "@hono/vite-dev-server";

// Vite
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const root = resolve(__dirname, ".");

export default defineConfig({
plugins: [
vike(),
vikeSolid(),
devServer({
entry: "./src/server/index.ts",
exclude: [
/^\/@.+$/,
/.*\.(ts|tsx|vue)($|\?)/,
/.*\.(s?css|less)($|\?)/,
/^\/favicon\.ico$/,
/.*\.(svg|png)($|\?)/,
/^\/(public|assets|static)\/.+/,
/^\/node_modules\/.*/,
],
injectClientScript: false,
}),
Icons({
compiler: "solid",
}),
],
server: {
port: 3000,
},
preview: {
port: 3000,
},
resolve: {
alias: {
"@": resolve(root, "src"),
},
},
});
2 replies