switched to new generator

pull/12/head
tycrek 4 years ago
parent 702149024c
commit 6ad7a62646
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

@ -11,11 +11,10 @@ const { host, port, domain, useSsl, resourceIdSize, resourceIdType, isProxied }
//#region Imports
const fs = require('fs-extra');
const uuid = require('uuid').v4;
const express = require('express');
const useragent = require('express-useragent');
const multer = require('multer');
const { path, saveData, log, verify, generateId } = require('./utils');
const { path, saveData, log, verify, generateToken, generateId } = require('./utils');
//#endregion
//#region Variables, module setup
@ -37,7 +36,7 @@ function preStartup() {
// Make sure auth.json exists and generate the first key
if (!fs.existsSync(path('auth.json'))) {
tokens.push(uuid().replace(/-/g, ''));
tokens.push(generateToken());
fs.writeJsonSync(path('auth.json'), { tokens }, { spaces: 4 });
log(`File [auth.json] created\n!! Important: save this token in a secure spot: ${tokens[0]}\n`);
} else log('File [auth.json] exists');

@ -1,5 +1,6 @@
const fs = require('fs-extra');
const Path = require('path');
const token = require('./generators/token');
const zwsGen = require('./generators/zws');
const randomGen = require('./generators/random');
@ -15,6 +16,7 @@ module.exports = {
path: (...paths) => Path.join(__dirname, ...paths),
saveData: (data) => fs.writeJsonSync(Path.join(__dirname, 'data.json'), data, { spaces: 4 }),
verify: (req, tokens) => req.headers.authorization && tokens.includes(req.headers.authorization),
generateToken: () => token(),
generateId: (mode, lenth, originalName) =>
(mode == idModes.zws) ? zwsGen(lenth)
: (mode == idModes.r) ? randomGen(lenth)

Loading…
Cancel
Save