Skip to content

Commit 496cbaa

Browse files
committed
feat: set types
1 parent 9a1c645 commit 496cbaa

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/api/v1/apps/{teamId}.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ const debug = Debug('otomi:api:v1:apps')
1111
export const getApps = (req: OpenApiRequestExt, res: Response): void => {
1212
const { teamId } = req.params
1313
const { picks } = req.query
14-
res.json(req.otomi.getApps(teamId, picks as string[]))
14+
// Handle comma-separated string or array
15+
const picksArray = typeof picks === 'string' ? picks.split(',') : (picks as string[])
16+
res.json(req.otomi.getApps(teamId, picksArray))
1517
}
1618

1719
/**

src/api/v1/settings.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ const debug = Debug('otomi:api:v1:settings')
1010
*/
1111
export const getSettings = (req: OpenApiRequestExt, res: Response): void => {
1212
const { ids } = req.query
13-
debug(`getSettings(${ids})`)
14-
const v = req.otomi.getSettings(ids as string[] | undefined)
13+
// Handle comma-separated string or array
14+
const idsArray = ids ? (typeof ids === 'string' ? ids.split(',') : (ids as string[])) : undefined
15+
debug(`getSettings(${idsArray})`)
16+
const v = req.otomi.getSettings(idsArray)
1517
if (v?.otomi) {
1618
const { otomi: otomiSettings, ...restSettings } = v
1719
// Remove the otomi.adminPassword from otomi settings response

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export async function initApp(inOtomiStack?: OtomiStack) {
212212
apiSpec: path.join(__dirname, 'generated-schema.json'),
213213
validateRequests: {
214214
allowUnknownQueryParameters: false,
215-
coerceTypes: true, // Equivalent to enableObjectCoercion
215+
coerceTypes: 'array',
216216
},
217217
validateResponses: false, // Start with false, can enable later for debugging
218218
validateSecurity: {

src/middleware/security-handlers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import { getSessionStack } from './session'
2121
export async function groupAuthzSecurityHandler(req: Request, scopes: string[], schema: any): Promise<boolean> {
2222
const extReq = req as OpenApiRequestExt
2323

24-
// JWT middleware already ran and set req.user if token was valid
24+
// In dev mode, JWT middleware sets a mock user without requiring Authorization header
25+
// In production, JWT middleware sets req.user only if valid token exists
26+
// Allow requests to proceed if user was set by JWT middleware
2527
if (!extReq.user) {
2628
throw { status: 401, message: 'Unauthorized - No valid JWT token provided' }
2729
}

0 commit comments

Comments
 (0)