Skip to content

Commit b46324c

Browse files
committed
added error handling to the middleware
1 parent af04443 commit b46324c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/middleware/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ export default function expressGraphQLRateLimiter(
136136
const requestTimestamp = new Date().valueOf();
137137
const { query, variables }: { query: string; variables: any } = req.body;
138138
if (!query) {
139-
// FIXME: Throw an error here? Code currently passes this on to whatever is next
140-
console.log('There is no query on the request');
139+
console.error(
140+
'Error in expressGraphQLRateLimiter: There is no query on the request. Rate-Limiting skipped'
141+
);
141142
return next();
142143
}
143144
// check for a proxied ip address before using the ip address on request
@@ -189,7 +190,10 @@ export default function expressGraphQLRateLimiter(
189190
}
190191
return next();
191192
} catch (err) {
192-
// todo: refactor error handling
193+
// log the error to the console and pass the request onto the next middleware.
194+
console.error(
195+
`Error in expressGraphQLRateLimiter processing query. Rate limiting is skipped: ${err}`
196+
);
193197
return next(err);
194198
}
195199
};

0 commit comments

Comments
 (0)