Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
refactor: delete a lot of old stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Moore committed Sep 28, 2023
1 parent d5bd01b commit c4b43dd
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 110 deletions.
14 changes: 0 additions & 14 deletions MagicNumbers.json

This file was deleted.

22 changes: 0 additions & 22 deletions src/checkEngine.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/logger.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/purge.ts

This file was deleted.

48 changes: 0 additions & 48 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Config } from 'ass-json';
import { FileData } from './types/definitions';
import fs from 'fs-extra';
import Path from 'path';
Expand All @@ -10,22 +9,10 @@ import zwsGen from './generators/zws';
import randomGen from './generators/random';
import gfyGen from './generators/gfycat';
import tsGen from './generators/timestamp';
import logger from './logger';
import { Request } from 'express';
import { isProd as ip } from '@tycrek/joint';
const { HTTP, HTTPS, KILOBYTES } = require('../MagicNumbers.json');

// Catch config.json not existing when running setup script
try {
// todo: fix this
const configPath = Path.join(process.cwd(), 'config.json');
if (!fs.existsSync(configPath)) throw new Error('Config file not found');
var { useSsl, port, domain, isProxied, diskFilePath, s3bucket, s3endpoint, s3usePathStyle }: Config = fs.readJsonSync(configPath);
} catch (ex) {
// @ts-ignore
if (ex.code !== 'MODULE_NOT_FOUND' || !ex.toString().includes('Unexpected end')) console.error(ex);
}

export function getTrueHttp() {
return ('http').concat(useSsl ? 's' : '').concat('://');
}
Expand Down Expand Up @@ -92,38 +79,3 @@ export function generateId(mode: string, length: number, gfyLength: number, orig
export const path = (...paths: string[]) => Path.join(process.cwd(), ...paths);

export const isProd = ip();
module.exports = {
path,
getTrueHttp,
getTrueDomain,
getS3url,
getDirectUrl,
getResourceColor,
formatTimestamp,
formatBytes,
replaceholder,
randomHexColour,
sanitize,
renameFile: (req: Request, newName: string) => new Promise((resolve: Function, reject) => {
try {
const paths = [req.file.destination, newName];
fs.rename(path(req.file.path), path(...paths));
req.file.path = Path.join(...paths);
resolve();
} catch (err) {
reject(err);
}
}),
generateToken: () => token(),
generateId,
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())))
.catch(reject)),
}

export const log = logger;
/**
* @type {TLog}
*/
module.exports.log = logger;

0 comments on commit c4b43dd

Please sign in to comment.