From 90831e61ac74d3a0a6df8694a44cf319d7c785a3 Mon Sep 17 00:00:00 2001 From: chris48s Date: Sat, 3 Jul 2021 21:13:58 +0100 Subject: [PATCH] deprecate [beerpay] (#6708) Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com> --- services/beerpay/beerpay.service.js | 52 ++++++----------------------- services/beerpay/beerpay.tester.js | 22 +++++------- 2 files changed, 20 insertions(+), 54 deletions(-) diff --git a/services/beerpay/beerpay.service.js b/services/beerpay/beerpay.service.js index 9d2167647cafd..287eb9296a1de 100644 --- a/services/beerpay/beerpay.service.js +++ b/services/beerpay/beerpay.service.js @@ -1,43 +1,13 @@ 'use strict' -const Joi = require('joi') -const { BaseJsonService } = require('..') - -const schema = Joi.object({ - total_amount: Joi.number().min(0).required(), -}).required() - -module.exports = class Beerpay extends BaseJsonService { - static category = 'funding' - static route = { base: 'beerpay', pattern: ':user/:project' } - - static examples = [ - { - title: 'Beerpay', - namedParams: { user: 'hashdog', project: 'scrapfy-chrome-extension' }, - staticPreview: this.render({ totalAmount: 10 }), - }, - ] - - static defaultBadgeData = { label: 'beerpay' } - - static render({ totalAmount }) { - return { - message: `$${totalAmount}`, - color: totalAmount > 0 ? 'blue' : 'red', - } - } - - async handle({ user, project }) { - // e.g. JSON response: https://beerpay.io/api/v1/beerpay/projects/beerpay.io - // e.g. SVG badge: https://beerpay.io/beerpay/beerpay.io/badge.svg?style=flat-square - const { total_amount: totalAmount } = await this._requestJson({ - schema, - url: `https://beerpay.io/api/v1/${user}/projects/${project}`, - errorMessages: { - 404: 'project not found', - }, - }) - return this.constructor.render({ totalAmount }) - } -} +const { deprecatedService } = require('..') + +module.exports = deprecatedService({ + category: 'build', + route: { + base: 'beerpay', + pattern: ':various+', + }, + label: 'beerpay', + dateAdded: new Date('2021-07-03'), +}) diff --git a/services/beerpay/beerpay.tester.js b/services/beerpay/beerpay.tester.js index e52ec83c5a7bc..3901ec29def3d 100644 --- a/services/beerpay/beerpay.tester.js +++ b/services/beerpay/beerpay.tester.js @@ -1,18 +1,14 @@ 'use strict' -const { withRegex } = require('../test-validators') -const t = (module.exports = require('../tester').createServiceTester()) - -const amountOfMoney = withRegex(/^\$[0-9]+(\.[0-9]+)?/) - -t.create('funding').get('/hashdog/scrapfy-chrome-extension.json').expectBadge({ - label: 'beerpay', - message: amountOfMoney, -}) - -t.create('funding (unknown project)') - .get('/hashdog/not-a-real-project.json') +const { ServiceTester } = require('../tester') +const t = (module.exports = new ServiceTester({ + id: 'beerpay', + title: 'Beerpay', +})) + +t.create('no longer available (previously beerpay)') + .get('/hashdog/scrapfy-chrome-extension.json') .expectBadge({ label: 'beerpay', - message: 'project not found', + message: 'no longer available', })