initial COM2 system snapshot
This commit is contained in:
43
web/hx-ki-website/server/routers.ts
Normal file
43
web/hx-ki-website/server/routers.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { COOKIE_NAME } from "@shared/const";
|
||||
import { getSessionCookieOptions } from "./_core/cookies";
|
||||
import { systemRouter } from "./_core/systemRouter";
|
||||
import { publicProcedure, router } from "./_core/trpc";
|
||||
import { z } from "zod";
|
||||
import { notifyOwner } from "./_core/notification";
|
||||
|
||||
export const appRouter = router({
|
||||
// if you need to use socket.io, read and register route in server/_core/index.ts, all api should start with '/api/' so that the gateway can route correctly
|
||||
system: systemRouter,
|
||||
auth: router({
|
||||
me: publicProcedure.query(opts => opts.ctx.user),
|
||||
logout: publicProcedure.mutation(({ ctx }) => {
|
||||
const cookieOptions = getSessionCookieOptions(ctx.req);
|
||||
ctx.res.clearCookie(COOKIE_NAME, { ...cookieOptions, maxAge: -1 });
|
||||
return {
|
||||
success: true,
|
||||
} as const;
|
||||
}),
|
||||
}),
|
||||
|
||||
contact: router({
|
||||
submit: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
name: z.string().min(1),
|
||||
email: z.string().email(),
|
||||
message: z.string().min(1),
|
||||
})
|
||||
)
|
||||
.mutation(async ({ input }) => {
|
||||
// Notify owner about new contact form submission
|
||||
await notifyOwner({
|
||||
title: "Neue Kontaktanfrage",
|
||||
content: `Name: ${input.name}\nE-Mail: ${input.email}\n\nNachricht:\n${input.message}`,
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export type AppRouter = typeof appRouter;
|
||||
Reference in New Issue
Block a user