Welcome to the Stock Check tool. This tool allows you to search for specific DOM elements on web pages and then send a notification to your own Discord server.
The tool was originally built to send a notification when a certain product is back in stock in a store.
- Clone the repo
run npm ci
with node 18.X (if you have installed nvm, run "nvm use")- create a
.env
file in project root - create a
shop-list.json
file in /src folder - build the project with
npm run build
command
To protect sensitive information like API keys the project uses env files.
DISCORD_API_KEY="YOUR DISCORD BOT API KEY"
CHANNEL_ID="THE ID OF THE DISCORD CHANNEL WHERE YOU WANT TO BECOME THE NOTIFICATION"
LOGIN_MSG="OPTIONAL: A CUSTOM LOGIN MESSAGE"
All metadata for the web pages that are to be analyzed are listed here.
[
{
"shopName": "NAME OF THE WEBSITE",
"productEndpoint": "URL TO THE WEBSITE",
"searchQuery": "THE SELECTOR YOU WANT TO SEARCH",
"showProductLink": false
}
]
Multiple web pages can also be configured:
[
{
"shopName": "NAME OF THE WEBSITE",
"productEndpoint": "URL TO THE WEBSITE",
"searchQuery": "THE SELECTOR YOU WANT TO SEARCH",
"showProductLink": false
},
{
"shopName": "NAME OF THE WEBSITE",
"productEndpoint": "URL TO THE WEBSITE",
"searchQuery": "THE SELECTOR YOU WANT TO SEARCH",
"showProductLink": false
}
]
The NodeJs script can also run in a Docker environment:
- Navigate into project dir
cd in-stock-check
- Compile the script:
npm run build
- Create .env file with necessary data and pass it as a secret:
docker build -t "in-stock-check" --secret id=in-stock-env,src=.env .
Please follow the Prettier, ESLint and TypeScript rules included in this project. You can check your code with the following commands:
Run ESLint:
npm run lint
Run Prettier:
npm run prettier
Compile TypeScript:
npm run build
While commiting, please use one of the following types:
['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test']
Example:
git commit -m "chore: update packages"