diff --git a/.husky/.gitignore b/.husky/.gitignore deleted file mode 100644 index 31354ec..0000000 --- a/.husky/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_ diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100755 index d71a03b..0000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -yarn commitlint --edit $1 diff --git a/README.md b/README.md index bd487ec..1074ca0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,10 @@ - Image uploading - URL shortening - 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 [See how to install here](https://zipline.diced.tech/docs/get-started) diff --git a/SECURITY.md b/SECURITY.md index 69d245e..ff69f38 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,7 +4,8 @@ | Version | Supported | | ------- | ------------------ | -| 3.x.x | :white_check_mark: | +| 3.2.x | :white_check_mark: | +| < 3 | :x: | | < 2 | :x: | ## Reporting a Vulnerability diff --git a/commitlint.config.js b/commitlint.config.js deleted file mode 100644 index 44bdd8b..0000000 --- a/commitlint.config.js +++ /dev/null @@ -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' - ], - ], - }, -}; \ No newline at end of file diff --git a/package.json b/package.json index 5a0d448..f2b1ba8 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,6 @@ "version": "3.3.1", "license": "MIT", "scripts": { - "prepare": "husky install", "dev": "NODE_ENV=development node server", "build": "npm-run-all build:schema build:next", "build:next": "next build", @@ -44,16 +43,12 @@ "yup": "^0.32.9" }, "devDependencies": { - "@commitlint/cli": "^12.1.4", - "@commitlint/config-conventional": "^12.1.4", "@types/cookie": "^0.4.0", "@types/multer": "^1.4.6", "@types/node": "^15.12.2", "eslint": "^7.32.0", "eslint-config-next": "11.0.0", - "husky": "^6.0.0", "npm-run-all": "^4.1.5", - "release": "^6.3.0", "ts-node": "^10.0.0", "typescript": "^4.3.2" }, diff --git a/server/index.js b/server/index.js index e1404ba..041e036 100644 --- a/server/index.js +++ b/server/index.js @@ -22,14 +22,8 @@ const dev = process.env.NODE_ENV === 'development'; try { await run(); } catch (e) { - if (e.message && e.message.startsWith('Could not find a production')) { - webLog.error(`there is no production build - run \`${shouldUseYarn() ? 'yarn build' : 'npm build'}\``); - } 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); - } + serverLog.error(e); + process.exit(1); } })(); @@ -57,10 +51,10 @@ async function run() { const prisma = new PrismaClient(); const srv = createServer(async (req, res) => { + const parts = req.url.split('/'); + if (!parts[2] || parts[2] === '') return; + if (req.url.startsWith('/r')) { - const parts = req.url.split('/'); - if (!parts[2] || parts[2] === '') return; - let image = await prisma.image.findFirst({ where: { OR: [ @@ -76,17 +70,19 @@ async function run() { }, }); - if (!image) { - const data = await getFile(config.uploader.directory, parts[2]); - if (!data) return app.render404(req, res); + image && await prisma.image.update({ + where: { id: image.id }, + 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'; res.setHeader('Content-Type', mimetype); res.end(data); - } else { - const data = await getFile(config.uploader.directory, image.file); - if (!data) return app.render404(req, res); - + } else { // raw image & update db await prisma.image.update({ where: { id: image.id }, data: { views: { increment: 1 } }, @@ -95,9 +91,6 @@ async function run() { res.end(data); } } 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({ where: { OR: [ @@ -114,23 +107,18 @@ async function run() { }, }); - if (!image) { - const data = await getFile(config.uploader.directory, parts[2]); - if (!data) return app.render404(req, res); - + image && await prisma.image.update({ + where: { id: image.id }, + data: { views: { increment: 1 } }, + }); + + if (!image) { // raw image const mimetype = mimes[extname(parts[2])] ?? 'application/octet-stream'; res.setHeader('Content-Type', mimetype); res.end(data); - } else if (image.embed) { + } else if (image.embed) { // embed image handle(req, res); - } else { - 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 } }, - }); + } else { // raw image fallback res.setHeader('Content-Type', image.mimetype); res.end(data); }