diff --git a/README.md b/README.md index 661fb7f..e153901 100644 --- a/README.md +++ b/README.md @@ -62,36 +62,40 @@ export default defineConfig({ ```ts import { LogoutForm } from "../../mod.ts"; import type { WithPlantation } from "../../mod.ts"; -import type { PageProps} from "$fresh/server.ts"; +import type { PageProps } from "$fresh/server.ts"; -export default function MustLogin(props: PageProps>) { +export default function MustLogin( + props: PageProps>, +) { return (
MUST LOGIN -

{props.state.plantation.authUserSession.resourceName} id : {props.state.plantation.authUserSession.user.userId}

+

+ {props.state.plantation.authUserSession.resourceName} id :{" "} + {props.state.plantation.authUserSession.user.userId} +

); } ``` -In the case of `user`, the ID of the resource can be obtained as in `props.state.plantation.authUserSession.user.userId`. +In the case of `user`, the ID of the resource can be obtained as in +`props.state.plantation.authUserSession.user.userId`.\ Similarly, the handler can also retrieve this. -```ts +```ts export const handler = { - GET(req: Request, ctx: FreshContext>){ - + GET(req: Request, ctx: FreshContext>) { // ex. get user id // ctx.state.plantation.authUserSession.user.userId - return ctx.render() - } -} + return ctx.render(); + }, +}; ``` - ## Custom handler and component You can use the cli tool to build your own handlers and components. diff --git a/mod.ts b/mod.ts index db5fc85..39e1250 100644 --- a/mod.ts +++ b/mod.ts @@ -7,5 +7,5 @@ export { passwordSchema, usernameSchema, } from "./src/utils/validates.ts"; -export type { PlantationParams , WithPlantation } from "./types.ts"; +export type { PlantationParams, WithPlantation } from "./types.ts"; export { LogoutForm } from "./src/components/LogoutForm.tsx"; diff --git a/types.ts b/types.ts index 9d2b5d1..ebc04ac 100644 --- a/types.ts +++ b/types.ts @@ -73,16 +73,18 @@ export interface DefaultActions { }; } - type IdName = `${T}Id`; type LuciaObjectKey = `auth${Capitalize}Session`; -export interface WithPlantation extends Record { - plantation:{ - [K in LuciaObjectKey]: { - [KK in Q]:{ - [KKK in IdName]: string; - }; - } & {resourceName:string} - } +export interface WithPlantation + extends Record { + plantation: { + [K in LuciaObjectKey]: + & { + [KK in Q]: { + [KKK in IdName]: string; + }; + } + & { resourceName: string }; + }; }