()
| 185 | * `requireAuth`. |
| 186 | */ |
| 187 | export const tryAuth = () => |
| 188 | new Elysia() |
| 189 | .use(createJWTConfig()) |
| 190 | .derive( |
| 191 | async ({ |
| 192 | jwt: jwtPlugin, |
| 193 | cookie, |
| 194 | }): Promise<{ user: IUser | null; accountId: string | null }> => { |
| 195 | const session = await verifyAuthCookie( |
| 196 | jwtPlugin, |
| 197 | cookie[AUTH_COOKIE_NAME]?.value |
| 198 | ); |
| 199 | |
| 200 | if (session === null) { |
| 201 | return { user: null, accountId: null }; |
| 202 | } |
| 203 | |
| 204 | return session; |
| 205 | } |
| 206 | ); |
no test coverage detected