Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: esbenp/pdf-bot
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.4.4
Choose a base ref
...
head repository: esbenp/pdf-bot
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Nov 9, 2017

  1. bump

    esbenp committed Nov 9, 2017
    Copy the full SHA
    60086b2 View commit details

Commits on Nov 13, 2017

  1. Add Postgres driver

    This commit will refactor the code-base into separate database drivers. We have experienced after
    using pdf-bot for a while that lowdb does not handle concurrency very well. Therefore, we have
    decided to use Postgres instead. pdf-bot will still have the lowdb option for minimum installation.
    esbenp committed Nov 13, 2017
    Copy the full SHA
    380e927 View commit details
  2. finish postgres

    esbenp committed Nov 13, 2017
    Copy the full SHA
    fe56e64 View commit details
  3. fix tests

    esbenp committed Nov 13, 2017
    Copy the full SHA
    4ac547b View commit details
  4. Merge pull request #14 from esbenp/postgres

    Add Postgres driver
    esbenp authored Nov 13, 2017
    Copy the full SHA
    cc7c5af View commit details
  5. bump version

    esbenp committed Nov 13, 2017
    Copy the full SHA
    8b050b6 View commit details
  6. make sure to close connections

    esbenp committed Nov 13, 2017
    Copy the full SHA
    43e00cc View commit details
  7. add close to api

    esbenp committed Nov 13, 2017
    Copy the full SHA
    b78483f View commit details
  8. fix tests

    esbenp committed Nov 13, 2017
    Copy the full SHA
    fe28f31 View commit details

Commits on Nov 14, 2017

  1. fix purge

    esbenp committed Nov 14, 2017
    Copy the full SHA
    eb6c923 View commit details

