-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use KV to store notify patterns (#1)
* Add script to store notify-patterns in KV. * Store notify-patterns in KV on bootstrap. * Read notify-patterns from KV when executing.
- Loading branch information
Showing
6 changed files
with
123 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,3 +171,7 @@ dist | |
.dev.vars | ||
wrangler.toml | ||
.wrangler/ | ||
|
||
# notify patterns | ||
|
||
.notify-patterns.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
NO_D1_WARNING=true | ||
export NO_D1_WARNING | ||
|
||
export RED="\033[1;31m" | ||
export GREEN="\033[1;32m" | ||
export YELLOW="\033[1;33m" | ||
export BLUE="\033[1;34m" | ||
export PURPLE="\033[1;35m" | ||
export CYAN="\033[1;36m" | ||
export GREY="\033[0;37m" | ||
export RESET="\033[m" | ||
|
||
check_command() { | ||
if ! command -v "$1" &> /dev/null | ||
then | ||
echo "$1 could not be found." | ||
echo "Exiting." | ||
exit 1 | ||
fi | ||
} | ||
|
||
print_error() { | ||
echo -e "${RED}$1${RESET}" | ||
} | ||
|
||
print_info() { | ||
echo -e "${CYAN}$1${RESET}" | ||
} | ||
print_success() { | ||
echo -e "${GREEN}$1${RESET}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
set -euf -o pipefail | ||
|
||
source scripts/common.sh | ||
|
||
check_command jq | ||
check_command npx | ||
|
||
if ! npm exec --no -- wrangler --version &> /dev/null | ||
then | ||
# shellcheck disable=SC2016 | ||
print_error "wrangler could not be found. Did you run \`npm install\` ?" | ||
print_error "Exiting." | ||
exit 1 | ||
fi | ||
|
||
# shellcheck disable=SC2034 | ||
KV_ID=$(npx wrangler kv:namespace list | jq -r '.[] | select(.title == "bankman-KV") | .id') | ||
|
||
npx wrangler kv:key --namespace-id $KV_ID put 'transaction-matchers' "$(cat .notify-patterns.json | jq -c .)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters