Skip to content

Commit 68ac079

Browse files
committed
Merge branch 'dev' of github.com:oslabs-beta/GraphQL-Gate into sh/build-type-weights
2 parents 3d2cebf + d29c6d4 commit 68ac079

File tree

6 files changed

+386
-95
lines changed

6 files changed

+386
-95
lines changed

.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
},
2020
"plugins": ["import", "prettier"],
2121
"rules": {
22-
22+
"no-plusplus": [2, {
23+
"allowForLoopAfterthoughts": true
24+
}],
2325
"prettier/prettier": [
2426
"error"
2527
]

package-lock.json

Lines changed: 18 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"test": "jest --passWithNoTests",
99
"lint": "eslint src test",
10-
"lint:fix": "eslint --fix src test",
10+
"lint:fix": "eslint --fix src test @types",
1111
"prettier": "prettier --write .",
1212
"prepare": "husky install"
1313
},
@@ -44,6 +44,7 @@
4444
"prettier": "2.6.2",
4545
"redis-mock": "^0.56.3",
4646
"ts-jest": "^28.0.2",
47+
"ts-node": "^10.8.0",
4748
"typescript": "^4.6.4"
4849
},
4950
"lint-staged": {

src/@types/rateLimit.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ interface TokenBucketOptions {
4040
}
4141

4242
// TODO: This will be a union type where we can specify Option types for other Rate Limiters
43-
type RateLimiterOptions = TokenBucketOptions;
43+
// Record<string, never> represents the empty object for alogorithms that don't require settings
44+
// and might be able to be removed in the future.
45+
type RateLimiterOptions = TokenBucketOptions | Record<string, never>;

src/middleware/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import { defaultTypeWeightsConfig } from '../analysis/buildTypeWeights';
1717
* Defaults to {mutation: 10, object: 1, field: 0, connection: 2}
1818
* @returns {RequestHandler} express middleware that computes the complexity of req.query and calls the next middleware
1919
* if the query is allowed or sends a 429 status if the request is blocked
20-
* @throws ValidationError if GraphQL Schema is invalid
20+
* FIXME: How about the specific GraphQLError?
21+
* @throws ValidationError if GraphQL Schema is invalid.
2122
*/
2223
export function expressRateLimiter(
2324
rateLimiter: RateLimiterSelection,
@@ -31,7 +32,6 @@ export function expressRateLimiter(
3132
// TODO: Connect to Redis store using provided options. Default to localhost:6379
3233
// TODO: Configure the selected RateLimtier
3334
// TODO: Configure the complexity analysis algorithm to run for incoming requests
34-
3535
const middleware: RequestHandler = (req: Request, res: Response, next: NextFunction) => {
3636
// TODO: Parse query from req.query, compute complexity and pass necessary info to rate limiter
3737
// TODO: Call next if query is successful, send 429 status if query blocked, call next(err) with any thrown errors

0 commit comments

Comments
 (0)