DangerZone
DangerZone
Explore posts from servers
HHono
Created by DangerZone on 11/6/2024 in #help
is the client component `render` method hydration?
Hey I was wondering if the client components render function was actually hydrating the UI. Thanks for the answer!
1 replies
CDCloudflare Developers
Created by DangerZone on 11/5/2024 in #workers-help
Connect a worker to AWS VPC via Tunnel
Hello, is it possible to connect a Cloudflare worker to my AWS VPC through a Cloudflare tunnel? I haven't seen any documentation about this other than the statement that a tunnel connects a private network to cloudflare network which sounds like it could allow workers send requests to an endpoint within my AWS VPC. Is that possible? and if yes, is there any documentation on how we can enable it?
1 replies
CDCloudflare Developers
Created by DangerZone on 10/15/2024 in #workers-help
Does a worker has access to bulk KV writes?
I want to create a worker that serves as a proxy to KV, specifically for the bulk writes. Can I use the bulk operations within the KV bindings?
10 replies
CDCloudflare Developers
Created by DangerZone on 10/14/2024 in #workers-help
Accessing Remote R2 while having local assets
Hey, I am trying to build a worker that can access my remote R2 buckets, but still have local static assets to serve. From my research it looks like its common to have an R2 assets bucket to solve this issue, but because multiple develpers are going to work on this worker, we don't want them to share the same assets bucket. Our current limitations: - We can't seed the local R2 since our data set is too big, and we need to know which data is seeded specifically across tens of buckets. - We can't have a remote assets folder since we don't want engineers to share them. - We can't have local assets with wrangler dev --remotesince it throws an error:
[ERROR] Cannot use assets in remote mode. Workers with assets are only supported in local mode. Please use `wrangler dev`.
[ERROR] Cannot use assets in remote mode. Workers with assets are only supported in local mode. Please use `wrangler dev`.
Whats should we do?
7 replies
CDCloudflare Developers
Created by DangerZone on 10/14/2024 in #workers-help
Cannot use assets in remote mode
Hello, I want to use an assets folder within my worker, on wrangler dev everything serves as expected, but when I am adding the --remote flag to the command I am getting this error:
[ERROR] Cannot use assets in remote mode. Workers with assets are only supported in local mode. Please use `wrangler dev`.
[ERROR] Cannot use assets in remote mode. Workers with assets are only supported in local mode. Please use `wrangler dev`.
I am trying to run the local worker with access remote R2 buckets, is there a way to do that with my assets folder? My Toml assets configuration:
assets = { directory = "./public/", binding = "ASSETS" }
assets = { directory = "./public/", binding = "ASSETS" }
3 replies
TtRPC
Created by DangerZone on 7/3/2024 in #❓-help
Property 'error' does not exist on type 'MiddlewareOKResult<any>'.
Hello, I am building an trpc adapter for nestjs, and I am trying to extend some of trpc's functionality, specifically the procedure middleware by creating a procedure class.
import {
type DataTransformerOptions,
type RootConfig,
type unsetMarker,
} from '@trpc/server';

import type { MiddlewareFunction } from '@trpc/server/src/core/middleware';

type ProcedureParams<Context = any> = {
_config: RootConfig<{
ctx: object & Context;
meta: object;
errorShape: never;
transformer: DataTransformerOptions;
}>;
_ctx_out: object & Context;
_input_in: typeof unsetMarker;
_input_out: typeof unsetMarker;
_output_in: typeof unsetMarker;
_output_out: typeof unsetMarker;
_meta: object;
}

export interface TRPCProcedure<Context = object> {
use: MiddlewareFunction<ProcedureParams<Context>, ProcedureParams<Context>>
}
import {
type DataTransformerOptions,
type RootConfig,
type unsetMarker,
} from '@trpc/server';

import type { MiddlewareFunction } from '@trpc/server/src/core/middleware';

type ProcedureParams<Context = any> = {
_config: RootConfig<{
ctx: object & Context;
meta: object;
errorShape: never;
transformer: DataTransformerOptions;
}>;
_ctx_out: object & Context;
_input_in: typeof unsetMarker;
_input_out: typeof unsetMarker;
_output_in: typeof unsetMarker;
_output_out: typeof unsetMarker;
_meta: object;
}

