mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-04 08:06:26 +08:00
feat(onboarding): add GET /api/onboarding/profile route
This commit is contained in:
28
server/api/onboarding/profile.get.ts
Normal file
28
server/api/onboarding/profile.get.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { requireUserSession } from '../../utils/auth'
|
||||
import { PilotProfile } from '../../models/PilotProfile'
|
||||
import { createDefaultOnboardingProfile } from '~~/shared/onboarding/config'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = await requireUserSession(event)
|
||||
const profile = await PilotProfile.findOne({ user: user._id })
|
||||
|
||||
if (!profile) {
|
||||
return createDefaultOnboardingProfile()
|
||||
}
|
||||
|
||||
return {
|
||||
simulator: profile.simulator ?? null,
|
||||
os: profile.os ?? null,
|
||||
hardware: profile.hardware ?? [],
|
||||
radioConfidence: profile.radioConfidence ?? null,
|
||||
radioPainPoint: profile.radioPainPoint ?? null,
|
||||
networkExperience: profile.networkExperience ?? [],
|
||||
toolkit: profile.toolkit ?? [],
|
||||
toolkitDuration: profile.toolkitDuration ?? {},
|
||||
topFeatures: profile.topFeatures ?? [],
|
||||
pricingPreference: profile.pricingPreference ?? null,
|
||||
resultCallsign: profile.resultCallsign ?? null,
|
||||
completedAt: profile.completedAt ? profile.completedAt.toISOString() : null,
|
||||
skippedAt: profile.skippedAt ? profile.skippedAt.toISOString() : null,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user