26 lines
767 B
TypeScript
26 lines
767 B
TypeScript
|
import { type AppProps, Handlers, PageProps } from "$fresh/server.ts";
|
||
|
import { Page } from "@/components/Page.tsx";
|
||
|
import { type PublicUser } from "@/types.ts";
|
||
|
import { type ContextState } from "@/types.ts";
|
||
|
|
||
|
interface MyAppProps extends AppProps {
|
||
|
user?: PublicUser;
|
||
|
}
|
||
|
|
||
|
export const handler: Handlers<unknown, ContextState> = {
|
||
|
async GET(_request: Request, context) {
|
||
|
const user: Partial<ContextState["user"]> = context.state.user;
|
||
|
if (user && "passwordDigest" in user) delete user.passwordDigest;
|
||
|
return await context.render(context.state.user);
|
||
|
},
|
||
|
};
|
||
|
|
||
|
export default function App({ Component, ...props }: MyAppProps) {
|
||
|
console.log("AppProps:", props);
|
||
|
return (
|
||
|
<Page user={props.user}>
|
||
|
<Component></Component>
|
||
|
</Page>
|
||
|
);
|
||
|
}
|