export interface TRPCProcedure<Context = object> {
use: MiddlewareFunction<ProcedureParams<Context>, ProcedureParams<Context>>
}
I am using the MiddlewareFunction here so it will provide the correct opts implementation. Everything works perfectly, but when I am trying to run it, I am getting a typescript error:
../../node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/src/core/internals/procedureBuilder.ts:387:20 - error TS2339: Property 'error' does not exist on type 'MiddlewareResult<any>'.
Property 'error' does not exist on type 'MiddlewareOKResult<any>'.

387 throw result.error;
~~~~~

../../node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/src/deprecated/internals/procedure.ts:244:20 - error TS2339: Property 'error' does not exist on type 'MiddlewareResult<any>'.
Property 'error' does not exist on type 'MiddlewareOKResult<any>'.

244 throw result.error;
~~~~~

[6:26:38 PM] Found 2 errors. Watching for file changes.
../../node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/src/core/internals/procedureBuilder.ts:387:20 - error TS2339: Property 'error' does not exist on type 'MiddlewareResult<any>'.
Property 'error' does not exist on type 'MiddlewareOKResult<any>'.

387 throw result.error;
~~~~~

../../node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/src/deprecated/internals/procedure.ts:244:20 - error TS2339: Property 'error' does not exist on type 'MiddlewareResult<any>'.
Property 'error' does not exist on type 'MiddlewareOKResult<any>'.

244 throw result.error;
~~~~~

[6:26:38 PM] Found 2 errors. Watching for file changes.
Anyone has an idea of how to solve this? I thought about using the ProcedureBuilder interface but couldn't make it to work.
1 replies
TTCTheo's Typesafe Cult
Created by DangerZone on 6/27/2024 in #questions
Creaete T3 No Req or Res in TRPC context
I am trying to integrate clerk with the trpc create context, but the createContext generated by create-3t isn't passing the req or res of the request. What can I do?
8 replies
TtRPC
Created by DangerZone on 6/16/2024 in #❓-help
Validating inputs and outputs only via typescript
Hey everyone, I am trying to create an appRouter with ts-morph but I am having trouble with passing the zod schema/object instance to it (since I need to pass the original implementation, not the instance). I was thinking about a way to work around this and was wondering if I could somehow just pass the zod typescript type in the inputs and outputs - keep in mind that my usecase only calls for the type definitions to work, not the actual implementation.
import { initTRPC } from '@trpc/server';
import { z } from 'zod';

const t = initTRPC.create();
const publicProcedure = t.procedure;

const randomSchema = z.object({
name: z.string(),
});

type RandomType = z.infer<typeof randomSchema>;

const appRouter = t.router({
UserRouter: {
hello: publicProcedure.input<RandomType>().query((opts) => {
const name = opts.input.name;
return {
greeting: `Hello ${opts.input.name}`,
};
}),
},
});
export type AppRouter = typeof appRouter;
import { initTRPC } from '@trpc/server';
import { z } from 'zod';

const t = initTRPC.create();
const publicProcedure = t.procedure;

const randomSchema = z.object({
name: z.string(),
});

type RandomType = z.infer<typeof randomSchema>;

const appRouter = t.router({
UserRouter: {
hello: publicProcedure.input<RandomType>().query((opts) => {
const name = opts.input.name;
return {
greeting: `Hello ${opts.input.name}`,
};
}),
},
});
export type AppRouter = typeof appRouter;
here you can see I am trying to pass on;y the RandomType, but ofc I don't really know what I am doing 😄
2 replies
TtRPC
Created by DangerZone on 4/2/2023 in #❓-help
How can I generate trpc Generic Types?
I am building a trpc library, and as part of my implementation, I need the generic types of t, t.mergeRouters, t.procedure, t.router and t.middleware. I've haven't been able to locate those generic types in the @trpc/server and since trpc has such a complex type structure, would love to see an implementation for a generic set of types for the ones listed about.
4 replies
TtRPC
Created by DangerZone on 3/24/2023 in #❓-help
Express middleware router type isn't correct
3 replies