Compare commits

...

2 Commits

Author SHA1 Message Date
d1d8311b9d Edit path for the metrics.json 2024-01-13 17:13:49 +01:00
097a1f11ff Edit path for the metrics.json 2024-01-13 17:10:12 +01:00
3 changed files with 16 additions and 5 deletions

View File

@ -1,6 +1,7 @@
const fs = require("fs") const fs = require("fs")
const path = require("path") const path = require("path")
var metricsPathFile = metricsPathFile
module.exports.getDate = function (formated) { module.exports.getDate = function (formated) {
@ -45,16 +46,20 @@ module.exports.getDate = function (formated) {
} }
module.exports.setMetricsFile = (path) => {
metricsPathFile = path
}
module.exports.getMetricsFile = () => { module.exports.getMetricsFile = () => {
if(!fs.existsSync(path.join(__dirname, "/metrics.json"))) { if(!fs.existsSync()) {
fs.writeFileSync(path.join(__dirname, "/metrics.json"), JSON.stringify([], null, 2)) fs.writeFileSync(metricsPathFile, JSON.stringify([], null, 2))
} else { } else {
return JSON.parse(fs.readFileSync(path.join(__dirname, "/metrics.json"))) return JSON.parse(fs.readFileSync(metricsPathFile))
} }
} }
module.exports.saveMetricsFile = (data) => { module.exports.saveMetricsFile = (data) => {
fs.writeFileSync(path.join(__dirname, "/metrics.json"), JSON.stringify(data, null, 2)) fs.writeFileSync(metricsPathFile, JSON.stringify(data, null, 2))
} }

View File

@ -5,6 +5,12 @@
const basics = require('./basics.js'); const basics = require('./basics.js');
const fs = require('fs'); const fs = require('fs');
module.exports.setMetricFile = (path) => {
basics.setMetricsFile(path);
const metricsFile = basics.getMetricsFile();
}
module.exports.Metric = class { module.exports.Metric = class {
name; name;
description; description;

View File

@ -1,6 +1,6 @@
{ {
"name": "webmetrik", "name": "webmetrik",
"version": "0.1.0", "version": "0.1.3",
"description": "NodeJS - npm package - Make metrics and make it available by making a httpServer", "description": "NodeJS - npm package - Make metrics and make it available by making a httpServer",
"main": "main.js", "main": "main.js",
"keywords": [], "keywords": [],