converted a ton of `module.exports` to `export` and `require` to `import`

pull/62/head
tycrek 3 years ago
parent de1358cfc8
commit 9b80ae6ff1
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

13
package-lock.json generated

@ -49,6 +49,7 @@
"@types/node": "^16.9.0",
"@types/node-fetch": "^2.5.12",
"@types/stream-to-array": "^2.3.0",
"@types/uuid": "^8.3.1",
"@types/ws": "^7.4.7"
},
"engines": {
@ -861,6 +862,12 @@
"@types/node": "*"
}
},
"node_modules/@types/uuid": {
"version": "8.3.1",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.1.tgz",
"integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==",
"dev": true
},
"node_modules/@types/ws": {
"version": "7.4.7",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz",
@ -5372,6 +5379,12 @@
"@types/node": "*"
}
},
"@types/uuid": {
"version": "8.3.1",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.1.tgz",
"integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==",
"dev": true
},
"@types/ws": {
"version": "7.4.7",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz",

@ -76,6 +76,7 @@
"@types/node": "^16.9.0",
"@types/node-fetch": "^2.5.12",
"@types/stream-to-array": "^2.3.0",
"@types/uuid": "^8.3.1",
"@types/ws": "^7.4.7"
}
}

@ -42,8 +42,8 @@ const ROUTERS = {
};
// Read users and data
const users = require('./auth');
const data = require('./data');
import { users } from './auth';
import { data } from './data';
//#endregion
// Enable/disable Express features

@ -5,7 +5,7 @@
import fs from 'fs-extra';
import { log, path, arrayEquals } from './utils';
const users = require('../auth.json').users || {};
export const users = require('../auth.json').users || {};
// Monitor auth.json for changes (triggered by running 'npm run new-token')
fs.watch(path('auth.json'), { persistent: false },
@ -18,5 +18,3 @@ fs.watch(path('auth.json'), { persistent: false },
}
})
.catch(log.c.error));
module.exports = users;

@ -3,5 +3,4 @@
*/
const { JsonDataEngine } = require('@tycrek/papito');
const data = new JsonDataEngine();
module.exports = data;
export const data = new JsonDataEngine();

@ -1,2 +1,2 @@
import { randomBytes } from 'crypto';
module.exports = (length: number, charset: string[]): string => [...randomBytes(length)].map((byte) => charset[Number(byte) % charset.length]).join('').slice(1).concat(charset[0]);
export default (length: number, charset: string[]): string => [...randomBytes(length)].map((byte) => charset[Number(byte) % charset.length]).join('').slice(1).concat(charset[0]);

@ -1,7 +1,7 @@
const uuid = require('uuid').v4;
import { v4 as uuid } from 'uuid';
import fs from 'fs-extra';
const path = require('path');
const randomGen = require('./random');
import path from 'path';
import randomGen from './random';
const TLog = require('@tycrek/log');
const log = new TLog();

@ -1,3 +1,3 @@
const lengthGen = require('./lengthGen');
import lengthGen from './lengthGen';
const zeroWidthChars = ['\u200B', '\u200C', '\u200D', '\u2060'];
export default ({ length }: { length: number }) => lengthGen(length, zeroWidthChars);

@ -3,12 +3,12 @@ import { FileData, IsPossible, AssRequest, AssResponse } from '../definitions';
import fs from 'fs-extra';
import escape from 'escape-html';
import fetch, { Response } from 'node-fetch';
const { deleteS3 } = require('../storage');
import { deleteS3 } from '../storage';
const { diskFilePath, s3enabled, viewDirect } = require('../../config.json');
import { path, log, getTrueHttp, getTrueDomain, formatBytes, formatTimestamp, getS3url, getDirectUrl, getResourceColor, replaceholder } from '../utils';
const { CODE_UNAUTHORIZED, CODE_NOT_FOUND, } = require('../../MagicNumbers.json');
const data = require('../data');
const users = require('../auth');
import { data } from '../data';
import { users } from '../auth';
import express from 'express';
const router = express.Router();

@ -1,15 +1,15 @@
import { FileData, AssRequest, AssResponse, ErrWrap, User } from "../definitions";
const fs = require('fs-extra');
import fs from 'fs-extra';
//const rateLimit = require('express-rate-limit');
const { DateTime } = require('luxon');
import { DateTime } from 'luxon';
const { WebhookClient, MessageEmbed } = require('discord.js');
const { doUpload, processUploaded } = require('../storage');
import { doUpload, processUploaded } from '../storage';
const { maxUploadSize, resourceIdSize, gfyIdSize, resourceIdType } = require('../../config.json');
import { path, log, verify, getTrueHttp, getTrueDomain, generateId, formatBytes } from '../utils';
const { CODE_UNAUTHORIZED, CODE_PAYLOAD_TOO_LARGE } = require('../../MagicNumbers.json');
const data = require('../data');
const users = require('../auth');
import { data } from '../data';
import { users } from '../auth';
const ASS_LOGO = 'https://cdn.discordapp.com/icons/848274994375294986/8d339d4a2f3f54b2295e5e0ff62bd9e6.png?size=1024';
import express from 'express';

@ -1,7 +1,8 @@
import { FileData } from "./definitions";
import ffmpeg from 'ffmpeg-static';
import Jimp from 'jimp';
const shell = require('any-shell-escape');
// @ts-ignore
import shell from 'any-shell-escape';
import { exec } from 'child_process';
import { isProd, path } from './utils';
const { diskFilePath } = require('../config.json');

Loading…
Cancel
Save