Skip to content

Commit

Permalink
refactor(index): replace typeof undefined check (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Oct 29, 2023
1 parent dc27254 commit 2f3deda
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ function fastifyCompress (fastify, opts, next) {
// add onSend hook onto each route as needed
fastify.addHook('onRoute', (routeOptions) => {
// If route config.compress has been set it takes precedence over compress
if (routeOptions.config && typeof routeOptions.config.compress !== 'undefined') {
if (routeOptions.config?.compress !== undefined) {
routeOptions.compress = routeOptions.config.compress
}

// Manage compression options
if (typeof routeOptions.compress !== 'undefined') {
if (routeOptions.compress !== undefined) {
if (typeof routeOptions.compress === 'object') {
const mergedCompressParams = Object.assign(
{}, globalCompressParams, processCompressParams(routeOptions.compress)
Expand All @@ -80,12 +80,12 @@ function fastifyCompress (fastify, opts, next) {
}

// If route config.decompress has been set it takes precedence over compress
if (routeOptions.config && typeof routeOptions.config.decompress !== 'undefined') {
if (routeOptions.config?.decompress !== undefined) {
routeOptions.decompress = routeOptions.config.decompress
}

// Manage decompression options
if (typeof routeOptions.decompress !== 'undefined') {
if (routeOptions.decompress !== undefined) {
if (typeof routeOptions.decompress === 'object') {
// if the current endpoint has a custom compress configuration ...
const mergedDecompressParams = Object.assign(
Expand Down

0 comments on commit 2f3deda

Please sign in to comment.