Abanob Boles
Abanob Boles
Explore posts from servers
DTDrizzle Team
Created by Abanob Boles on 8/19/2024 in #help
Migration Error - already on Production
787 | query && (query.cursorFn || query.describeFirst) && write(Sync) 788 | const error = Errors.postgres(parseError(x)) 789 | query && query.retried 790 | ? errored(query.retried) 791 | : query && query.prepared && retryRoutines.has(error.routine) 792 | ? retry(query, error) ^ PostgresError: type "bigserial" does not exist code: "42704" I use already bigserial on production, and i wanted to change other table also to bigserial, that was not a good idea. so i removed it and tryied to do a new migration. but I get this error:PostgresError: type "bigserial" does not exist My Schema is know like before, hmmm Thank you for any help
1 replies
HHono
Created by Abanob Boles on 5/15/2024 in #help
Websocket with Bun
I've tried everything but I can't get WebSockets to work with Bun, also the git issues were not helpful, does anyone have an idea ?
import { createBunWebSocket } from "hono/bun";
import wsApp from "./routes/websocket";

const { websocket } = createBunWebSocket();

type Bindings = {
ip: SocketAddress;
};

const app = new Hono<{ Bindings: Bindings }>().basePath("/v1");

app.route("/", wsApp);

const server = Bun.serve({
fetch(req, server) {
return app.fetch(req, { ip: server.requestIP(req) });
},
websocket,
});`
import { createBunWebSocket } from "hono/bun";
import wsApp from "./routes/websocket";

const { websocket } = createBunWebSocket();

type Bindings = {
ip: SocketAddress;
};

const app = new Hono<{ Bindings: Bindings }>().basePath("/v1");

app.route("/", wsApp);

const server = Bun.serve({
fetch(req, server) {
return app.fetch(req, { ip: server.requestIP(req) });
},
websocket,
});`
import { Hono } from "hono";
import { createBunWebSocket } from "hono/bun";
import { WSContext } from "hono/ws";

const { upgradeWebSocket, websocket } = createBunWebSocket();

const wsApp = new Hono();

const userSockets = new Map<string, WSContext>();

wsApp.get(
"/ws/:userId",
upgradeWebSocket((c) => {
const userId = c.req.param("userId");
return {
onOpen(event, ws) {
userSockets.set(userId, ws);
console.log(`WebSocket connection opened for user ${userId}`);
},
onMessage(event, ws) {
const message = JSON.parse(event.data.toString());
if (message.type === "checkEmailVerified") {
// ---
}
console.log(message);
ws.send("hi");
},
onClose: () => {
userSockets.delete(userId);
console.log(`WebSocket connection closed for user ${userId}`);
},
};
})
);

export default wsApp;
import { Hono } from "hono";
import { createBunWebSocket } from "hono/bun";
import { WSContext } from "hono/ws";

const { upgradeWebSocket, websocket } = createBunWebSocket();

const wsApp = new Hono();

const userSockets = new Map<string, WSContext>();

wsApp.get(
"/ws/:userId",
upgradeWebSocket((c) => {
const userId = c.req.param("userId");
return {
onOpen(event, ws) {
userSockets.set(userId, ws);
console.log(`WebSocket connection opened for user ${userId}`);
},
onMessage(event, ws) {
const message = JSON.parse(event.data.toString());
if (message.type === "checkEmailVerified") {
// ---
}
console.log(message);
ws.send("hi");
},
onClose: () => {
userSockets.delete(userId);
console.log(`WebSocket connection closed for user ${userId}`);
},
};
})
);

export default wsApp;
3 replies