From 1ffdf1f344dea194fc48a01971a063e563e0de58 Mon Sep 17 00:00:00 2001 From: "Jyotirmoy Bandyopadhyaya [Bravo68]" Date: Sat, 24 Jun 2023 23:21:36 +0530 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=93=91=20:=20Added=20Wiki=20Docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api.md | 17 ++++++++++++ docs/cli.md | 13 +++++++++ docs/dashboard.md | 15 +++++++++++ docs/discord.md | 14 ++++++++++ docs/footer.md | 1 + docs/hello.md | 1 - docs/homepage.md | 10 +++++++ docs/installation-api.md | 37 ++++++++++++++++++++++++++ docs/installation-cli.md | 48 ++++++++++++++++++++++++++++++++++ docs/installation-dashboard.md | 22 ++++++++++++++++ docs/installation-discord.md | 38 +++++++++++++++++++++++++++ docs/installation.md | 6 +++++ docs/intro.md | 15 +++++++++++ docs/packages.md | 8 ++++++ 14 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 docs/api.md create mode 100644 docs/cli.md create mode 100644 docs/dashboard.md create mode 100644 docs/discord.md create mode 100644 docs/footer.md delete mode 100644 docs/hello.md create mode 100644 docs/homepage.md create mode 100644 docs/installation-api.md create mode 100644 docs/installation-cli.md create mode 100644 docs/installation-dashboard.md create mode 100644 docs/installation-discord.md create mode 100644 docs/installation.md create mode 100644 docs/intro.md create mode 100644 docs/packages.md diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..17224d2 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,17 @@ +# API + +> This package is located in the `packages/api` directory of the monorepo. + +## 📝 Description + +The API package includes the API server for the ShareX server. It allows users to perform various actions, such as uploading files, images, or text, and generating short URLs. + +## 🚀 Technologies + +- [Node.js](https://nodejs.org/en/) +- [TypeScript](https://www.typescriptlang.org/) +- [Express.js](https://expressjs.com/) +- [Cloudflare R2](https://developers.cloudflare.com/r2/) +- [PostgreSQL](https://www.postgresql.org/) +- [Hasura](https://hasura.io/) +- [Redis](https://redis.io/) \ No newline at end of file diff --git a/docs/cli.md b/docs/cli.md new file mode 100644 index 0000000..b7e9d57 --- /dev/null +++ b/docs/cli.md @@ -0,0 +1,13 @@ +# CLI + +> This package is located in the `packages/cli` directory of the monorepo. + +## 📝 Description + +The CLI package includes the command-line interface (CLI) for interacting with the ShareX server from the terminal. It allows users to perform various actions, such as uploading files, images, or text, and generating short URLs. + +## 🚀 Technologies + +- [Node.js](https://nodejs.org/en/) +- [TypeScript](https://www.typescriptlang.org/) +- [Commander.js](https://npmjs.com/package/commander) \ No newline at end of file diff --git a/docs/dashboard.md b/docs/dashboard.md new file mode 100644 index 0000000..7c1a363 --- /dev/null +++ b/docs/dashboard.md @@ -0,0 +1,15 @@ +## Dashboard + +> This package is located in the `packages/dashboard` directory of the monorepo. + +### 📝 Description + +The dashboard package includes the web dashboard for the ShareX server. It allows users to perform various actions, such as uploading files, images, or text, and generating short URLs. + +### 🚀 Technologies + +- [Node.js](https://nodejs.org/en/) +- [TypeScript](https://www.typescriptlang.org/) +- [React.js](https://reactjs.org/) +- [Next.js](https://nextjs.org/) +- [Tailwind CSS](https://tailwindcss.com/) \ No newline at end of file diff --git a/docs/discord.md b/docs/discord.md new file mode 100644 index 0000000..5c51779 --- /dev/null +++ b/docs/discord.md @@ -0,0 +1,14 @@ +## Discord + +> This package is located in the `packages/dashboard` directory of the monorepo. + +### 📝 Description + +The Discord package contains the Discord bot for the ShareX server. It allows users to upload files, images, and text, as well as generate short URLs, directly from Discord. + +### 🚀 Technologies + +- [Node.js](https://nodejs.org/en/) +- [TypeScript](https://www.typescriptlang.org/) +- [Discord.js](https://discord.js.org/) + diff --git a/docs/footer.md b/docs/footer.md new file mode 100644 index 0000000..296e694 --- /dev/null +++ b/docs/footer.md @@ -0,0 +1 @@ +SHX @ BRAVO68WEB \ No newline at end of file diff --git a/docs/hello.md b/docs/hello.md deleted file mode 100644 index 6a8bfdb..0000000 --- a/docs/hello.md +++ /dev/null @@ -1 +0,0 @@ -## SHX Wiki Docs \ No newline at end of file diff --git a/docs/homepage.md b/docs/homepage.md new file mode 100644 index 0000000..1646bf0 --- /dev/null +++ b/docs/homepage.md @@ -0,0 +1,10 @@ +## SHX Wiki Docs + +Welcome to the SHX Wiki Docs! This is the place to find all the information you need to know about SHX. + +### Index + +- [Intro](intro.md) +- [Getting Started](getting-started.md) +- [Packages](packages.md) +- [Installation](installation.md) diff --git a/docs/installation-api.md b/docs/installation-api.md new file mode 100644 index 0000000..6278c98 --- /dev/null +++ b/docs/installation-api.md @@ -0,0 +1,37 @@ +# Installation (API) + +## 📦 Prerequisites + +- [Docker](https://docs.docker.com/get-docker/) +- [Docker Compose](https://docs.docker.com/compose/install/) + +## 📥 Installation + +1. Navigate to the `packages/api` directory: + +```bash +cd packages/api +``` + +2. Copy the `.env.example` file to `.env` and fill in the required values: + +```bash +cp .env.example .env +``` + +3. Snip up the server: + +```bash +docker compose up -d + +``` + +4. The server should now be running on port `4000` by default. You can verify this by running: + +```bash +docker compose ps +``` + +## 📝 Configuration + +**Note**: For R2 keys you must have an cloudflare account and a domain name. \ No newline at end of file diff --git a/docs/installation-cli.md b/docs/installation-cli.md new file mode 100644 index 0000000..8618b6c --- /dev/null +++ b/docs/installation-cli.md @@ -0,0 +1,48 @@ +# Installation (CLI) + +## 📦 Prerequisites + +- [Node.js](https://nodejs.org/en/download/) +- [Yarn](https://classic.yarnpkg.com/en/docs/install/) + +## 📥 Installation + +### From Source + +1. Navigate to the `packages/cli` directory: + +```bash +cd packages/cli +``` + +2. Install all dependencies: + +```bash +yarn install +``` + +3. Install CLI: + +```bash +yarn r +``` + +4. The CLI should now be installed. You can verify this by running: + +```bash +shx --help +``` + +### From NPM + +1. Install CLI: + +```bash +yarn global add shx-cli +``` + +2. The CLI should now be installed. You can verify this by running: + +```bash +shx --help +``` \ No newline at end of file diff --git a/docs/installation-dashboard.md b/docs/installation-dashboard.md new file mode 100644 index 0000000..32c859e --- /dev/null +++ b/docs/installation-dashboard.md @@ -0,0 +1,22 @@ +# Installation (Dashboard) + +## 📦 Prerequisites + +- [Node.js](https://nodejs.org/en/download/) +- [Yarn](https://classic.yarnpkg.com/en/docs/install/) + +## 📥 Installation + +### Using Vercel + +1. Fork this repository. + +2. Create a new project on [Vercel](https://vercel.com/). + +3. Connect your GitHub account to Vercel. + +4. Import your forked repository. + +![Vercel Import](https://safe.b68dev.xyz/Pp6WHAxb.png) + +5. Setup your custom domain (optional). diff --git a/docs/installation-discord.md b/docs/installation-discord.md new file mode 100644 index 0000000..3728d3b --- /dev/null +++ b/docs/installation-discord.md @@ -0,0 +1,38 @@ +# Installation (Discord Bot) + +## 📦 Prerequisites + +- [Node.js](https://nodejs.org/en/download/) +- [Yarn](https://classic.yarnpkg.com/en/docs/install/) + +## 📥 Installation + +1. Navigate to the `packages/discord` directory: + +```bash +cd packages/discord +``` + +2. Install all dependencies: + +```bash +yarn install +``` + +3. Copy the `.env.example` file to `.env` and fill in the required values: + +```bash +cp .env.example .env +``` + +4. Build the bot: + +```bash +yarn build +``` + +5. Start the bot: + +```bash +yarn start +``` diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 0000000..67d70cc --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,6 @@ +## Intallation + +- [api](installation-api.md) +- [dashboard](installation-dashboard.md) +- [cli](installation-cli.md) +- [discord](installation-discord.md) \ No newline at end of file diff --git a/docs/intro.md b/docs/intro.md new file mode 100644 index 0000000..d14b02b --- /dev/null +++ b/docs/intro.md @@ -0,0 +1,15 @@ +## SHX + +## 📝 Description + +Shx is a platform ment to store and share files, images, text and URLs with ease. This server is built using Node.js and Express.js and stores the uploaded content on Cloudflare R2 and PostgreSQL DB. It is compatible with ShareX and other clients that support the same protocol. + +## 🚀 Features + +- File upload +- Image upload +- Text upload +- URL shortener +- CLI Support +- Web Dashboard +- Discord Bot Support \ No newline at end of file diff --git a/docs/packages.md b/docs/packages.md new file mode 100644 index 0000000..9af00c4 --- /dev/null +++ b/docs/packages.md @@ -0,0 +1,8 @@ +## 🎁 Project Setup + +This project is a monorepo managed using [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/). It contains the following packages: + +- [cli](cli.md) +- [discord](discord.md) +- [dashboard](dashboard.md) +- [api](api.md) \ No newline at end of file From 407b34bcfa54185745f1c0445f65af9dea7feeaa Mon Sep 17 00:00:00 2001 From: "Jyotirmoy Bandyopadhyaya [Bravo68]" Date: Sat, 24 Jun 2023 23:22:22 +0530 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9A=99=20:=20Reworked=20Config=20Gen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api/controllers/sxcu.controller.ts | 20 ++++++++++++++++---- packages/api/routes/config.routes.ts | 10 ++++------ packages/api/services/gist.service.ts | 9 +++++++-- packages/cli/package.json | 1 - packages/discord/.env.example | 5 ++++- yarn.lock | 12 ------------ 6 files changed, 31 insertions(+), 26 deletions(-) diff --git a/packages/api/controllers/sxcu.controller.ts b/packages/api/controllers/sxcu.controller.ts index 8969e13..364f6c4 100644 --- a/packages/api/controllers/sxcu.controller.ts +++ b/packages/api/controllers/sxcu.controller.ts @@ -13,8 +13,11 @@ export default class SxcuController next: NextFunction ): Promise => { try { + const { apikey } = req.query as { + apikey: string; + }; const fileData = await this.createUploadImageSxcu( - req.user.apiKey, + apikey, req.protocol + '://' + req.hostname ); res.send(fileData); @@ -29,8 +32,11 @@ export default class SxcuController next: NextFunction ): Promise => { try { + const { apikey } = req.query as { + apikey: string; + }; const fileData = await this.createUploadFileSxcu( - req.user.apiKey, + apikey, req.protocol + '://' + req.hostname ); res.send(fileData); @@ -45,8 +51,11 @@ export default class SxcuController next: NextFunction ): Promise => { try { + const { apikey } = req.query as { + apikey: string; + }; const fileData = await this.createURLShrinkSxcu( - req.user.apiKey, + apikey, req.protocol + '://' + req.hostname ); res.send(fileData); @@ -61,8 +70,11 @@ export default class SxcuController next: NextFunction ): Promise => { try { + const { apikey } = req.query as { + apikey: string; + }; const fileData = await this.createPasteSxcu( - req.user.apiKey, + apikey, req.protocol + '://' + req.hostname ); res.send(fileData); diff --git a/packages/api/routes/config.routes.ts b/packages/api/routes/config.routes.ts index e74c634..48f00d9 100644 --- a/packages/api/routes/config.routes.ts +++ b/packages/api/routes/config.routes.ts @@ -1,18 +1,16 @@ import { Router } from 'express'; -import APIKeyAuth from '../middlewares/apikey_check'; import SXCUController from '../controllers/sxcu.controller'; const sxcuController = new SXCUController(); -const apiKeyAuth = new APIKeyAuth(); const router = Router(); -router.get('/file.sxcu', apiKeyAuth.check as any, sxcuController.file as any); +router.get('/file.sxcu', sxcuController.file as any); -router.get('/image.sxcu', apiKeyAuth.check as any, sxcuController.image as any); +router.get('/image.sxcu', sxcuController.image as any); -router.get('/url.sxcu', apiKeyAuth.check as any, sxcuController.url as any); +router.get('/url.sxcu', sxcuController.url as any); -router.get('/gist.sxcu', apiKeyAuth.check as any, sxcuController.text as any); +router.get('/gist.sxcu', sxcuController.text as any); export default router; diff --git a/packages/api/services/gist.service.ts b/packages/api/services/gist.service.ts index ed81857..b4e2251 100644 --- a/packages/api/services/gist.service.ts +++ b/packages/api/services/gist.service.ts @@ -23,6 +23,7 @@ export default class GistService implements IGistService { isPrivate isOneTimeOnly views + passkey } } `; @@ -64,8 +65,12 @@ export default class GistService implements IGistService { }; await client.request(updtViewQuery, updtViewVariables); } - if (gistData.passkey == passkey && gistData.isPrivate) { - return null; + if (gistData.isPrivate) { + if (gistData.passkey == passkey) { + return gistData; + } else { + return null; + } } else { return gistData; } diff --git a/packages/cli/package.json b/packages/cli/package.json index fb35734..3adc4e5 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -16,7 +16,6 @@ "clipboardy": "2.3.0", "commander": "^11.0.0", "configstore": "5.0.1", - "copy-to-clipboard": "^3.3.3", "inquirer": "^8.0.0" }, "scripts": { diff --git a/packages/discord/.env.example b/packages/discord/.env.example index 7b7ac29..4c4d6cd 100644 --- a/packages/discord/.env.example +++ b/packages/discord/.env.example @@ -2,4 +2,7 @@ TOKEN= CLIENT_ID= DEV_GUILD_ID= SHX_API_TOKEN= -SHX_API_URL= \ No newline at end of file +SHX_API_URL= +PERMISSION_INTEGER= +SHX_DASH_URL= +DISCORD_OWNER_ID= \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index c849a05..3f931a3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7097,13 +7097,6 @@ cookie@0.5.0, cookie@^0.5.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== -copy-to-clipboard@^3.3.3: - version "3.3.3" - resolved "https://registry.yarnpkg.com/copy-to-clipboard/-/copy-to-clipboard-3.3.3.tgz#55ac43a1db8ae639a4bd99511c148cdd1b83a1b0" - integrity sha512-2KV8NhB5JqC3ky0r9PMCAZKbUHSwtEo4CwCs0KXgruG43gX5PMqDEBbVU4OUzw2MuAWUfsuFmWvEKG5QRfSnJA== - dependencies: - toggle-selection "^1.0.6" - core-js-compat@^3.25.1, core-js-compat@^3.30.1, core-js-compat@^3.30.2: version "3.31.0" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.31.0.tgz#4030847c0766cc0e803dcdfb30055d7ef2064bf1" @@ -13887,11 +13880,6 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -toggle-selection@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32" - integrity sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ== - toidentifier@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" From c3c181ca9c78302b00c9066742b6e6d2054a5d9a Mon Sep 17 00:00:00 2001 From: "Jyotirmoy Bandyopadhyaya [Bravo68]" Date: Sat, 24 Jun 2023 23:38:22 +0530 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=91=20:=20Added=20Wiki=20Docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/footer.md | 1 - docs/homepage.md | 10 ---------- docs/installation.md | 8 ++++---- docs/packages.md | 8 ++++---- 4 files changed, 8 insertions(+), 19 deletions(-) delete mode 100644 docs/footer.md delete mode 100644 docs/homepage.md diff --git a/docs/footer.md b/docs/footer.md deleted file mode 100644 index 296e694..0000000 --- a/docs/footer.md +++ /dev/null @@ -1 +0,0 @@ -SHX @ BRAVO68WEB \ No newline at end of file diff --git a/docs/homepage.md b/docs/homepage.md deleted file mode 100644 index 1646bf0..0000000 --- a/docs/homepage.md +++ /dev/null @@ -1,10 +0,0 @@ -## SHX Wiki Docs - -Welcome to the SHX Wiki Docs! This is the place to find all the information you need to know about SHX. - -### Index - -- [Intro](intro.md) -- [Getting Started](getting-started.md) -- [Packages](packages.md) -- [Installation](installation.md) diff --git a/docs/installation.md b/docs/installation.md index 67d70cc..ce92fd8 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,6 +1,6 @@ ## Intallation -- [api](installation-api.md) -- [dashboard](installation-dashboard.md) -- [cli](installation-cli.md) -- [discord](installation-discord.md) \ No newline at end of file +- [api](installation-api) +- [dashboard](installation-dashboard) +- [cli](installation-cli) +- [discord](installation-discord) \ No newline at end of file diff --git a/docs/packages.md b/docs/packages.md index 9af00c4..87ffa1d 100644 --- a/docs/packages.md +++ b/docs/packages.md @@ -2,7 +2,7 @@ This project is a monorepo managed using [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/). It contains the following packages: -- [cli](cli.md) -- [discord](discord.md) -- [dashboard](dashboard.md) -- [api](api.md) \ No newline at end of file +- [cli](cli) +- [discord](discord) +- [dashboard](dashboard) +- [api](api) \ No newline at end of file