refactor: use badge-maker replace openbadge
and change telemetry url, because not a api
This commit is contained in:
parent
5a3a621fd6
commit
b4f2170e51
@ -25,6 +25,7 @@
|
|||||||
"@types/uuid": "^9.0.3",
|
"@types/uuid": "^9.0.3",
|
||||||
"antd": "^5.9.3",
|
"antd": "^5.9.3",
|
||||||
"axios": "^1.5.0",
|
"axios": "^1.5.0",
|
||||||
|
"badge-maker": "^3.3.1",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"clsx": "^2.0.0",
|
"clsx": "^2.0.0",
|
||||||
"colord": "^2.9.3",
|
"colord": "^2.9.3",
|
||||||
@ -48,7 +49,6 @@
|
|||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"nanoid": "^3.3.6",
|
"nanoid": "^3.3.6",
|
||||||
"nodemailer": "^6.9.5",
|
"nodemailer": "^6.9.5",
|
||||||
"openbadge": "^1.0.4",
|
|
||||||
"passport": "^0.6.0",
|
"passport": "^0.6.0",
|
||||||
"passport-jwt": "^4.0.1",
|
"passport-jwt": "^4.0.1",
|
||||||
"ping": "^0.4.4",
|
"ping": "^0.4.4",
|
||||||
|
@ -34,6 +34,9 @@ dependencies:
|
|||||||
axios:
|
axios:
|
||||||
specifier: ^1.5.0
|
specifier: ^1.5.0
|
||||||
version: 1.5.0
|
version: 1.5.0
|
||||||
|
badge-maker:
|
||||||
|
specifier: ^3.3.1
|
||||||
|
version: 3.3.1
|
||||||
bcryptjs:
|
bcryptjs:
|
||||||
specifier: ^2.4.3
|
specifier: ^2.4.3
|
||||||
version: 2.4.3
|
version: 2.4.3
|
||||||
@ -103,9 +106,6 @@ dependencies:
|
|||||||
nodemailer:
|
nodemailer:
|
||||||
specifier: ^6.9.5
|
specifier: ^6.9.5
|
||||||
version: 6.9.5
|
version: 6.9.5
|
||||||
openbadge:
|
|
||||||
specifier: ^1.0.4
|
|
||||||
version: 1.0.4
|
|
||||||
passport:
|
passport:
|
||||||
specifier: ^0.6.0
|
specifier: ^0.6.0
|
||||||
version: 0.6.0
|
version: 0.6.0
|
||||||
@ -2280,6 +2280,12 @@ packages:
|
|||||||
engines: {node: '>=0.4.2'}
|
engines: {node: '>=0.4.2'}
|
||||||
dev: false
|
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:
|
/ansi-regex@2.1.1:
|
||||||
resolution: {integrity: sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==}
|
resolution: {integrity: sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@ -2482,6 +2488,15 @@ packages:
|
|||||||
resolution: {integrity: sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==}
|
resolution: {integrity: sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==}
|
||||||
dev: false
|
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:
|
/balanced-match@1.0.2:
|
||||||
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
||||||
|
|
||||||
@ -2515,6 +2530,10 @@ packages:
|
|||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/binary-search@1.3.6:
|
||||||
|
resolution: {integrity: sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/body-parser@1.20.1:
|
/body-parser@1.20.1:
|
||||||
resolution: {integrity: sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==}
|
resolution: {integrity: sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==}
|
||||||
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
|
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
|
||||||
@ -2637,6 +2656,12 @@ packages:
|
|||||||
escape-string-regexp: 1.0.5
|
escape-string-regexp: 1.0.5
|
||||||
supports-color: 5.5.0
|
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:
|
/chokidar@3.5.3:
|
||||||
resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
|
resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
|
||||||
engines: {node: '>= 8.10.0'}
|
engines: {node: '>= 8.10.0'}
|
||||||
@ -2697,6 +2722,10 @@ packages:
|
|||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/color-convert@0.5.3:
|
||||||
|
resolution: {integrity: sha512-RwBeO/B/vZR3dfKL1ye/vx8MHZ40ugzpyfeVG5GsiuGnrlMWe2o8wxBbLCpw9CsxV+wHuzYlCiWnybrIA0ling==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/color-convert@1.9.3:
|
/color-convert@1.9.3:
|
||||||
resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==}
|
resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -2869,6 +2898,14 @@ packages:
|
|||||||
- encoding
|
- encoding
|
||||||
dev: false
|
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:
|
/css-in-js-utils@3.1.0:
|
||||||
resolution: {integrity: sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A==}
|
resolution: {integrity: sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A==}
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -2883,6 +2920,10 @@ packages:
|
|||||||
source-map: 0.6.1
|
source-map: 0.6.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/css-unit-converter@1.1.2:
|
||||||
|
resolution: {integrity: sha512-IiJwMC8rdZE0+xiEZHeru6YoONC4rfPMqGm2W85jMIbkFvv5nFTwJVFHam2eFrN6txmoUYFAFXiv8ICVeTO0MA==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/csscolorparser@1.0.3:
|
/csscolorparser@1.0.3:
|
||||||
resolution: {integrity: sha512-umPSgYwZkdFoUrH5hIq5kf0wPSXiro51nPw0j2K/c83KflkPSTBGMz6NJvMB+07VlL0y7VPo6QJcDjcgKTTm3w==}
|
resolution: {integrity: sha512-umPSgYwZkdFoUrH5hIq5kf0wPSXiro51nPw0j2K/c83KflkPSTBGMz6NJvMB+07VlL0y7VPo6QJcDjcgKTTm3w==}
|
||||||
dev: false
|
dev: false
|
||||||
@ -4265,10 +4306,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==}
|
resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/lodash@3.10.1:
|
|
||||||
resolution: {integrity: sha512-9mDDwqVIma6OZX79ZlDACZl8sBm0TEnkf99zV3iMA4GzkIT/9hiqP5mY0HoT1iNLCrKc/R1HByV+yJfRWVJryQ==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/lodash@4.17.21:
|
/lodash@4.17.21:
|
||||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||||
dev: false
|
dev: false
|
||||||
@ -4683,20 +4720,6 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
wrappy: 1.0.2
|
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:
|
/pac-proxy-agent@7.0.1:
|
||||||
resolution: {integrity: sha512-ASV8yU4LLKBAjqIPMbrgtaKIvxQri/yh2OpI+S6hVa9JRkUI3Y3NPFbfngDtY7oFtSMD3w31Xns89mDa3Feo5A==}
|
resolution: {integrity: sha512-ASV8yU4LLKBAjqIPMbrgtaKIvxQri/yh2OpI+S6hVa9JRkUI3Y3NPFbfngDtY7oFtSMD3w31Xns89mDa3Feo5A==}
|
||||||
engines: {node: '>= 14'}
|
engines: {node: '>= 14'}
|
||||||
@ -6449,10 +6472,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-Eet/eeMhkO6TX8mnUteS9zgPbUMQa4I6Kkp5ORiBD5476/m+PIRiumP5tmh5ioJpH7k51Kehawy2UDfsnxxY8Q==}
|
resolution: {integrity: sha512-Eet/eeMhkO6TX8mnUteS9zgPbUMQa4I6Kkp5ORiBD5476/m+PIRiumP5tmh5ioJpH7k51Kehawy2UDfsnxxY8Q==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/tiny-inflate@1.0.3:
|
|
||||||
resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/tiny-lru@11.0.1:
|
/tiny-lru@11.0.1:
|
||||||
resolution: {integrity: sha512-iNgFugVuQgBKrqeO/mpiTTgmBsTP0WL6yeuLfLs/Ctf0pI/ixGqIRm8sDCwMcXGe9WWvt2sGXI5mNqZbValmJg==}
|
resolution: {integrity: sha512-iNgFugVuQgBKrqeO/mpiTTgmBsTP0WL6yeuLfLs/Ctf0pI/ixGqIRm8sDCwMcXGe9WWvt2sGXI5mNqZbValmJg==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
@ -39,7 +39,7 @@ app.disable('x-powered-by');
|
|||||||
app.use('/api/user', userRouter);
|
app.use('/api/user', userRouter);
|
||||||
app.use('/api/website', websiteRouter);
|
app.use('/api/website', websiteRouter);
|
||||||
app.use('/api/workspace', workspaceRouter);
|
app.use('/api/workspace', workspaceRouter);
|
||||||
app.use('/api/telemetry', telemetryRouter);
|
app.use('/telemetry', telemetryRouter);
|
||||||
|
|
||||||
app.use('/trpc', trpcExpressMiddleware);
|
app.use('/trpc', trpcExpressMiddleware);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { Router } from 'express';
|
|||||||
import { query, validate } from '../middleware/validate';
|
import { query, validate } from '../middleware/validate';
|
||||||
import { recordTelemetryEvent, sumTelemetryEvent } from '../model/telemetry';
|
import { recordTelemetryEvent, sumTelemetryEvent } from '../model/telemetry';
|
||||||
import { numify } from '../utils/common';
|
import { numify } from '../utils/common';
|
||||||
const openBadge = require('openbadge');
|
import { makeBadge } from 'badge-maker';
|
||||||
|
|
||||||
export const telemetryRouter = Router();
|
export const telemetryRouter = Router();
|
||||||
|
|
||||||
@ -37,19 +37,10 @@ telemetryRouter.get(
|
|||||||
recordTelemetryEvent(req);
|
recordTelemetryEvent(req);
|
||||||
const num = await sumTelemetryEvent(req);
|
const num = await sumTelemetryEvent(req);
|
||||||
|
|
||||||
const svg = await new Promise((resolve, reject) => {
|
const svg = makeBadge({
|
||||||
openBadge(
|
label: String(title),
|
||||||
{
|
message: numify(num + start),
|
||||||
text: [title, numify(num + start)],
|
color: 'green',
|
||||||
},
|
|
||||||
(err: any, badgeSvg: string) => {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
} else {
|
|
||||||
resolve(badgeSvg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
res.header('Content-Type', 'image/svg+xml').send(svg);
|
res.header('Content-Type', 'image/svg+xml').send(svg);
|
||||||
|
Loading…
Reference in New Issue
Block a user