Commits on Jan 7, 2018

  1. Add support for passing a database URL and ssl config

    When running on with [PostgreSQL on Heroku](https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js), the connection parameters are provided as a URL string. The pg package supports this, it's just a matter of passing it through the pdf-bot config.
    
    Additionally, this PR adds support for the other possible `pg` [client options](https://node-postgres.com/api/client).
    danielwestendorf committed Jan 7, 2018
    Copy the full SHA
    55dee0d View commit details

Commits on Jan 8, 2018

  1. Merge pull request #16 from danielwestendorf/pg-options

    Add support for passing a database URL and other PostgreSQL options
    esbenp authored Jan 8, 2018
    Copy the full SHA
    8c228bc View commit details
  2. bump version

    esbenp committed Jan 8, 2018
    Copy the full SHA
    f304c3f View commit details

Commits on Jan 15, 2018

  1. Upgrade html-pdf-chrome to v0.4.2

    html-pdf-chrome's release of v0.4.2 [fixes a bug](westy92/html-pdf-chrome#115) that causes pdf-bot to hang when processing if the server requested is unresponsive due to a network error.
    danielwestendorf committed Jan 15, 2018
    Copy the full SHA
    05f60b4 View commit details

Commits on Mar 26, 2018

  1. Update lowdb.js

    Fixes #15
    axxag authored Mar 26, 2018
    Copy the full SHA
    e11e894 View commit details
  2. Merge pull request #17 from danielwestendorf/upgrade-html-pdf-chrome

    Upgrade html-pdf-chrome to v0.4.2
    esbenp authored Mar 26, 2018
    Copy the full SHA
    eef9f15 View commit details
  3. Merge pull request #19 from agentilela/master

    Update lowdb.js
    esbenp authored Mar 26, 2018
    Copy the full SHA
    1ee1216 View commit details
  4. bump version

    esbenp authored Mar 26, 2018
    Copy the full SHA
    6eaec8b View commit details

Commits on Jul 30, 2018

  1. Allow for quicker generation by generating again at the end of shift:…

    …all and when pushing to queue
    esbenp committed Jul 30, 2018
    Copy the full SHA
    48fe04d View commit details
  2. Copy the full SHA
    6b7d4c0 View commit details
  3. Update README

    esbenp authored Jul 30, 2018
    Copy the full SHA
    28fc2b9 View commit details

Commits on Aug 22, 2018

  1. add debug

    esbenp committed Aug 22, 2018
    Copy the full SHA
    5bf58dc View commit details
  2. Copy the full SHA
    a2edd1e View commit details

Commits on Sep 10, 2020

  1. Bump node-fetch from 1.7.3 to 2.6.1

    Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 1.7.3 to 2.6.1.
    - [Release notes](https://github.com/bitinn/node-fetch/releases)
    - [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
    - [Commits](node-fetch/node-fetch@1.7.3...v2.6.1)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Sep 10, 2020
    Copy the full SHA
    fcc0410 View commit details

Commits on Oct 31, 2020

  1. Merge pull request #38 from esbenp/dependabot/npm_and_yarn/node-fetch…

    …-2.6.1
    
    Bump node-fetch from 1.7.3 to 2.6.1
    esbenp authored Oct 31, 2020
    Copy the full SHA
    5162235 View commit details
Showing with 961 additions and 391 deletions.
  1. +62 −10 README.md
  2. +255 −126 bin/pdf-bot.js
  3. +6 −0 examples/pdf-bot.config.js
  4. +5 −4 package.json
  5. +17 −9 src/api.js
  6. +237 −0 src/db/lowdb.js
  7. +256 −0 src/db/pgsql.js
  8. +2 −1 src/pdfGenerator.js
  9. +49 −180 src/queue.js
  10. +11 −7 test/api.test.js
  11. +4 −4 test/pdfGenerator.test.js
  12. +57 −50 test/queue.test.js
72 changes: 62 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@ api.post('/hook', function (req, res) {
We setup our crontab to continuously look for jobs that have not yet been completed.

```bash
* * * * * node $(npm bin -g)/pdf-bot -c ./pdf-bot.config.js shift >> /var/log/pdfbot.log 2>&1
* * * * * node $(npm bin -g)/pdf-bot -c ./pdf-bot.config.js shift:all >> /var/log/pdfbot.log 2>&1
* * * * * node $(npm bin -g)/pdf-bot -c ./pdf-bot.config.js ping:retry-failed >> /var/log/pdfbot.log 2>&1
```

@@ -166,10 +166,10 @@ Let us assume I want to generate a PDF for `https://esbenp.github.io`. I can add
$ pdf-bot -c ./pdf-bot.config.js push https://esbenp.github.io --meta '{"id":1}'
```

Next, if my crontab is not setup to run it automatically I can run it using the `shift` command
Next, if my crontab is not setup to run it automatically I can run it using the `shift:all` command

```bash
$ pdf-bot -c ./pdf-bot.config.js shift
$ pdf-bot -c ./pdf-bot.config.js shift:all
```

This will look for the oldest uncompleted job and run it.
@@ -283,6 +283,56 @@ curl -X POST -H 'Authorization: Bearer api-token' -H 'Content-Type: application/
}'
```

## Database

### LowDB (file-database) (default)

If you have low conurrency (run a job every now and then) you can use the default database driver that uses LowDB.

```javascript
var LowDB = require('pdf-bot/src/db/lowdb')

module.exports = {
api: {
token: 'api-token'
},
db: LowDB({
lowDbOptions: {},
path: '' // defaults to $storagePath/db/db.json
}),
webhook: {
secret: '1234',
url: 'http://localhost:3000/webhooks/pdf'
}
}
```

### PostgreSQL

```javascript
var pgsql = require('pdf-bot/src/db/pgsql')

module.exports = {
api: {
token: 'api-token'
},
db: pgsql({
database: 'pdfbot',
username: 'pdfbot',
password: 'pdfbot',
port: 5432
}),
webhook: {
secret: '1234',
url: 'http://localhost:3000/webhooks/pdf'
}
}
```

Optionally, you can specify a database url by specifying a `connectionString`.

To install the necessary database tables, run `db:migrate`. You can also destroy the database by running `db:destroy`.

## Storage

Currently `pdf-bot` comes bundled with build-in support for storing PDFs on Amazon S3.
@@ -332,9 +382,12 @@ module.exports = {
api: {
// The port your express.js instance listens to requests from. (default: 3000)
port: 3000,
// Spawn command when a job has been pushed to the API
postPushCommand: ['/home/user/.npm-global/bin/pdf-bot', ['-c', './pdf-bot.config.js', 'shift:all']],
// The token used to validate requests to your API. Not required, but 100% recommended.
token: 'api-token'
},
db: LowDB(), // see other drivers under Database
// html-pdf-chrome
generator: {
// Triggers that specify when the PDF should be generated
@@ -351,20 +404,16 @@ module.exports = {
// How many times should pdf-bot try to generate a PDF?
// (default: 5)
generationMaxTries: 5,
// How many generations to run at the same time when using shift:all
parallelism: 4,
// How frequent should pdf-bot retry failed webhook pings?
// (default: 1 min, 3 min, 10 min, 30 min, 60 min)
webhookRetryStrategy: function(job, retries) {
return decaySchedule[retries - 1] ? decaySchedule[retries - 1] : 0
},
// How many times should pdf-bot try to ping a webhook?
// (default: 5)
webhookMaxTries: 5,
// In what path should the database be stored?
path: 'storage/db/db.json',
// pdf-bot uses lowdb. You can pass options to it here.
lowDbOptions: {

}
webhookMaxTries: 5
},
storage: {
's3': createS3Config({
@@ -412,6 +461,8 @@ $ pdf-bot.js --config ./examples/pdf-bot.config.js --help
Commands:

api Start the API
db:migrate
db:destroy
install
generate [jobID] Generate PDF for job
jobs [options] List all completed jobs
@@ -421,6 +472,7 @@ $ pdf-bot.js --config ./examples/pdf-bot.config.js --help
purge [options] Will remove all completed jobs
push [options] [url] Push new job to the queue
shift Run the next job in the queue
shift:all Run all unfinished jobs in the queue
```

## Debug mode
Loading