cleanup
This commit is contained in:
		| @@ -1,4 +1,4 @@ | ||||
| const conf = require("../../nationchains/tribes/conf.json"); | ||||
| const conf = require(`${process.env.dirtown}/conf.json`); | ||||
|  | ||||
| const checkHeaders = (req, res, next) => { | ||||
|   /** | ||||
|   | ||||
| @@ -2,7 +2,7 @@ const fs = require("fs-extra"); | ||||
| const glob = require("glob"); | ||||
| const path = require("path"); | ||||
|  | ||||
| const config = require("../../nationchains/tribes/conf.json"); | ||||
| const conf = require(`${process.env.dirtown}/conf.json`); | ||||
|  | ||||
| const hasAccessrighton = (object, action, ownby) => { | ||||
|   /* | ||||
| @@ -16,7 +16,7 @@ const hasAccessrighton = (object, action, ownby) => { | ||||
|  need to check first a person exist with this alias in tribe      | ||||
|   | ||||
|     const person = fs.readJsonSync( | ||||
|       `${conf.dirname}/nationchains/tribes/${req.session.header.xtribe}/persons/${req.session.header.xalias}.json` | ||||
|       `${conf.dirapi}/nationchains/tribes/${req.session.header.xtribe}/persons/${req.session.header.xalias}.json` | ||||
|     ); | ||||
|  | ||||
|   | ||||
|   | ||||
| @@ -3,24 +3,24 @@ const dayjs = require("dayjs"); | ||||
| const glob = require("glob"); | ||||
| const openpgp = require("openpgp"); | ||||
|  | ||||
| const conf = require("../../nationchains/tribes/conf.json"); | ||||
| const conf = require(`${process.env.dirtown}/conf.json`); | ||||
|  | ||||
| const isAuthenticated = async (req, res, next) => { | ||||
|   // once a day rm oldest tokens than 24hours tag job by adding tmp/tokensmenagedone{day} | ||||
|   const currentday = dayjs().date(); | ||||
|   console.log( | ||||
|     "if menagedone" + currentday, | ||||
|     !fs.existsSync(`${__base}tmp/tokensmenagedone${currentday}`) | ||||
|     !fs.existsSync(`${process.env.dirtown}/tmp/tokensmenagedone${currentday}`) | ||||
|   ); | ||||
|   if (!fs.existsSync(`${__base}/tmp/tokens`)) | ||||
|     fs.mkdirSync(`${__base}tmp/tokens`); | ||||
|   if (!fs.existsSync(`${__base}tmp/tokensmenagedone${currentday}`)) { | ||||
|   if (!fs.existsSync(`${process.env.dirtown}/tmp/tokens`)) | ||||
|     fs.mkdirSync(`${process.env.dirtown}/tmp/tokens`); | ||||
|   if (!fs.existsSync(`${process.env.dirtown}/tmp/tokensmenagedone${currentday}`)) { | ||||
|     // clean oldest | ||||
|     const tsday = dayjs().valueOf(); // now in timestamp format | ||||
|     glob.sync(`${__base}tmp/tokensmenagedone*`).forEach((f) => { | ||||
|     glob.sync(`${process.env.dirtown}/tmp/tokensmenagedone*`).forEach((f) => { | ||||
|       fs.removeSync(f); | ||||
|     }); | ||||
|     glob.sync(`${__base}tmp/tokens/*.json`).forEach((f) => { | ||||
|     glob.sync(`${process.env.dirtown}/tmp/tokens/*.json`).forEach((f) => { | ||||
|       if (tsday - parseInt(f.split("_")[1]) > 86400000) fs.remove(f); | ||||
|     }); | ||||
|   } | ||||
| @@ -40,7 +40,7 @@ const isAuthenticated = async (req, res, next) => { | ||||
|     return res.status(401).json(resnotauth); | ||||
|   } | ||||
|  | ||||
|   const tmpfs = `${__base}tmp/tokens/${req.session.header.xalias}_${ | ||||
|   const tmpfs = `${process.env.dirtown}/tmp/tokens/${req.session.header.xalias}_${ | ||||
|     req.session.header.xdays | ||||
|   }_${req.session.header.xhash.substring(20, 200)}`; | ||||
|   console.log(tmpfs); | ||||
| @@ -49,11 +49,11 @@ const isAuthenticated = async (req, res, next) => { | ||||
|     let publickey; | ||||
|     if ( | ||||
|       fs.existsSync( | ||||
|         `${__base}nationchains/pagans/itm/${req.session.header.xalias}.json` | ||||
|         `${conf.dirapi}/nationchains/pagans/itm/${req.session.header.xalias}.json` | ||||
|       ) | ||||
|     ) { | ||||
|       const pagan = fs.readJsonSync( | ||||
|         `${__base}nationchains/pagans/itm/${req.session.header.xalias}.json` | ||||
|         `${conf.dirapi}nationchains/pagans/itm/${req.session.header.xalias}.json` | ||||
|       ); | ||||
|       publickey = pagan.publicKey; | ||||
|     } else { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user