/poller

Primary LanguageTypeScript

Poller

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Run on Docker

docker build . -t poller

docker run \
  -dit \
  -p 3004:3000 \
  --user 1000:1000 \
  --cap-add=SYS_ADMIN \
  --network bridge \
  --env-file .env.production \
  -e PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome \
  --name poller \
  poller

According to the Puppeteer documentation:

Note the image requires the SYS_ADMIN capability since the browser runs in sandbox mode.

API Documentation

See the documentation generated by Swagger by accessing http://localhost:3000/api.

Test

Note: Tests must always be executed serially (using the --runInBand flag). The current scripts already include it. This is because the database is dropped after each test case, which must happen synchronously.

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Future Work

  • Allow JSON requests.
  • (Done ✅) Allow requests where the HTML content is loaded using Javascript.
  • (Done ✅) Add more polling rules.
  • (Done ✅) Create a UI.
  • Configure request headers (e.g. API key, etc).
  • (Done ✅) Allow rules to modify the notification message using tokens (e.g. page contains $count occurrences of "hello world"). Tokens should be specific to each individual rule.

Tools Used

  • NestJS Framework
  • TypeScript
  • Jest
  • TypeORM
  • PostgreSQL