Version 1.0.3 - Ajout de WebMetrics en Prévsion

This commit is contained in:
Raphael 2024-01-13 17:20:34 +01:00
parent 02b18d7ff0
commit bd92cf6c4d
7 changed files with 34 additions and 6 deletions

7
data/metrics.json Normal file
View File

@ -0,0 +1,7 @@
[
{
"name": "visitorCounted",
"description": "Nombre de visiteurs",
"value": 17
}
]

View File

@ -188,6 +188,6 @@
"deaf": false,
"bio": "",
"banner": null,
"token": "fdc6a37b-0696-4951-9c91-5c59494264ec"
"token": "adf077e6-1fac-4c0c-9468-6ebe698c550a"
}
]

15
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "subsonics-web",
"version": "0.6.0",
"version": "1.0.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "subsonics-web",
"version": "0.6.0",
"version": "1.0.3",
"dependencies": {
"cookie": "^0.5.0",
"cookie-parser": "^1.4.6",
@ -20,6 +20,7 @@
"pm2": "^5.3.0",
"socket.io": "^4.6.1",
"uuid": "^9.0.0",
"webmetrik": "^0.1.3",
"ytfps": "^1.1.0"
}
},
@ -3391,6 +3392,11 @@
"lodash": "^4.17.14"
}
},
"node_modules/webmetrik": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/webmetrik/-/webmetrik-0.1.3.tgz",
"integrity": "sha512-UhCK1qTwAuhw17by2/lS5fL9o9uLyKBZ9+WvIY+VFSmuTcYr6zAVD4E0ns0M69NodHznH+L4a5mOyIfsq0o8cw=="
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
@ -5929,6 +5935,11 @@
}
}
},
"webmetrik": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/webmetrik/-/webmetrik-0.1.3.tgz",
"integrity": "sha512-UhCK1qTwAuhw17by2/lS5fL9o9uLyKBZ9+WvIY+VFSmuTcYr6zAVD4E0ns0M69NodHznH+L4a5mOyIfsq0o8cw=="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View File

@ -1,7 +1,7 @@
{
"name": "subsonics-web",
"author": "Raphix",
"version": "1.0.2",
"version": "1.0.3",
"nodemonConfig": {
"ext": "js, html",
"ignore": [
@ -24,6 +24,7 @@
"pm2": "^5.3.0",
"socket.io": "^4.6.1",
"uuid": "^9.0.0",
"webmetrik": "^0.1.4",
"ytfps": "^1.1.0"
},
"scripts": {

View File

@ -19,7 +19,8 @@ const __glob = {
README: root + path.sep + "README.md",
PLAYLIST: root + path.sep + "data" + path.sep + "playlist.json",
RADIO: root + path.sep + "data" + path.sep + "radios.json",
LOGS: root + path.sep + "src" + path.sep + "modules" + path.sep + "logs"
LOGS: root + path.sep + "src" + path.sep + "modules" + path.sep + "logs",
METRIC_FILE: root + path.sep + "data" + path.sep + "metrics.json",
};
const webroot = __glob.WEB_DIR + path.sep

View File

@ -5,6 +5,11 @@ var auth = require("../../modules/sub-auth")
var log = require("../../modules/sub-log")
var { __glob } = require("../../modules/global-variables")
var uuid = require("uuid")
const metric = require("webmetrik")
metric.setMetricFile(__glob.METRIC_FILE)
metric.publishMetrics("8001", "raphraph")
var fs = require("fs")
var md = require('markdown-it')({
@ -36,6 +41,10 @@ var md = require('markdown-it')({
router.get('/', function(req, res, next) {
const visitorCounted = new metric.Metric("visitorCounted", "Nombre de visiteurs")
visitorCounted.setValue(visitorCounted.getValue() + 1)
if(!auth.checkUser(req.cookies.token)) {
res.redirect("/login")

View File

@ -31,7 +31,6 @@ router.get('/redirect', function(req, res, next) {
var user = data
const token = uuid.v4().toString()
user.token = token
auth.addUser(user)