Skip to content

Commit 782dd1e

Browse files
committed
fix: UserProfileType, move to @local/common
1 parent 8141c0d commit 782dd1e

7 files changed

Lines changed: 17 additions & 12 deletions

File tree

apps/backend/src/api/auth/$.routes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This file contains routes and sample routes for possible APIs usecases with Kinde.
33
*/
44

5-
import type { UserProfileType } from '#src/types.js'
5+
import type { UserProfileType } from '@local/common/src/types/user'
66
// import type { ClaimTokenType, FlagType } from '@kinde-oss/kinde-typescript-sdk'
77
import { appFactory } from '#src/helpers/factory.js'
88
import { getSessionManager } from '#src/helpers/kinde.js'
@@ -18,8 +18,8 @@ export const authRoutesApp = appFactory.createApp()
1818
const kindeClient = await getKindeClient()
1919
const sessionManager = getSessionManager(c)
2020

21-
const [profile, token]: [UserProfileType | null, string | null] = await Promise.all([
22-
kindeClient.getUserProfile(sessionManager).catch(() => null),
21+
const [profile, token] = await Promise.all([
22+
kindeClient.getUserProfile(sessionManager).catch(() => null) as Promise<UserProfileType>,
2323
kindeClient.getToken(sessionManager).catch(() => null),
2424
])
2525

apps/backend/src/types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import type { UserType } from '@kinde-oss/kinde-typescript-sdk'
21
import type { LambdaContext, LambdaEvent } from 'hono-adapter-aws-lambda'
32
import type { Session } from 'hono-sessions'
4-
import type { Simplify } from 'hono/utils/types'
53

64
export interface HonoEnv {
75
Bindings: {
@@ -18,5 +16,3 @@ export interface HonoEnv {
1816
session_key_rotation: boolean
1917
}
2018
}
21-
22-
export type UserProfileType = Simplify<UserType>

apps/frontend/app/components/chat/sidebar/ChatSidebarUserMenuButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const nicknameRef = useChatNickname()
99
<div class="h-9 flex items-center gap-2 truncate text-sm leading-tight">
1010
<template v-if="$auth.loggedIn">
1111
<Avatar shape="square" size="sm" class="size-9" alt="User avatar">
12-
<AvatarImage :src="$auth.user.picture" alt="Avatar image" />
12+
<AvatarImage v-if="$auth.user.picture" :src="$auth.user.picture" alt="Avatar image" />
1313
<AvatarFallback>👤</AvatarFallback>
1414
</Avatar>
1515
<div class="truncate">

apps/frontend/app/plugins/auth.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// eslint-disable-next-line ts/ban-ts-comment
2-
// @ts-ignore TS6305: `backend/src/app` has not been built yet
3-
import type { UserProfileType } from 'backend/src/types'
1+
import type { UserProfileType } from '@local/common/src/types/user'
42
import type { Reactive } from 'vue'
53

64
export type AuthState = (

locals/common/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"devDependencies": {
1515
"@local/tsconfig": "workspace:*",
16-
"dotenv": "^16.6.1"
16+
"dotenv": "^16.6.1",
17+
"type-fest": "^4.41.0"
1718
}
1819
}

locals/common/src/types/user.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { UserType } from '@kinde-oss/kinde-typescript-sdk'
2+
3+
export interface UserProfileType extends UserType {
4+
// Note: `name` and `sub` exists in Kinde UserType but is not typed
5+
name: string
6+
sub: string
7+
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)