fix: tidy up stuff
This commit is contained in:
parent
8044b7f623
commit
d236589644
11 changed files with 105 additions and 3086 deletions
|
@ -11,14 +11,6 @@ module.exports = {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
webpack(config) {
|
|
||||||
config.module.rules.push({
|
|
||||||
test: /\.svg$/,
|
|
||||||
use: ['@svgr/webpack'],
|
|
||||||
});
|
|
||||||
|
|
||||||
return config;
|
|
||||||
},
|
|
||||||
images: {
|
images: {
|
||||||
domains: [
|
domains: [
|
||||||
// For sharex icon in manage user
|
// For sharex icon in manage user
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
"@dicedtomato/mantine-data-grid": "0.0.21",
|
"@dicedtomato/mantine-data-grid": "0.0.21",
|
||||||
"@emotion/react": "^11.9.3",
|
"@emotion/react": "^11.9.3",
|
||||||
"@emotion/server": "^11.4.0",
|
"@emotion/server": "^11.4.0",
|
||||||
"@iarna/toml": "2.2.5",
|
|
||||||
"@mantine/core": "^5.2.6",
|
"@mantine/core": "^5.2.6",
|
||||||
"@mantine/dropzone": "^5.2.6",
|
"@mantine/dropzone": "^5.2.6",
|
||||||
"@mantine/form": "^5.2.6",
|
"@mantine/form": "^5.2.6",
|
||||||
|
@ -33,8 +32,6 @@
|
||||||
"@prisma/internals": "^4.1.0",
|
"@prisma/internals": "^4.1.0",
|
||||||
"@prisma/migrate": "^4.1.0",
|
"@prisma/migrate": "^4.1.0",
|
||||||
"@reduxjs/toolkit": "^1.8.2",
|
"@reduxjs/toolkit": "^1.8.2",
|
||||||
"@svgr/webpack": "^6.3.1",
|
|
||||||
"@tabler/icons": "^1.92.0",
|
|
||||||
"@tanstack/react-query": "^4.2.3",
|
"@tanstack/react-query": "^4.2.3",
|
||||||
"argon2": "^0.28.5",
|
"argon2": "^0.28.5",
|
||||||
"chart.js": "^3.9.1",
|
"chart.js": "^3.9.1",
|
||||||
|
@ -45,21 +42,18 @@
|
||||||
"dayjs": "^1.11.5",
|
"dayjs": "^1.11.5",
|
||||||
"dotenv": "^16.0.1",
|
"dotenv": "^16.0.1",
|
||||||
"dotenv-expand": "^8.0.3",
|
"dotenv-expand": "^8.0.3",
|
||||||
"fecha": "^4.2.3",
|
|
||||||
"fflate": "^0.7.3",
|
"fflate": "^0.7.3",
|
||||||
"find-my-way": "^6.3.0",
|
"find-my-way": "^6.3.0",
|
||||||
"minio": "^7.0.28",
|
"minio": "^7.0.28",
|
||||||
"ms": "canary",
|
"ms": "canary",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"next": "^12.1.6",
|
"next": "^12.1.6",
|
||||||
"npm": "^8.19.1",
|
|
||||||
"prisma": "^4.1.0",
|
"prisma": "^4.1.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-chartjs-2": "^4.3.1",
|
"react-chartjs-2": "^4.3.1",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-feather": "^2.0.10",
|
"react-feather": "^2.0.10",
|
||||||
"react-redux": "^8.0.2",
|
"react-redux": "^8.0.2",
|
||||||
"react-table": "^7.8.0",
|
|
||||||
"redux": "^4.2.0",
|
"redux": "^4.2.0",
|
||||||
"sharp": "^0.30.7",
|
"sharp": "^0.30.7",
|
||||||
"yup": "^0.32.11"
|
"yup": "^0.32.11"
|
||||||
|
|
|
@ -93,6 +93,12 @@ export default function ZiplineTheming({ Component, pageProps, ...props }) {
|
||||||
transition: 'pop',
|
transition: 'pop',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
LoadingOverlay: {
|
||||||
|
defaultProps: {
|
||||||
|
overlayBlur: 3,
|
||||||
|
overlayColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : 'white',
|
||||||
|
},
|
||||||
|
},
|
||||||
Card: {
|
Card: {
|
||||||
styles: t => ({
|
styles: t => ({
|
||||||
root: {
|
root: {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Button, Collapse, Group, Progress, Select, Title, PasswordInput } from '@mantine/core';
|
import { Button, Collapse, Group, Progress, Select, Title, PasswordInput, Tooltip } from '@mantine/core';
|
||||||
import { randomId, useClipboard } from '@mantine/hooks';
|
import { randomId, useClipboard } from '@mantine/hooks';
|
||||||
import { showNotification, updateNotification } from '@mantine/notifications';
|
import { showNotification, updateNotification } from '@mantine/notifications';
|
||||||
import Dropzone from 'components/dropzone/Dropzone';
|
import Dropzone from 'components/dropzone/Dropzone';
|
||||||
|
@ -164,47 +164,51 @@ export default function Upload() {
|
||||||
</Collapse>
|
</Collapse>
|
||||||
|
|
||||||
<Group position='right' mt='md'>
|
<Group position='right' mt='md'>
|
||||||
<PasswordInput
|
<Tooltip label='Add a password to your files (optional, leave blank for none)'>
|
||||||
style={{width: '252px'}}
|
<PasswordInput
|
||||||
placeholder='Password'
|
style={{width: '252px'}}
|
||||||
value={password}
|
placeholder='Password'
|
||||||
onChange={(e) => setPassword(e.currentTarget.value)}
|
value={password}
|
||||||
/>
|
onChange={(e) => setPassword(e.currentTarget.value)}
|
||||||
<Select
|
/>
|
||||||
value={expires}
|
</Tooltip>
|
||||||
onChange={(e) => setExpires(e)}
|
<Tooltip label='Set an expiration date for your files (optional, defaults to never)'>
|
||||||
icon={<ClockIcon size={14} />}
|
<Select
|
||||||
data={[
|
value={expires}
|
||||||
{ value: 'never', label: 'Never' },
|
onChange={(e) => setExpires(e)}
|
||||||
{ value: '5min', label: '5 minutes' },
|
icon={<ClockIcon size={14} />}
|
||||||
{ value: '10min', label: '10 minutes' },
|
data={[
|
||||||
{ value: '15min', label: '15 minutes' },
|
{ value: 'never', label: 'Never' },
|
||||||
{ value: '30min', label: '30 minutes' },
|
{ value: '5min', label: '5 minutes' },
|
||||||
{ value: '1h', label: '1 hour' },
|
{ value: '10min', label: '10 minutes' },
|
||||||
{ value: '2h', label: '2 hours' },
|
{ value: '15min', label: '15 minutes' },
|
||||||
{ value: '3h', label: '3 hours' },
|
{ value: '30min', label: '30 minutes' },
|
||||||
{ value: '4h', label: '4 hours' },
|
{ value: '1h', label: '1 hour' },
|
||||||
{ value: '5h', label: '5 hours' },
|
{ value: '2h', label: '2 hours' },
|
||||||
{ value: '6h', label: '6 hours' },
|
{ value: '3h', label: '3 hours' },
|
||||||
{ value: '8h', label: '8 hours' },
|
{ value: '4h', label: '4 hours' },
|
||||||
{ value: '12h', label: '12 hours' },
|
{ value: '5h', label: '5 hours' },
|
||||||
{ value: '1d', label: '1 day' },
|
{ value: '6h', label: '6 hours' },
|
||||||
{ value: '3d', label: '3 days' },
|
{ value: '8h', label: '8 hours' },
|
||||||
{ value: '5d', label: '5 days' },
|
{ value: '12h', label: '12 hours' },
|
||||||
{ value: '7d', label: '7 days' },
|
{ value: '1d', label: '1 day' },
|
||||||
{ value: '1w', label: '1 week' },
|
{ value: '3d', label: '3 days' },
|
||||||
{ value: '1.5w', label: '1.5 weeks' },
|
{ value: '5d', label: '5 days' },
|
||||||
{ value: '2w', label: '2 weeks' },
|
{ value: '7d', label: '7 days' },
|
||||||
{ value: '3w', label: '3 weeks' },
|
{ value: '1w', label: '1 week' },
|
||||||
{ value: '1m', label: '1 month' },
|
{ value: '1.5w', label: '1.5 weeks' },
|
||||||
{ value: '1.5m', label: '1.5 months' },
|
{ value: '2w', label: '2 weeks' },
|
||||||
{ value: '2m', label: '2 months' },
|
{ value: '3w', label: '3 weeks' },
|
||||||
{ value: '3m', label: '3 months' },
|
{ value: '1m', label: '1 month' },
|
||||||
{ value: '6m', label: '6 months' },
|
{ value: '1.5m', label: '1.5 months' },
|
||||||
{ value: '8m', label: '8 months' },
|
{ value: '2m', label: '2 months' },
|
||||||
{ value: '1y', label: '1 year' },
|
{ value: '3m', label: '3 months' },
|
||||||
]}
|
{ value: '6m', label: '6 months' },
|
||||||
/>
|
{ value: '8m', label: '8 months' },
|
||||||
|
{ value: '1y', label: '1 year' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
<Button leftIcon={<UploadIcon />} onClick={handleUpload} disabled={files.length === 0 ? true : false}>Upload</Button>
|
<Button leftIcon={<UploadIcon />} onClick={handleUpload} disabled={files.length === 0 ? true : false}>Upload</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -46,6 +46,8 @@ export interface ConfigUploader {
|
||||||
admin_limit: number;
|
admin_limit: number;
|
||||||
user_limit: number;
|
user_limit: number;
|
||||||
disabled_extensions: string[];
|
disabled_extensions: string[];
|
||||||
|
|
||||||
|
format_date: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigUrls {
|
export interface ConfigUrls {
|
||||||
|
|
|
@ -55,6 +55,7 @@ const validator = object({
|
||||||
admin_limit: number().default(104900000),
|
admin_limit: number().default(104900000),
|
||||||
user_limit: number().default(104900000),
|
user_limit: number().default(104900000),
|
||||||
disabled_extensions: array().default([]),
|
disabled_extensions: array().default([]),
|
||||||
|
format_date: string().default('YYYY-MM-DD_HH:mm:ss'),
|
||||||
}).required(),
|
}).required(),
|
||||||
urls: object({
|
urls: object({
|
||||||
route: string().default('/go'),
|
route: string().default('/go'),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { format } from 'fecha';
|
import dayjs from 'dayjs';
|
||||||
import { blueBright, red, cyan } from 'colorette';
|
import { blueBright, red, cyan } from 'colorette';
|
||||||
|
|
||||||
export enum LoggerLevel {
|
export enum LoggerLevel {
|
||||||
|
@ -37,16 +37,16 @@ export default class Logger {
|
||||||
}
|
}
|
||||||
|
|
||||||
formatMessage(level: LoggerLevel, name: string, message: string) {
|
formatMessage(level: LoggerLevel, name: string, message: string) {
|
||||||
const time = format(new Date(), 'YYYY-MM-DD hh:mm:ss,SSS A');
|
const time = dayjs().format('YYYY-MM-DD hh:mm:ss,SSS A');
|
||||||
return `${time} ${this.formatLevel(level)} [${blueBright(name)}] ${message}`;
|
return `${time} ${this.formatLevel(level)} [${blueBright(name)}] ${message}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
formatLevel(level: LoggerLevel) {
|
formatLevel(level: LoggerLevel) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case LoggerLevel.INFO:
|
case LoggerLevel.INFO:
|
||||||
return cyan('INFO ');
|
return cyan('info ');
|
||||||
case LoggerLevel.ERROR:
|
case LoggerLevel.ERROR:
|
||||||
return red('ERROR');
|
return red('error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ import { GetServerSideProps } from 'next';
|
||||||
import { Box, Button, Modal, PasswordInput } from '@mantine/core';
|
import { Box, Button, Modal, PasswordInput } from '@mantine/core';
|
||||||
import config from 'lib/config';
|
import config from 'lib/config';
|
||||||
import prisma from 'lib/prisma';
|
import prisma from 'lib/prisma';
|
||||||
import { parse } from 'lib/utils/clientUtils';
|
import { parse } from 'lib/utils/client';
|
||||||
import exts from 'lib/exts';
|
import exts from 'lib/exts';
|
||||||
|
|
||||||
export default function EmbeddedImage({ image, user, pass }) {
|
export default function EmbeddedImage({ image, user, pass }) {
|
||||||
|
|
|
@ -5,12 +5,11 @@ import { NextApiReq, NextApiRes, withZipline } from 'lib/middleware/withZipline'
|
||||||
import { createInvisImage, randomChars, hashPassword } from 'lib/util';
|
import { createInvisImage, randomChars, hashPassword } from 'lib/util';
|
||||||
import Logger from 'lib/logger';
|
import Logger from 'lib/logger';
|
||||||
import { ImageFormat, InvisibleImage } from '@prisma/client';
|
import { ImageFormat, InvisibleImage } from '@prisma/client';
|
||||||
import { format as formatDate } from 'fecha';
|
import dayjs from 'dayjs';
|
||||||
import datasource from 'lib/datasource';
|
import datasource from 'lib/datasource';
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
import { humanTime, parseExpiry } from 'lib/utils/clientUtils';
|
import { parseExpiry } from 'lib/utils/client';
|
||||||
import { StringValue } from 'ms';
|
|
||||||
import { sendUpload } from 'lib/discord';
|
import { sendUpload } from 'lib/discord';
|
||||||
|
|
||||||
const uploader = multer();
|
const uploader = multer();
|
||||||
|
@ -79,7 +78,7 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
||||||
fileName = randomChars(zconfig.uploader.length);
|
fileName = randomChars(zconfig.uploader.length);
|
||||||
break;
|
break;
|
||||||
case ImageFormat.DATE:
|
case ImageFormat.DATE:
|
||||||
fileName = formatDate(new Date(), 'YYYY-MM-DD_HH:mm:ss');
|
fileName = dayjs().format(zconfig.uploader.format_date);
|
||||||
break;
|
break;
|
||||||
case ImageFormat.UUID:
|
case ImageFormat.UUID:
|
||||||
fileName = randomUUID({ disableEntropyCache: true });
|
fileName = randomUUID({ disableEntropyCache: true });
|
||||||
|
|
|
@ -24,11 +24,9 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
||||||
// i found this on some stack overflow thing, forgot the url
|
// i found this on some stack overflow thing, forgot the url
|
||||||
const onBackpressure = (stream, outputStream, cb) => {
|
const onBackpressure = (stream, outputStream, cb) => {
|
||||||
const runCb = () => {
|
const runCb = () => {
|
||||||
// Pause if either output or internal backpressure should be applied
|
|
||||||
cb(applyOutputBackpressure || backpressureBytes > backpressureThreshold);
|
cb(applyOutputBackpressure || backpressureBytes > backpressureThreshold);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Internal backpressure (for when AsyncZipDeflate is slow)
|
|
||||||
const backpressureThreshold = 65536;
|
const backpressureThreshold = 65536;
|
||||||
let backpressure = [];
|
let backpressure = [];
|
||||||
let backpressureBytes = 0;
|
let backpressureBytes = 0;
|
||||||
|
@ -48,15 +46,12 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
||||||
if (ondata) {
|
if (ondata) {
|
||||||
stream.ondata = ondataPatched;
|
stream.ondata = ondataPatched;
|
||||||
} else {
|
} else {
|
||||||
// You can remove this condition if you make sure to
|
|
||||||
// call zip.add(file) before calling onBackpressure
|
|
||||||
Object.defineProperty(stream, 'ondata', {
|
Object.defineProperty(stream, 'ondata', {
|
||||||
get: () => ondataPatched,
|
get: () => ondataPatched,
|
||||||
set: cb => ondata = cb,
|
set: cb => ondata = cb,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output backpressure (for when outputStream is slow)
|
|
||||||
let applyOutputBackpressure = false;
|
let applyOutputBackpressure = false;
|
||||||
const write = outputStream.write;
|
const write = outputStream.write;
|
||||||
outputStream.write = (data) => {
|
outputStream.write = (data) => {
|
||||||
|
|
Loading…
Reference in a new issue