diff --git a/package.json b/package.json index efc4027..a42d256 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@types/uuid": "^9.0.3", "antd": "^5.9.3", "axios": "^1.5.0", + "badge-maker": "^3.3.1", "bcryptjs": "^2.4.3", "clsx": "^2.0.0", "colord": "^2.9.3", @@ -48,7 +49,6 @@ "morgan": "^1.10.0", "nanoid": "^3.3.6", "nodemailer": "^6.9.5", - "openbadge": "^1.0.4", "passport": "^0.6.0", "passport-jwt": "^4.0.1", "ping": "^0.4.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b28da9a..cbfd22a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,6 +34,9 @@ dependencies: axios: specifier: ^1.5.0 version: 1.5.0 + badge-maker: + specifier: ^3.3.1 + version: 3.3.1 bcryptjs: specifier: ^2.4.3 version: 2.4.3 @@ -103,9 +106,6 @@ dependencies: nodemailer: specifier: ^6.9.5 version: 6.9.5 - openbadge: - specifier: ^1.0.4 - version: 1.0.4 passport: specifier: ^0.6.0 version: 0.6.0 @@ -2280,6 +2280,12 @@ packages: engines: {node: '>=0.4.2'} dev: false + /anafanafo@2.0.0: + resolution: {integrity: sha512-Nlfq7NC4AOkTJerWRIZcOAiMNtIDVIGWGvQ98O7Jl6Kr2Dk0dX5u4MqN778kSRTy5KRqchpLdF2RtLFEz9FVkQ==} + dependencies: + char-width-table-consumer: 1.0.0 + dev: false + /ansi-regex@2.1.1: resolution: {integrity: sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==} engines: {node: '>=0.10.0'} @@ -2482,6 +2488,15 @@ packages: resolution: {integrity: sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==} dev: false + /badge-maker@3.3.1: + resolution: {integrity: sha512-OO/PS7Zg2E6qaUWzHEHt21Q5VjcFBAJVA8ztgT/fIdSZFBUwoyeo0ZhA6V5tUM8Vcjq8DJl6jfGhpjESssyqMQ==} + engines: {node: '>= 10', npm: '>= 5'} + hasBin: true + dependencies: + anafanafo: 2.0.0 + css-color-converter: 2.0.0 + dev: false + /balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -2515,6 +2530,10 @@ packages: engines: {node: '>=8'} dev: true + /binary-search@1.3.6: + resolution: {integrity: sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA==} + dev: false + /body-parser@1.20.1: resolution: {integrity: sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} @@ -2637,6 +2656,12 @@ packages: escape-string-regexp: 1.0.5 supports-color: 5.5.0 + /char-width-table-consumer@1.0.0: + resolution: {integrity: sha512-Fz4UD0LBpxPgL9i29CJ5O4KANwaMnX/OhhbxzvNa332h+9+nRKyeuLw4wA51lt/ex67+/AdsoBQJF3kgX2feYQ==} + dependencies: + binary-search: 1.3.6 + dev: false + /chokidar@3.5.3: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} engines: {node: '>= 8.10.0'} @@ -2697,6 +2722,10 @@ packages: engines: {node: '>=6'} dev: false + /color-convert@0.5.3: + resolution: {integrity: sha512-RwBeO/B/vZR3dfKL1ye/vx8MHZ40ugzpyfeVG5GsiuGnrlMWe2o8wxBbLCpw9CsxV+wHuzYlCiWnybrIA0ling==} + dev: false + /color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} dependencies: @@ -2869,6 +2898,14 @@ packages: - encoding dev: false + /css-color-converter@2.0.0: + resolution: {integrity: sha512-oLIG2soZz3wcC3aAl/7Us5RS8Hvvc6I8G8LniF/qfMmrm7fIKQ8RIDDRZeKyGL2SrWfNqYspuLShbnjBMVWm8g==} + dependencies: + color-convert: 0.5.3 + color-name: 1.1.4 + css-unit-converter: 1.1.2 + dev: false + /css-in-js-utils@3.1.0: resolution: {integrity: sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A==} dependencies: @@ -2883,6 +2920,10 @@ packages: source-map: 0.6.1 dev: false + /css-unit-converter@1.1.2: + resolution: {integrity: sha512-IiJwMC8rdZE0+xiEZHeru6YoONC4rfPMqGm2W85jMIbkFvv5nFTwJVFHam2eFrN6txmoUYFAFXiv8ICVeTO0MA==} + dev: false + /csscolorparser@1.0.3: resolution: {integrity: sha512-umPSgYwZkdFoUrH5hIq5kf0wPSXiro51nPw0j2K/c83KflkPSTBGMz6NJvMB+07VlL0y7VPo6QJcDjcgKTTm3w==} dev: false @@ -4265,10 +4306,6 @@ packages: resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==} dev: false - /lodash@3.10.1: - resolution: {integrity: sha512-9mDDwqVIma6OZX79ZlDACZl8sBm0TEnkf99zV3iMA4GzkIT/9hiqP5mY0HoT1iNLCrKc/R1HByV+yJfRWVJryQ==} - dev: false - /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: false @@ -4683,20 +4720,6 @@ packages: dependencies: wrappy: 1.0.2 - /openbadge@1.0.4: - resolution: {integrity: sha512-A/yslJpnCgQPPo8sYYDTymAiDfuZI9AzpwuOQdbc0ZIbTcL4BsuVQm2BV63jEiDVatlz4kcFX8Y36hloEuFhGA==} - dependencies: - lodash: 3.10.1 - opentype.js: 0.6.9 - dev: false - - /opentype.js@0.6.9: - resolution: {integrity: sha512-H8TkPyysd95WFQcgBpOoyZA0y6rf5b7iC5Y4ABwHi7ZMc0dqdgwOIeKMh7+rU2SG492Y+6eqJ4uOxLTBVkixjw==} - hasBin: true - dependencies: - tiny-inflate: 1.0.3 - dev: false - /pac-proxy-agent@7.0.1: resolution: {integrity: sha512-ASV8yU4LLKBAjqIPMbrgtaKIvxQri/yh2OpI+S6hVa9JRkUI3Y3NPFbfngDtY7oFtSMD3w31Xns89mDa3Feo5A==} engines: {node: '>= 14'} @@ -6449,10 +6472,6 @@ packages: resolution: {integrity: sha512-Eet/eeMhkO6TX8mnUteS9zgPbUMQa4I6Kkp5ORiBD5476/m+PIRiumP5tmh5ioJpH7k51Kehawy2UDfsnxxY8Q==} dev: false - /tiny-inflate@1.0.3: - resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==} - dev: false - /tiny-lru@11.0.1: resolution: {integrity: sha512-iNgFugVuQgBKrqeO/mpiTTgmBsTP0WL6yeuLfLs/Ctf0pI/ixGqIRm8sDCwMcXGe9WWvt2sGXI5mNqZbValmJg==} engines: {node: '>=12'} diff --git a/src/server/main.ts b/src/server/main.ts index 9a08172..ed728c7 100644 --- a/src/server/main.ts +++ b/src/server/main.ts @@ -39,7 +39,7 @@ app.disable('x-powered-by'); app.use('/api/user', userRouter); app.use('/api/website', websiteRouter); app.use('/api/workspace', workspaceRouter); -app.use('/api/telemetry', telemetryRouter); +app.use('/telemetry', telemetryRouter); app.use('/trpc', trpcExpressMiddleware); diff --git a/src/server/router/telemetry.ts b/src/server/router/telemetry.ts index 8c9be5f..a2adc06 100644 --- a/src/server/router/telemetry.ts +++ b/src/server/router/telemetry.ts @@ -2,7 +2,7 @@ import { Router } from 'express'; import { query, validate } from '../middleware/validate'; import { recordTelemetryEvent, sumTelemetryEvent } from '../model/telemetry'; import { numify } from '../utils/common'; -const openBadge = require('openbadge'); +import { makeBadge } from 'badge-maker'; export const telemetryRouter = Router(); @@ -37,19 +37,10 @@ telemetryRouter.get( recordTelemetryEvent(req); const num = await sumTelemetryEvent(req); - const svg = await new Promise((resolve, reject) => { - openBadge( - { - text: [title, numify(num + start)], - }, - (err: any, badgeSvg: string) => { - if (err) { - reject(err); - } else { - resolve(badgeSvg); - } - } - ); + const svg = makeBadge({ + label: String(title), + message: numify(num + start), + color: 'green', }); res.header('Content-Type', 'image/svg+xml').send(svg);