Skip to content

Commit

Permalink
feat: add mock apis
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan committed Sep 17, 2023
1 parent 8f61c56 commit 7cd1d69
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
12 changes: 6 additions & 6 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export default defineNuxtConfig({
sessionCookie: true,
},

// appCheck: {
// debug: true,
// isTokenAutoRefreshEnabled: true,
// provider: 'ReCaptchaEnterprise',
// key: '6LfNWy8oAAAAAG9GdaqR-X8t8721YyHyILD_C6Pu',
// },
appCheck: {
debug: process.env.FIREBASE_APP_CHECK_DEBUG_TOKEN || process.env.NODE_ENV !== 'production',
isTokenAutoRefreshEnabled: true,
provider: 'ReCaptchaEnterprise',
key: '6LfNWy8oAAAAAG9GdaqR-X8t8721YyHyILD_C6Pu',
},
},

runtimeConfig: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@libsql/client": "^0.3.4",
"@nuxt/devtools": "latest",
"@paralleldrive/cuid2": "^2.2.2",
"dayjs": "^1.11.9",
"dotenv": "^16.3.1",
"drizzle-kit": "^0.19.13",
"drizzle-orm": "^0.28.6",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions server/api/event/[id].get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import dayjs from 'dayjs'

export default defineProtectedEventHandler(event => ({
id: event.context.params!.id,
name: 'SST Homecoming 2024',
description: 'SST Homecoming 2024',
location: 'SST',
badgeImage: 'https://www.sst.edu.sg/images/default-source/album/2019-2020/2020-01-24-homecoming/20200124_182000.jpg?sfvrsn=2',
startDateTime: dayjs(Date.now()).valueOf(),
endDateTime: dayjs(Date.now()).valueOf(),
}))
3 changes: 0 additions & 3 deletions server/api/test.get.ts

This file was deleted.

7 changes: 7 additions & 0 deletions server/api/user/[id].get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default defineProtectedEventHandler(event => ({
id: event.context.params!.id,
name: 'Qin Guan',
memberId: 'ABC-1',
graduationYear: 2024,
memberType: 'exco',
}))
3 changes: 2 additions & 1 deletion server/utils/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-expect-error Bad types
import { verifyIdToken } from 'web-auth-library/google'
import type { UserToken } from 'web-auth-library/dist/google'
import type { EventHandler, EventHandlerRequest } from 'h3'

export function defineProtectedEventHandler<T extends EventHandlerRequest, D>(
Expand All @@ -16,7 +17,7 @@ export function defineProtectedEventHandler<T extends EventHandlerRequest, D>(
}

const idToken = authorization.substring(7, authorization.length)
await verifyIdToken({
const data: UserToken = await verifyIdToken({
idToken,
projectId: useRuntimeConfig().firebase.projectId,
})
Expand Down

0 comments on commit 7cd1d69

Please # to comment.