2018-11-22 15:42:19 -08:00
|
|
|
const uuid = require('uuid/v4');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
2019-08-19 07:49:21 -07:00
|
|
|
const secretFilePath = path.join((process.env.SECRET_DIRNAME ? process.env.SECRET_DIRNAME : __dirname), 'secret.txt');
|
2018-11-22 15:42:19 -08:00
|
|
|
|
|
|
|
try {
|
|
|
|
module.exports = fs.readFileSync(secretFilePath).toString();
|
|
|
|
} catch (_) {
|
|
|
|
const secret = uuid();
|
|
|
|
fs.writeFileSync(secretFilePath, secret);
|
|
|
|
module.exports = secret;
|
|
|
|
}
|