diff --git a/.eslintrc.js b/.eslintrc.js
index c02fc66..4ab840a 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,25 +1,25 @@
module.exports = {
- env: {
- browser: true,
- node: true,
- commonjs: true,
- es2021: true,
- jest: true,
+ env: {
+ browser: true,
+ node: true,
+ commonjs: true,
+ es2021: true,
+ jest: true,
+ serviceworker: true,
+ },
+ extends: ['eslint:recommended', 'plugin:react/recommended'],
+ overrides: [],
+ parserOptions: {
+ ecmaVersion: 'latest',
+ sourceType: 'module',
+ ecmaFeatures: {
+ jsx: true,
},
- extends: ['eslint:recommended', 'plugin:react/recommended'],
- overrides: [],
- parserOptions: {
- ecmaVersion: 'latest',
- sourceType: "module",
- ecmaFeatures: {
- jsx: true
- }
+ },
+ rules: {},
+ settings: {
+ react: {
+ version: 'detect',
},
- rules: {},
- settings: {
- react: {
- version: "detect"
- }
- },
-
- };
\ No newline at end of file
+ },
+};
diff --git a/package-lock.json b/package-lock.json
index d02fc02..cd43fc8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12,6 +12,7 @@
"@fontsource/poppins": "^4.5.10",
"@octokit/rest": "^19.0.5",
"bootstrap": "^5.2.2",
+ "compressorjs": "^1.1.1",
"eslint": "^8.27.0",
"http-status-codes": "^2.2.0",
"octokit": "^2.0.10",
@@ -6219,6 +6220,25 @@
}
}
},
+ "node_modules/@typescript-eslint/typescript-estree/node_modules/globby": {
+ "version": "11.1.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
+ "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
+ "dependencies": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.2.9",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/@typescript-eslint/utils": {
"version": "5.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.43.0.tgz",
@@ -7224,6 +7244,11 @@
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
+ "node_modules/blueimp-canvas-to-blob": {
+ "version": "3.29.0",
+ "resolved": "https://registry.npmjs.org/blueimp-canvas-to-blob/-/blueimp-canvas-to-blob-3.29.0.tgz",
+ "integrity": "sha512-0pcSSGxC0QxT+yVkivxIqW0Y4VlO2XSDPofBAqoJ1qJxgH9eiUDLv50Rixij2cDuEfx4M6DpD9UGZpRhT5Q8qg=="
+ },
"node_modules/body-parser": {
"version": "1.20.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
@@ -7785,6 +7810,15 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
+ "node_modules/compressorjs": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/compressorjs/-/compressorjs-1.1.1.tgz",
+ "integrity": "sha512-SysRuUPfmUNoq+RviE0iMFVUmoX2q/x+7PkEPUmk6NGkd85hDrmvujx0Qtp8UCGA6KMe5kuodsylPQcNaLf60w==",
+ "dependencies": {
+ "blueimp-canvas-to-blob": "^3.29.0",
+ "is-blob": "^2.1.0"
+ }
+ },
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -10650,19 +10684,6 @@
}
]
},
- "node_modules/fs-extra": {
- "version": "10.1.0",
- "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
- "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
- "dependencies": {
- "graceful-fs": "^4.2.0",
- "jsonfile": "^6.0.1",
- "universalify": "^2.0.0"
- },
- "engines": {
- "node": ">=12"
- }
- },
"node_modules/fs-monkey": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.3.tgz",
@@ -10870,25 +10891,6 @@
"node": ">=4"
}
},
- "node_modules/globby": {
- "version": "11.1.0",
- "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
- "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
- "dependencies": {
- "array-union": "^2.1.0",
- "dir-glob": "^3.0.1",
- "fast-glob": "^3.2.9",
- "ignore": "^5.2.0",
- "merge2": "^1.4.1",
- "slash": "^3.0.0"
- },
- "engines": {
- "node": ">=10"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
"node_modules/graceful-fs": {
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
@@ -11476,6 +11478,17 @@
"node": ">=8"
}
},
+ "node_modules/is-blob": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-blob/-/is-blob-2.1.0.tgz",
+ "integrity": "sha512-SZ/fTft5eUhQM6oF/ZaASFDEdbFVe89Imltn9uZr03wdKMcWNVYSMjQPFtg05QuNkt5l5c135ElvXEQG0rk4tw==",
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/is-boolean-object": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz",
@@ -17398,6 +17411,25 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
+ "node_modules/react-dev-utils/node_modules/globby": {
+ "version": "11.1.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
+ "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
+ "dependencies": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.2.9",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/react-dev-utils/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -17599,6 +17631,19 @@
}
}
},
+ "node_modules/react-scripts/node_modules/fs-extra": {
+ "version": "10.1.0",
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
+ "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
+ "dependencies": {
+ "graceful-fs": "^4.2.0",
+ "jsonfile": "^6.0.1",
+ "universalify": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/react-scripts/node_modules/react-refresh": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz",
@@ -24847,6 +24892,21 @@
"is-glob": "^4.0.3",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
+ },
+ "dependencies": {
+ "globby": {
+ "version": "11.1.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
+ "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
+ "requires": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.2.9",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^3.0.0"
+ }
+ }
}
},
"@typescript-eslint/utils": {
@@ -25626,6 +25686,11 @@
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
+ "blueimp-canvas-to-blob": {
+ "version": "3.29.0",
+ "resolved": "https://registry.npmjs.org/blueimp-canvas-to-blob/-/blueimp-canvas-to-blob-3.29.0.tgz",
+ "integrity": "sha512-0pcSSGxC0QxT+yVkivxIqW0Y4VlO2XSDPofBAqoJ1qJxgH9eiUDLv50Rixij2cDuEfx4M6DpD9UGZpRhT5Q8qg=="
+ },
"body-parser": {
"version": "1.20.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
@@ -26051,6 +26116,15 @@
}
}
},
+ "compressorjs": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/compressorjs/-/compressorjs-1.1.1.tgz",
+ "integrity": "sha512-SysRuUPfmUNoq+RviE0iMFVUmoX2q/x+7PkEPUmk6NGkd85hDrmvujx0Qtp8UCGA6KMe5kuodsylPQcNaLf60w==",
+ "requires": {
+ "blueimp-canvas-to-blob": "^3.29.0",
+ "is-blob": "^2.1.0"
+ }
+ },
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -28004,16 +28078,6 @@
"resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz",
"integrity": "sha512-cHEpEQHUg0f8XdtZCc2ZAhrHzKzT0MrFUTcvx+hfxYu7rGMDc5SKoXFh+n4YigxsHXRzc6OrCshdR1bWH6HHyg=="
},
- "fs-extra": {
- "version": "10.1.0",
- "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
- "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
- "requires": {
- "graceful-fs": "^4.2.0",
- "jsonfile": "^6.0.1",
- "universalify": "^2.0.0"
- }
- },
"fs-monkey": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.3.tgz",
@@ -28159,19 +28223,6 @@
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA=="
},
- "globby": {
- "version": "11.1.0",
- "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
- "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
- "requires": {
- "array-union": "^2.1.0",
- "dir-glob": "^3.0.1",
- "fast-glob": "^3.2.9",
- "ignore": "^5.2.0",
- "merge2": "^1.4.1",
- "slash": "^3.0.0"
- }
- },
"graceful-fs": {
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
@@ -28587,6 +28638,11 @@
"binary-extensions": "^2.0.0"
}
},
+ "is-blob": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-blob/-/is-blob-2.1.0.tgz",
+ "integrity": "sha512-SZ/fTft5eUhQM6oF/ZaASFDEdbFVe89Imltn9uZr03wdKMcWNVYSMjQPFtg05QuNkt5l5c135ElvXEQG0rk4tw=="
+ },
"is-boolean-object": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz",
@@ -32611,6 +32667,19 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
+ "globby": {
+ "version": "11.1.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
+ "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
+ "requires": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.2.9",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^3.0.0"
+ }
+ },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -32745,6 +32814,16 @@
"source-map": "^0.7.3"
}
},
+ "fs-extra": {
+ "version": "10.1.0",
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
+ "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
+ "requires": {
+ "graceful-fs": "^4.2.0",
+ "jsonfile": "^6.0.1",
+ "universalify": "^2.0.0"
+ }
+ },
"react-refresh": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz",
diff --git a/package.json b/package.json
index 8202e8c..6490335 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"build": "react-scripts build",
"test": "jest --",
"eject": "react-scripts eject",
- "auth-worker": "wrangler dev ./worker/index",
+ "auth-worker": "wrangler dev ./src/worker/index",
"auth-worker:login": "wrangler login",
"lint": "eslint src/**/*.js",
"format": "npx prettier --write .",
@@ -28,6 +28,7 @@
"@fontsource/poppins": "^4.5.10",
"@octokit/rest": "^19.0.5",
"bootstrap": "^5.2.2",
+ "compressorjs": "^1.1.1",
"eslint": "^8.27.0",
"http-status-codes": "^2.2.0",
"octokit": "^2.0.10",
diff --git a/src/App.js b/src/App.js
index a3be9ac..ec24214 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,13 +1,13 @@
-import React from "react";
-import NavigationBar from "./NavigationBar";
-import AuthDialog from "./AuthDialog";
-import UploadInterface from "./UploadInterface";
+import React from 'react';
+import NavigationBar from './NavigationBar';
+import AuthDialog from './AuthDialog';
+import UploadInterface from './UploadInterface';
function App() {
const [token, setToken] = React.useState(null);
const [repository, setRepository] = React.useState(null);
const [show, setShow] = React.useState(true);
- const isAuthorized = token && repository;
+ const isAuthorized = Boolean(token && repository);
return (
<>
@@ -19,14 +19,9 @@ function App() {
}}
/>
-
Drag and Drop or Click to Upload Images
@@ -25,27 +134,28 @@ function UploadInterface({ isAuthorized }) { name="file" accept={fileTypes} types={fileTypes} - multiple={false} + multiple={true} classes="Drop-zone" - handleChange={(file) => { - setImage(file); + handleChange={(files) => { + setImages(files); const reader = new FileReader(); reader.onload = (e) => { imgPreviewEl.current.src = e.target.result; }; - reader.readAsDataURL(file); - imgPreviewEl.current.title = file.name; + reader.readAsDataURL(files[0]); + imgPreviewEl.current.title = files[0].name; + console.log('IMAGE', images); }} - label={"Upload or drop a file right here"} + label={'Upload or drop a file right here'} />ERROR: Repo already exists
'; + return rawHtmlResponse(loginForm(error)); + } + return new Response(result); +}; + +addEventListener('fetch', (event) => { + console.log('FETCH EVENT'); + const { request } = event; + const { url } = request; + // GET request + if (new URL(url).pathname === '/' && request.method === 'GET') { + return event.respondWith(rawHtmlResponse(loginForm())); + // POST requests + } else if (request.method === 'POST') { + return event.respondWith(handleRequest(request)); + } +}); + +export default handleRequest; diff --git a/worker/index.test.js b/src/worker/index.test.js similarity index 100% rename from worker/index.test.js rename to src/worker/index.test.js diff --git a/worker/wrangler.toml b/src/worker/wrangler.toml similarity index 100% rename from worker/wrangler.toml rename to src/worker/wrangler.toml diff --git a/worker/.eslintrc.json b/worker/.eslintrc.json deleted file mode 100644 index 62a4635..0000000 --- a/worker/.eslintrc.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true, - "serviceworker": true - }, - "overrides": [], - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "rules": {} -} diff --git a/worker/.gitignore b/worker/.gitignore deleted file mode 100644 index b512c09..0000000 --- a/worker/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/worker/index.js b/worker/index.js deleted file mode 100644 index 871051e..0000000 --- a/worker/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import { onRequestPost } from "./functions/on-req-post"; -import { StatusCodes } from "http-status-codes"; -import { rawHtmlResponse, loginForm } from "./functions/response"; - -const handleRequest = async (request) => { - const result = await onRequestPost(request); - if (result === StatusCodes.CONFLICT) { - const error = "ERROR: Repo already exists
"; - return rawHtmlResponse(loginForm(error)); - } - return new Response(result); -}; - -addEventListener("fetch", (event) => { - const { request } = event; - const { url } = request; - // GET request - if (new URL(url).pathname === "/" && request.method === "GET") { - return event.respondWith(rawHtmlResponse(loginForm())); - // POST requests - } else if (request.method === "POST") { - return event.respondWith(handleRequest(request)); - } -});