Skip to content

Commit

Permalink
Merge branch 'main' into update-sso
Browse files Browse the repository at this point in the history
  • Loading branch information
pauljohanneskraft authored Jan 14, 2025
2 parents 38ab01e + 0223b8e commit 72c5d10
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
3 changes: 3 additions & 0 deletions functions/models/src/functions/defaultSeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ export const defaultSeedInputSchema = z.object({
[],
),
})

export type DefaultSeedInput = z.input<typeof defaultSeedInputSchema>
export type DefaultSeedOutput = Record<string, never>
1 change: 1 addition & 0 deletions functions/models/src/functions/updateStaticData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ export const updateStaticDataInputSchema = z.object({
),
})
export type UpdateStaticDataInput = z.input<typeof updateStaticDataInputSchema>
export type UpdateStaticDataOutput = Record<string, never>
21 changes: 13 additions & 8 deletions functions/src/functions/defaultSeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {
DebugDataComponent,
defaultSeedInputSchema,
type DefaultSeedOutput,
UserDebugDataComponent,
UserType,
} from '@stanfordbdhg/engagehf-models'
Expand Down Expand Up @@ -187,13 +188,17 @@ export const defaultSeed =
defaultSeedInputSchema,
async (_, data, response) => {
await _defaultSeed(getServiceFactory(), data)
response.write('Success', 'utf8')
response.end()
const result: DefaultSeedOutput = {}
response.send({ result })
},
)
: validatedOnCall(
'defaultSeed',
defaultSeedInputSchema,
async (request): Promise<DefaultSeedOutput> => {
const factory = getServiceFactory()
factory.credential(request.auth).check(UserRole.admin)
await _defaultSeed(factory, request.data)
return {}
},
)
: validatedOnCall('defaultSeed', defaultSeedInputSchema, async (request) => {
const factory = getServiceFactory()
factory.credential(request.auth).check(UserRole.admin)
await _defaultSeed(factory, request.data)
return 'Success'
})
9 changes: 5 additions & 4 deletions functions/src/functions/updateStaticData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {
StaticDataComponent,
updateStaticDataInputSchema,
type UpdateStaticDataOutput,
} from '@stanfordbdhg/engagehf-models'
import { type z } from 'zod'
import { validatedOnCall, validatedOnRequest } from './helpers.js'
Expand Down Expand Up @@ -43,17 +44,17 @@ export const updateStaticData =
updateStaticDataInputSchema,
async (_, data, response) => {
await _updateStaticData(getServiceFactory(), data)
response.write('Success', 'utf8')
response.end()
const result: UpdateStaticDataOutput = {}
response.send({ result })
},
)
: validatedOnCall(
'updateStaticData',
updateStaticDataInputSchema,
async (request) => {
async (request): Promise<UpdateStaticDataOutput> => {
const factory = getServiceFactory()
factory.credential(request.auth).check(UserRole.admin)
await _updateStaticData(factory, request.data)
return 'Success'
return {}
},
)

0 comments on commit 72c5d10

Please sign in to comment.