Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove fastify deprecated properties #607

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/http/plugins/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
fastify.decorateRequest('jwt', '')
fastify.decorateRequest('jwtPayload', undefined)

fastify.addHook('preHandler', async (request, reply) => {

Check warning on line 28 in src/http/plugins/jwt.ts

View workflow job for this annotation

GitHub Actions / Test / OS ubuntu-20.04 / Node 20

'reply' is defined but never used
request.jwt = (request.headers.authorization || '').replace(BEARER, '')

if (!request.jwt && request.routeConfig.allowInvalidJwt) {
if (!request.jwt && request.routeOptions.config.allowInvalidJwt) {
request.jwtPayload = { role: 'anon' }
request.isAuthenticated = false
return
Expand All @@ -41,11 +41,11 @@
request.jwtPayload = payload
request.owner = payload.sub
request.isAuthenticated = true
} catch (err: any) {

Check warning on line 44 in src/http/plugins/jwt.ts

View workflow job for this annotation

GitHub Actions / Test / OS ubuntu-20.04 / Node 20

Unexpected any. Specify a different type
request.jwtPayload = { role: 'anon' }
request.isAuthenticated = false

if (request.routeConfig.allowInvalidJwt) {
if (request.routeOptions.config.allowInvalidJwt) {
return
}
throw ERRORS.AccessDenied(err.message, err)
Expand Down
6 changes: 3 additions & 3 deletions src/http/plugins/log-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

interface FastifyContextConfig {
operation?: { type: string }
resources?: (req: FastifyRequest<any>) => string[]

Check warning on line 21 in src/http/plugins/log-request.ts

View workflow job for this annotation

GitHub Actions / Test / OS ubuntu-20.04 / Node 20

Unexpected any. Specify a different type
}
}

Expand Down Expand Up @@ -59,8 +59,8 @@
const resourceFromParams = Object.values(req.params || {}).join('/')
const resources = getFirstDefined<string[]>(
req.resources,
req.routeConfig.resources?.(req),
req.routeOptions.config.resources?.(req),
(req.raw as any).resources,

Check warning on line 63 in src/http/plugins/log-request.ts

View workflow job for this annotation

GitHub Actions / Test / OS ubuntu-20.04 / Node 20

Unexpected any. Specify a different type
resourceFromParams ? [resourceFromParams] : ([] as string[])
)

Expand All @@ -73,7 +73,7 @@
}

req.resources = resources
req.operation = req.routeConfig.operation
req.operation = req.routeOptions.config.operation

if (req.operation) {
trace.getActiveSpan()?.setAttribute('http.operation', req.operation.type)
Expand Down Expand Up @@ -115,7 +115,7 @@
const rId = req.id
const cIP = req.ip
const statusCode = options.statusCode
const error = (req.raw as any).executionError || req.executionError

Check warning on line 118 in src/http/plugins/log-request.ts

View workflow job for this annotation

GitHub Actions / Test / OS ubuntu-20.04 / Node 20

Unexpected any. Specify a different type
const tenantId = req.tenantId

const buildLogMessage = `${tenantId} | ${rMeth} | ${statusCode} | ${cIP} | ${rId} | ${rUrl} | ${uAgent}`
Expand All @@ -129,7 +129,7 @@
owner: req.owner,
role: req.jwtPayload?.role,
resources: req.resources,
operation: req.operation?.type ?? req.routeConfig.operation?.type,
operation: req.operation?.type ?? req.routeOptions.config.operation?.type,
serverTimes: req.serverTimings,
})
}
Expand Down
Loading