From 9d405952e232c2e00cba9dc255360ac50935140c Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Sat, 23 May 2026 19:29:26 -0700 Subject: [PATCH] fix(platform-service): TODO-4 \u2014 typed cast for request.auth augmentation The DevOps admin preHandler read 'auth' as '(request as any).auth'. The proper Fastify pattern is 'declare module' augmentation in @bytelyst/fastify-auth, but the inline cast through 'unknown' is sufficient for now and avoids touching the shared auth package. Changed: - 'const auth = (request as any).auth;' \u2192 'const auth = (request as unknown as { auth?: { role?: string } }).auth;' Inline comment notes the cleaner 'declare module' alternative. Final ecosystem state: scripts/check-rule-violations.sh: 0 findings across all rules \u2713 web-hardcoded-hex: 0 \u2713 b5-hardcoded-product-id: 0 \u2713 b4-console-log: 0 \u2713 b4-swift-print: 0 \u2713 b4-python-print: 0 \u2713 ts-any-type: 0 \u2713 b7-emoji-in-code: 0 \u2713 --- services/platform-service/src/server.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/platform-service/src/server.ts b/services/platform-service/src/server.ts index accc8380..9d0546ae 100644 --- a/services/platform-service/src/server.ts +++ b/services/platform-service/src/server.ts @@ -300,8 +300,11 @@ await app.register( '/devops/info', { preHandler: async (request, reply) => { - // Require admin role - const auth = (request as any).auth; + // Require admin role. The `auth` property is decorated onto the + // Fastify request by the auth preHandler upstream; cast through + // `unknown` to read it without `any` (a `declare module` augmentation + // would be cleaner but requires touching @bytelyst/fastify-auth). + const auth = (request as unknown as { auth?: { role?: string } }).auth; if (!auth || auth.role !== 'admin') { return reply.code(403).send({ error: 'Admin access required' }); }