Skip to content

Commit

Permalink
Simplify handling of EmailTemplateProps
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed Dec 3, 2024
1 parent 7cf6744 commit 023f83c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions frontend/src/routes/email/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import type {Component} from 'svelte';

export async function POST(event: RequestEvent): Promise<Response> {
const request = await event.request.json() as EmailTemplateProps;
const {...props} = request;
const component = componentMap[props.template] as unknown as Component<EmailTemplateProps>;
if (!component) throw new Error(`Invalid email template ${props.template}.}`);
return json(render(component, props, event.locals.activeLocale));
const component = componentMap[request.template] as unknown as Component<EmailTemplateProps>;
if (!component) throw new Error(`Invalid email template ${request.template}.}`);
return json(render(component, request, event.locals.activeLocale));
}


Expand Down

0 comments on commit 023f83c

Please sign in to comment.