Skip to content

Conversation

@DGoel1602
Copy link
Contributor

Why

Allows us to run arbitrary code upon form submission to run things automatically such as member or hacker creation

What

Added a connections tRPC page that allows connecting procedures and forms by mapping all the fields from a procedure to a field on the form. Automatically store all connections in the DB, get these connections from DB when a form is submitted on the backend and then run whatever procedures it is connected to by mapping the fields.

Test Plan

trpcformlink.mp4

Comment on lines +43 to +65
const handleCallbacks = async (response: Record<string, unknown>) => {
"use server";
for (const con of connections) {
const data: Record<string, unknown> = {};
for (const map of con.connections as {
procField: string;
formField: string;
}[]) {
data[map.procField] = response[map.formField];
}

const route = procs[con.proc]?.route.split(".");
if (!Array.isArray(route) || route.length < 2) continue;
const [routerName, procName] = route as [keyof typeof api, string];
const subroute = api[routerName];
const proc = (
subroute as Record<string, (input: unknown) => Promise<unknown>>
)[procName];
if (!proc) continue;

await proc(data);
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

holy typescript

Copy link
Contributor

@DVidal1205 DVidal1205 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was actually a beautiful read. very well done

@DVidal1205 DVidal1205 added this pull request to the merge queue Jan 13, 2026
Merged via the queue into main with commit aaf28e7 Jan 13, 2026
5 checks passed
@DVidal1205 DVidal1205 deleted the forms/form-trpc-link branch January 13, 2026 22:31
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.

3 participants