fix: cleanup
This commit is contained in:
parent
2b9af0e0de
commit
6506846207
7 changed files with 28 additions and 101 deletions
1
.husky/.gitignore
vendored
1
.husky/.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
_
|
|
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
yarn commitlint --edit $1
|
|
|
@ -19,7 +19,10 @@
|
||||||
- Image uploading
|
- Image uploading
|
||||||
- URL shortening
|
- URL shortening
|
||||||
- Text uploading
|
- Text uploading
|
||||||
- Easy setup instructions on [docs](https://zipline.diced.tech/) (One command install `docker-compose up`)
|
- URL Formats (uuid, dates, random alphanumeric, original name, zws)
|
||||||
|
- Discord embeds (OG metadata)
|
||||||
|
- Gallery viewer, and multiple file format support
|
||||||
|
- Easy setup instructions on [docs](https://zipline.diced.tech/) (One command install `docker-compose up -d`)
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
[See how to install here](https://zipline.diced.tech/docs/get-started)
|
[See how to install here](https://zipline.diced.tech/docs/get-started)
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
| ------- | ------------------ |
|
| ------- | ------------------ |
|
||||||
| 3.x.x | :white_check_mark: |
|
| 3.2.x | :white_check_mark: |
|
||||||
|
| < 3 | :x: |
|
||||||
| < 2 | :x: |
|
| < 2 | :x: |
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
parserPreset: 'conventional-changelog-conventionalcommits',
|
|
||||||
rules: {
|
|
||||||
'body-leading-blank': [1, 'always'],
|
|
||||||
'body-max-line-length': [2, 'always', 100],
|
|
||||||
'footer-leading-blank': [1, 'always'],
|
|
||||||
'footer-max-line-length': [2, 'always', 100],
|
|
||||||
'header-max-length': [2, 'always', 100],
|
|
||||||
'subject-case': [
|
|
||||||
2,
|
|
||||||
'never',
|
|
||||||
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
|
|
||||||
],
|
|
||||||
'subject-empty': [2, 'never'],
|
|
||||||
'subject-full-stop': [2, 'never', '.'],
|
|
||||||
'type-case': [2, 'always', 'lower-case'],
|
|
||||||
'type-empty': [2, 'never'],
|
|
||||||
'type-enum': [
|
|
||||||
2,
|
|
||||||
'always',
|
|
||||||
[
|
|
||||||
'build',
|
|
||||||
'chore',
|
|
||||||
'ci',
|
|
||||||
'docs',
|
|
||||||
'feat',
|
|
||||||
'fix',
|
|
||||||
'perf',
|
|
||||||
'refactor',
|
|
||||||
'revert',
|
|
||||||
'style',
|
|
||||||
'test',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'scope-enum': [
|
|
||||||
1,
|
|
||||||
'always',
|
|
||||||
[
|
|
||||||
'prisma',
|
|
||||||
'scripts',
|
|
||||||
'server',
|
|
||||||
'pages',
|
|
||||||
'config',
|
|
||||||
'api',
|
|
||||||
'hooks',
|
|
||||||
'components',
|
|
||||||
'middleware',
|
|
||||||
'redux',
|
|
||||||
'themes',
|
|
||||||
'lib',
|
|
||||||
'assets'
|
|
||||||
],
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -3,7 +3,6 @@
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "husky install",
|
|
||||||
"dev": "NODE_ENV=development node server",
|
"dev": "NODE_ENV=development node server",
|
||||||
"build": "npm-run-all build:schema build:next",
|
"build": "npm-run-all build:schema build:next",
|
||||||
"build:next": "next build",
|
"build:next": "next build",
|
||||||
|
@ -44,16 +43,12 @@
|
||||||
"yup": "^0.32.9"
|
"yup": "^0.32.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^12.1.4",
|
|
||||||
"@commitlint/config-conventional": "^12.1.4",
|
|
||||||
"@types/cookie": "^0.4.0",
|
"@types/cookie": "^0.4.0",
|
||||||
"@types/multer": "^1.4.6",
|
"@types/multer": "^1.4.6",
|
||||||
"@types/node": "^15.12.2",
|
"@types/node": "^15.12.2",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-next": "11.0.0",
|
"eslint-config-next": "11.0.0",
|
||||||
"husky": "^6.0.0",
|
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"release": "^6.3.0",
|
|
||||||
"ts-node": "^10.0.0",
|
"ts-node": "^10.0.0",
|
||||||
"typescript": "^4.3.2"
|
"typescript": "^4.3.2"
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,14 +22,8 @@ const dev = process.env.NODE_ENV === 'development';
|
||||||
try {
|
try {
|
||||||
await run();
|
await run();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.message && e.message.startsWith('Could not find a production')) {
|
serverLog.error(e);
|
||||||
webLog.error(`there is no production build - run \`${shouldUseYarn() ? 'yarn build' : 'npm build'}\``);
|
process.exit(1);
|
||||||
} else if (e.code && e.code === 'ENOENT') {
|
|
||||||
if (e.path === './.next') webLog.error(`there is no production build - run \`${shouldUseYarn() ? 'yarn build' : 'npm build'}\``);
|
|
||||||
} else {
|
|
||||||
serverLog.error(e);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -57,10 +51,10 @@ async function run() {
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
const srv = createServer(async (req, res) => {
|
const srv = createServer(async (req, res) => {
|
||||||
if (req.url.startsWith('/r')) {
|
const parts = req.url.split('/');
|
||||||
const parts = req.url.split('/');
|
if (!parts[2] || parts[2] === '') return;
|
||||||
if (!parts[2] || parts[2] === '') return;
|
|
||||||
|
|
||||||
|
if (req.url.startsWith('/r')) {
|
||||||
let image = await prisma.image.findFirst({
|
let image = await prisma.image.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
OR: [
|
||||||
|
@ -76,17 +70,19 @@ async function run() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!image) {
|
image && await prisma.image.update({
|
||||||
const data = await getFile(config.uploader.directory, parts[2]);
|
where: { id: image.id },
|
||||||
if (!data) return app.render404(req, res);
|
data: { views: { increment: 1 } },
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await getFile(config.uploader.directory, parts[2]);
|
||||||
|
if (!data) return app.render404(req, res);
|
||||||
|
|
||||||
|
if (!image) { // raw image
|
||||||
const mimetype = mimes[extname(parts[2])] ?? 'application/octet-stream';
|
const mimetype = mimes[extname(parts[2])] ?? 'application/octet-stream';
|
||||||
res.setHeader('Content-Type', mimetype);
|
res.setHeader('Content-Type', mimetype);
|
||||||
res.end(data);
|
res.end(data);
|
||||||
} else {
|
} else { // raw image & update db
|
||||||
const data = await getFile(config.uploader.directory, image.file);
|
|
||||||
if (!data) return app.render404(req, res);
|
|
||||||
|
|
||||||
await prisma.image.update({
|
await prisma.image.update({
|
||||||
where: { id: image.id },
|
where: { id: image.id },
|
||||||
data: { views: { increment: 1 } },
|
data: { views: { increment: 1 } },
|
||||||
|
@ -95,9 +91,6 @@ async function run() {
|
||||||
res.end(data);
|
res.end(data);
|
||||||
}
|
}
|
||||||
} else if (req.url.startsWith(config.uploader.route)) {
|
} else if (req.url.startsWith(config.uploader.route)) {
|
||||||
const parts = req.url.split('/');
|
|
||||||
if (!parts[2] || parts[2] === '') return;
|
|
||||||
|
|
||||||
let image = await prisma.image.findFirst({
|
let image = await prisma.image.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
OR: [
|
||||||
|
@ -114,23 +107,18 @@ async function run() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!image) {
|
image && await prisma.image.update({
|
||||||
const data = await getFile(config.uploader.directory, parts[2]);
|
where: { id: image.id },
|
||||||
if (!data) return app.render404(req, res);
|
data: { views: { increment: 1 } },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!image) { // raw image
|
||||||
const mimetype = mimes[extname(parts[2])] ?? 'application/octet-stream';
|
const mimetype = mimes[extname(parts[2])] ?? 'application/octet-stream';
|
||||||
res.setHeader('Content-Type', mimetype);
|
res.setHeader('Content-Type', mimetype);
|
||||||
res.end(data);
|
res.end(data);
|
||||||
} else if (image.embed) {
|
} else if (image.embed) { // embed image
|
||||||
handle(req, res);
|
handle(req, res);
|
||||||
} else {
|
} else { // raw image fallback
|
||||||
const data = await getFile(config.uploader.directory, image.file);
|
|
||||||
if (!data) return app.render404(req, res);
|
|
||||||
|
|
||||||
await prisma.image.update({
|
|
||||||
where: { id: image.id },
|
|
||||||
data: { views: { increment: 1 } },
|
|
||||||
});
|
|
||||||
res.setHeader('Content-Type', image.mimetype);
|
res.setHeader('Content-Type', image.mimetype);
|
||||||
res.end(data);
|
res.end(data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue