From: Luigi Pinca Date: Fri, 30 Nov 2018 08:41:28 +0000 (+0100) Subject: bumped canvas to version 2.1.x X-Git-Url: https://git.saalbach.dev/?a=commitdiff_plain;h=2c3a8f55b808881f4c945b8ff7c3124ecc87e6b5;p=binbsis50.git bumped canvas to version 2.1.x --- diff --git a/lib/captcha.js b/lib/captcha.js index adba350..640bdc0 100644 --- a/lib/captcha.js +++ b/lib/captcha.js @@ -1,11 +1,8 @@ 'use strict'; -/** - * Module dependencies. - */ +const { createCanvas } = require('canvas'); -var canvas = require('canvas') - , characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; +const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; /** * Captcha constructor. @@ -13,7 +10,7 @@ var canvas = require('canvas') function Captcha() { this.code = ''; - this.canvas = new canvas(74, 26); + this.canvas = createCanvas(74, 26); this.initialize(); } @@ -26,7 +23,7 @@ Captcha.prototype.initialize = function() { this.code += characters[Math.floor(Math.random() * characters.length)]; } - var ctx = this.canvas.getContext('2d'); + const ctx = this.canvas.getContext('2d'); ctx.fillStyle = '#DDDDDD'; ctx.fillRect(0, 0, 74, 26); diff --git a/package.json b/package.json index 9897525..cc50240 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "dependencies": { "async": "2.6.x", "body-parser": "1.18.x", - "canvas": "1.6.x", + "canvas": "2.1.x", "connect-redis": "3.3.x", "cookie-parser": "1.4.x", "express": "4.16.x",