fero.xd
fero.xd
Explore posts from servers
TTCTheo's Typesafe Cult
Created by fero.xd on 5/3/2024 in #questions
Weird react behaviour
I am rendering a element for every item inside of Root's children array, in that element i have a state to open or close the item (if its a dir). When someone opens a directory , i render a Nested Component that uses react query to fetch the contents of that directory and render them, and the nested component again renders the item (recursion goes on). This works fine in itself but when i have a zustand store that stores the current file and directory opened, the tree behaves in a very weird way.. the folders wont open even after multiple clicks and will randomly open on another click. It seems like updating states is fine but when the component is re rendering coz of the state change, then its causing issues https://pastebin.com/eJvbiirr
6 replies
TTCTheo's Typesafe Cult
Created by fero.xd on 4/29/2024 in #questions
Bundle type defs for a package in node_modules
I want to send type definitions for a package that is present in my node_modules folder to the frontend so that i can use it with monaco editor. The problem is how can i bundle all the types of the module into a single file. Sometimes a package has external type dependencies too, how can i handle that.
3 replies
TTCTheo's Typesafe Cult
Created by fero.xd on 3/20/2024 in #questions
Cloudflare workers: cannot import "node:events"
When running pnpm wrangler dev i get this error
Uncaught Error: Dynamic require of "node:events" is not supported
Uncaught Error: Dynamic require of "node:events" is not supported
the line that this points in the transpiled js is this
const node_events_1 = __importDefault(require("node:events"));
const node_events_1 = __importDefault(require("node:events"));
how can i fix this ?
2 replies
CDCloudflare Developers
Created by fero.xd on 3/18/2024 in #workers-help
Cannot import 'events'
When running pnpm wrangler dev i get this error
Uncaught Error: Dynamic require of "node:events" is not supported
Uncaught Error: Dynamic require of "node:events" is not supported
the line that this points in the transpiled js is this
const node_events_1 = __importDefault(require("node:events"));
const node_events_1 = __importDefault(require("node:events"));
how can i fix this ?
2 replies
CDCloudflare Developers
Created by fero.xd on 3/17/2024 in #workers-help
SynaxError: Unexpected Token export
I am trying to run my code that imports some types from "@cloudflare/workers-types" but it gives me this error
/home/----/----/node_modules/.pnpm/@cloudflare+workers-types@4.20240314.0/node_modules/@cloudflare/workers-types/index.ts:17

export declare class DOMException extends Error {
^^^^^^

SyntaxError: Unexpected token 'export'
/home/----/----/node_modules/.pnpm/@cloudflare+workers-types@4.20240314.0/node_modules/@cloudflare/workers-types/index.ts:17

export declare class DOMException extends Error {
^^^^^^

SyntaxError: Unexpected token 'export'
Its a monorepo and am using simple ts-node to run my index file. This file imports a local package that in turn imports from "cloudflare/workers-types".
8 replies
TTCTheo's Typesafe Cult
Created by fero.xd on 2/21/2024 in #questions
Kubernetes Exec with websockets
So i want to get shell access to my k8s pod from my frontend (using xterm.js) i see k8s node client has a exec method that i can use with streams, but that doesnt seem to work. Can anyone help ?
7 replies
TTCTheo's Typesafe Cult
Created by fero.xd on 11/15/2023 in #questions
Making a page static
I have my index page, it has nothing dynamic and i want this page to be statically rendered and served from the edge network. But whenever i build the app using pnpm build, next js always marks this page as dynamic(λ), am i too dumb ?
3 replies
TTCTheo's Typesafe Cult
Created by fero.xd on 11/7/2023 in #questions
WebSocket Reverse proxy
I am using this library http-proxy-middleware to hide my actual websocket server. Proxy url = 'ws"//localhost:3001' Ws server = 'ws://localhost:3000' Is there a way that when i close the proxy server, the websocket connection doesnt get closed
1 replies
TTCTheo's Typesafe Cult
Created by fero.xd on 11/5/2023 in #questions
Pusher auth server on different host
This question is related to pusher-js. I have a channel authorization server at a different physical host, i can specify the url of the server while creating new instance of Pusher, but it doesnt send cookies alongside it.
new Pusher({
cluster: "",
channelAuthorization: {
endpoint: 'http:different_host',
transport: 'ajax',
}
})
new Pusher({
cluster: "",
channelAuthorization: {
endpoint: 'http:different_host',
transport: 'ajax',
}
})
When using transport to jsonp it shows jsonp is not recognized as auth transport
2 replies
TTCTheo's Typesafe Cult
Created by fero.xd on 10/21/2023 in #questions
Nextjs
is there a way i can pass nextjs/headers to axios ?
2 replies
TTCTheo's Typesafe Cult
Created by fero.xd on 7/3/2023 in #questions
Refactor type
I got a type def -
// Clear this mess
type GeneralCondition<T extends ValidSubscription> = {
[K in T as T extends SubWithoutBroadcasterId
? never
: "broadcaster_user_id"]: string;
} & {
[K in T as T extends `user.${string}` ? UserAuthSubCondition : never]: string;
} & {
[K in T as T extends "channel.raid"
? "from_broadcaster_user_id" | "to_broadcaster_user_id"
: never]: string;
} & {
[K in T as T extends "channel.follow" | `channel.guest_star_${string}.update`
? "moderator_id"
: never]: string;
} & {
[K in T as T extends
| `channel.channel_points_custom_reward_redemption.${string}`
| `channel.channel_points_custom_reward.${"update" | "remove"}`
? "reward_id"
: never]: string;
} & {
[K in T as T extends "drop.entitlement.grant"
? DropEntitlementGrantCondition
: never]: string;
} & {
[K in T as T extends `extension.${string}`
? "extension_client_id"
: never]: string;
};
// Clear this mess
type GeneralCondition<T extends ValidSubscription> = {
[K in T as T extends SubWithoutBroadcasterId
? never
: "broadcaster_user_id"]: string;
} & {
[K in T as T extends `user.${string}` ? UserAuthSubCondition : never]: string;
} & {
[K in T as T extends "channel.raid"
? "from_broadcaster_user_id" | "to_broadcaster_user_id"
: never]: string;
} & {
[K in T as T extends "channel.follow" | `channel.guest_star_${string}.update`
? "moderator_id"
: never]: string;
} & {
[K in T as T extends
| `channel.channel_points_custom_reward_redemption.${string}`
| `channel.channel_points_custom_reward.${"update" | "remove"}`
? "reward_id"
: never]: string;
} & {
[K in T as T extends "drop.entitlement.grant"
? DropEntitlementGrantCondition
: never]: string;
} & {
[K in T as T extends `extension.${string}`
? "extension_client_id"
: never]: string;
};
ValidSubscription, DropEntitlementGrantCondition. SubWithoutBroadcasterId, UserAuthSubCondition are an union of strings Is there a way i can make this better
1 replies
TTCTheo's Typesafe Cult
Created by fero.xd on 5/31/2023 in #questions
Want to request only half of the audio file but not working
i request an audio file from my server and stream it to the browser .. on the browser i make a request to get only half of the audio file stream (i am doing total size of the file / 2 bytes) using the range header in request. the response header is something like this
Content-Range: bytes 0-5510814/11021629;
Content-Range: bytes 0-5510814/11021629;
but in the html <audio /> element i am getting the total duration of the audio as the original length of the file not the half of it i also tried to manipulate the total size of the file in the response header but still it shows the full length but the actual available audio is correct (i.e half of the original audio file)
7 replies