Skip to content

Commit

Permalink
chore!: Deprecate calling protect() with no rules (#608)
Browse files Browse the repository at this point in the history
Closes #605 

This adds a warning log if `protect()` is called with no rules configured that lets users know they should be configuring at least one rule, and suggests Shield because that is the common case where no rule would be specified before this behavior change.
  • Loading branch information
blaine-arcjet committed Apr 16, 2024
1 parent 16af391 commit 57a8f6b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arcjet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,13 @@ export default function arcjet<

const context: ArcjetContext = { key, fingerprint };

if (rules.length < 1) {
// TODO(#607): Error if no rules configured after deprecation period
logger.warn(
"Calling `protect()` with no rules is deprecated. Did you mean to configure the Shield rule?",
);
}

if (rules.length > 10) {
logger.error("Failure running rules. Only 10 rules may be specified.");

Expand Down

0 comments on commit 57a8f6b

Please sign in to comment.