chore: remove old code

pull/182/head
tycrek 1 year ago
parent e896693219
commit 94cac0f5ba
No known key found for this signature in database
GPG Key ID: FF8A54DCE404885A

@ -6,7 +6,7 @@ import fs from 'fs-extra';
import { nanoid } from 'nanoid';
import { Request } from 'express';
import bcrypt from 'bcrypt';
import { log, path, arrayEquals } from './utils';
import { log, path } from './utils';
import { data } from './data';
import { User, Users, OldUsers } from './types/auth';
import { FileData } from './types/definitions';
@ -238,17 +238,3 @@ export const verifyCliKey = (req: Request) => {
const cliKey: string = fs.readJsonSync(path('auth.json')).cliKey;
return req.headers.authorization != null && req.headers.authorization === cliKey;
};
// todo: move inside of onStart (currently broken)
// Monitor auth.json for changes (triggered by running 'npm run new-token')
/* fs.watch(path('auth.json'), { persistent: false },
(eventType: String) => eventType === 'change' && fs.readJson(path('auth.json'))
.then((json: { users: JSON[] }) => {
if (!(arrayEquals(Object.keys(users), Object.keys(json.users)))) {
// @ts-ignore
Object.keys(json.users).forEach((token) => (!Object.prototype.hasOwnProperty.call(users, token)) && (users[token] = json.users[token]));
log.info('New token added', Object.keys(users)[Object.keys(users).length - 1] || 'No new token');
}
})
.catch(console.error));
*/

@ -68,10 +68,6 @@ export function replaceholder(data: string, size: number, timestamp: number, tim
.replace(/&timestamp/g, formatTimestamp(timestamp, timeoffset));
}
export function arrayEquals(arr1: any[], arr2: any[]) {
return arr1.length === arr2.length && arr1.slice().sort().every((value: string, index: number) => value === arr2.slice().sort()[index])
}
const idModes = {
zws: 'zws', // Zero-width spaces (see: https://zws.im/)
og: 'original', // Use original uploaded filename
@ -116,7 +112,6 @@ module.exports = {
}),
generateToken: () => token(),
generateId,
arrayEquals,
downloadTempS3: (file: FileData) => new Promise((resolve: Function, reject) =>
fetch(getS3url(file.randomId, file.ext))
.then((f2) => f2.body!.pipe(fs.createWriteStream(Path.join(__dirname, diskFilePath, sanitize(file.originalname))).on('close', () => resolve())))

Loading…
Cancel
Save