Skip to content

Commit

Permalink
Drop bluebird dependency, use native Promise
Browse files Browse the repository at this point in the history
Node.js provides native Promise API for more than six years. Node.js
versions older than that are unmaintained and unsupported for many
years. Thus Bluebird dependency is completely unnecessary.

Resolves alvarcarto#159
  • Loading branch information
jirutka committed Apr 26, 2021
1 parent 4fd7b10 commit a3419ce
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 19 deletions.
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"homepage": "https://github.com/alvarcarto/url-to-pdf-api#readme",
"dependencies": {
"bluebird": "^3.5.0",
"body-parser": "^1.18.2",
"compression": "^1.7.1",
"cors": "^2.8.4",
Expand Down
6 changes: 0 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
const createApp = require('./app');
const enableDestroy = require('server-destroy');
const BPromise = require('bluebird');
const logger = require('./util/logger')(__filename);
const config = require('./config');

BPromise.config({
warnings: config.NODE_ENV !== 'production',
longStackTraces: true,
});

const app = createApp();
const server = app.listen(config.PORT, () => {
logger.info(
Expand Down
3 changes: 1 addition & 2 deletions src/util/express.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const _ = require('lodash');
const BPromise = require('bluebird');

// Route which assumes that the Promise `func` returns, will be resolved
// with data which will be sent as json response.
Expand Down Expand Up @@ -28,7 +27,7 @@ function createRoute(func, responseHandler) {
let valuePromise = callback();
if (!_.isFunction(_.get(valuePromise, 'then'))) {
// It was a not a Promise, so wrap it as a Promise
valuePromise = BPromise.resolve(valuePromise);
valuePromise = Promise.resolve(valuePromise);
}

if (_.isFunction(responseHandler)) {
Expand Down
5 changes: 0 additions & 5 deletions test/test-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
const chai = require('chai');
const fs = require('fs');
const request = require('supertest');
const BPromise = require('bluebird');
const { getResource } = require('./util');
const pdf = require('pdf-parse');
const createApp = require('../src/app');

const DEBUG = false;

BPromise.config({
longStackTraces: true,
});

const app = createApp();

function normalisePdfText(text) {
Expand Down

0 comments on commit a3419ce

Please sign in to comment.