Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tRPC : ready for production ✨ #3437

Merged
merged 11 commits into from
Nov 25, 2024
Merged

tRPC : ready for production ✨ #3437

merged 11 commits into from
Nov 25, 2024

Conversation

farnoux
Copy link
Contributor

@farnoux farnoux commented Nov 22, 2024

tRPC

tRPC prêt à être utilisé globalement 🎉

  • documentation ADR sur tRPC
  • configuration front de tRPC
  • configuration back de tRPC avec gestion du contexte authentifié
  • API fiche.countByStatut désormais branché en tRPC à la place de l'API REST (anciennement appelé fiche/synthese)

Pour les routes authentifiées

  • Côté front : rien ne change, c'est transparent
return trpc.plans.fiches.countByStatut.useQuery({
    collectiviteId,
    body: params,
  });
  • Côté back : procédure dédiée authedProcedure et récupération du user via le ctx de la query.
/* Dans le router */
countByStatut: this.trpc.authedProcedure
    .input(inputSchema)
    .query(({ input, ctx }) => {
        const { collectiviteId, body } = input;
        return this.service.countByStatut(collectiviteId, body, ctx.user);
    })

/* Dans le service */
const uuid = user.id;
const role = user.role;

@farnoux farnoux merged commit 6668821 into main Nov 25, 2024
16 of 17 checks passed
@farnoux farnoux deleted the trpc/ready-to-prod branch November 25, 2024 12:15
@farnoux farnoux mentioned this pull request Nov 25, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant