I am a Dev
I am a Dev
Explore posts from servers
TtRPC
Created by I am a Dev on 10/14/2023 in #❓-help
Hello, is there any way to create a base router with common procedures? like an interface
I want all routers that use it have the state procedure (subscriptions), so I can create a common hook later Although the implementation of the methods is completely different on each router, I just want to guarantee that they have those procedures, like an interface The hook basically will subscribe to the state on mount, and unsubscribe on unmount Thanks
8 replies
TtRPC
Created by I am a Dev on 10/6/2023 in #❓-help
There is a logger middleware like morgan for express?
There is a package with a nice logger middleware? Thanks
2 replies
TTCTheo's Typesafe Cult
Created by I am a Dev on 10/5/2023 in #questions
with t3 what do you use to stream open ai chat gpt responses?
Since tRPC currently does not support it. Thanks
4 replies
DTDrizzle Team
Created by I am a Dev on 10/3/2023 in #help
Drizzle support SELECT FOR UPDATE of postgres to avoid logical race conditions ?
I have a similar use case like this: https://on-systems.tech/blog/128-preventing-read-committed-sql-concurrency-errors/ Currently I use a mutex in my node main process, but I think is better to move this to the db. If is possible can you show me a minimal example Thank you so much
23 replies
TtRPC
Created by I am a Dev on 10/3/2023 in #❓-help
Review of inner and outer context with express
Hello, I didn't find any example that uses inner (for testing) and outer context with express. That's how I implemented it for my express trpc boilerplate, I wanted to know if I did it right, or if there was some error. Thank you so much TLDR; The inner context and options is a custom object with partial express options. the outer context and options is an extension of the inner but now the express options are mandatory.
import { initTRPC } from '@trpc/server';
import type * as trpcExpress from '@trpc/server/adapters/express';
import superjson from 'superjson';
import type { OpenApiMeta } from 'trpc-openapi';

// Fake prisma
const prisma = 'prisma';

export interface CreateInnerTRPCContextOptions
extends Partial<trpcExpress.CreateExpressContextOptions> {}

export interface AppInnerContext
extends Partial<trpcExpress.CreateExpressContextOptions> {
prisma: string;
}

export async function createInnerTRPCContext(
_opts: CreateInnerTRPCContextOptions,
): Promise<AppInnerContext> {
return {
prisma,
};
}

type CreateTRPCContextOptions = CreateInnerTRPCContextOptions &
trpcExpress.CreateExpressContextOptions;

export type AppContext = AppInnerContext &
trpcExpress.CreateExpressContextOptions;

export async function createTRPCContext(
opts: CreateTRPCContextOptions,
): Promise<AppContext> {
const innerContext = await createInnerTRPCContext(opts);

return {
...innerContext,
req: opts.req,
res: opts.res,
};
}

const t = initTRPC.meta<OpenApiMeta>().context<AppInnerContext>().create({
transformer: superjson,
});

export const createTRPCRouter = t.router;

export const publicProcedure = t.procedure;
import { initTRPC } from '@trpc/server';
import type * as trpcExpress from '@trpc/server/adapters/express';
import superjson from 'superjson';
import type { OpenApiMeta } from 'trpc-openapi';

// Fake prisma
const prisma = 'prisma';

export interface CreateInnerTRPCContextOptions
extends Partial<trpcExpress.CreateExpressContextOptions> {}

export interface AppInnerContext
extends Partial<trpcExpress.CreateExpressContextOptions> {
prisma: string;
}

export async function createInnerTRPCContext(
_opts: CreateInnerTRPCContextOptions,
): Promise<AppInnerContext> {
return {
prisma,
};
}

type CreateTRPCContextOptions = CreateInnerTRPCContextOptions &
trpcExpress.CreateExpressContextOptions;

export type AppContext = AppInnerContext &
trpcExpress.CreateExpressContextOptions;

export async function createTRPCContext(
opts: CreateTRPCContextOptions,
): Promise<AppContext> {
const innerContext = await createInnerTRPCContext(opts);

return {
...innerContext,
req: opts.req,
res: opts.res,
};
}

const t = initTRPC.meta<OpenApiMeta>().context<AppInnerContext>().create({
transformer: superjson,
});

export const createTRPCRouter = t.router;

export const publicProcedure = t.procedure;
2 replies
TtRPC
Created by I am a Dev on 10/3/2023 in #❓-help
Should i use lint rule explicit-function-return-type when use trpc?
No description
2 replies
TtRPC
Created by I am a Dev on 10/1/2023 in #❓-help
Name recommendations for my api endpoints that use swagger, trpc-panel, trpc-playground.
What name do you recommend for each one, in addition to the rest api and the trpc api endpoints. Like /api /trpc /trpc/panel Thanks
3 replies
TtRPC
Created by I am a Dev on 10/1/2023 in #❓-help
In the context should I put all my dependencies for my endpoint handlers?
For example I have the end point 'getStuff` In this endpoint the handler call 3 party apis and map the data to the tRPC output. But I have an API key rotator class, to do each request to a 3 party API with the different API key in each request. So should I put in the context the API key rotator class? And this should be a singleton like the db instance? Also the API key rotator has dependency on the db, to store the last used API key, and consult all API keys. Thanks
2 replies
TtRPC
Created by I am a Dev on 9/30/2023 in #❓-help
How to return a stream? like open ai api
I want that my api can have stream responses like open ai https://github.com/openai/openai-node#streaming-responses how can i do it? Thanks
5 replies
TtRPC
Created by I am a Dev on 9/29/2023 in #❓-help
I have an api with trpc, how can I consume it from dart/flutter?
2 replies
TtRPC
Created by I am a Dev on 9/28/2023 in #❓-help
Is there a guide of how to test?
I'm usually use vitest but in frontend of shared packages. I'm frontend trying to create my first api πŸ™‚ Thanks
2 replies
TtRPC
Created by I am a Dev on 9/28/2023 in #❓-help
is there a simple boilerplate that has everything ready to deploy?
For example nodemon, reading the port for .env, etc. (I don't know if that's how it is haha) I use turborepo, so can be an internal package. But I want to see how the project configuration looks for the deploy. It's the first time I am creating a server, for now it will be deployed on a PC on an intranet. It's just a server to everyone in the intranet can access and modify a json file. Thanks
4 replies
TtRPC
Created by I am a Dev on 9/26/2023 in #❓-help
In a monorepo can I have 2 packages each one with different trpc server, and use both in 1 app?
I want to create 2 different APIs, and in my monorepo I have several apps, in some I want to use both, in others only 1 Thanks
5 replies
TtRPC
Created by I am a Dev on 9/26/2023 in #❓-help
Have you used electron-trpc? how does it work for you? Do you recommend it?
2 replies
PD🧩 Plasmo Developers
Created by I am a Dev on 9/19/2023 in #πŸ”°newbie
There is a difference in the developer experience building the options page vs normal web with vite?
Hello, for now I want to develop an app in the options tab, the idea is to open it as if I were developing a web app with Vite. There I will use, react-router, redux, etc, like a normal web app. My question is if my development experience in that tab is the same as when developing a regular web app with vite, or does it have any limitations or differences that cause the app to restart, or lose state while developing. Basically I'm just migrating a web app to the extension's options window, so I want to know if it's better to develop it in Vite as a web app, or is it the same DX with Plasmo. Thanks
3 replies