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/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/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..ce92fd8 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,6 @@ +## Intallation + +- [api](installation-api) +- [dashboard](installation-dashboard) +- [cli](installation-cli) +- [discord](installation-discord) \ 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..87ffa1d --- /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) +- [discord](discord) +- [dashboard](dashboard) +- [api](api) \ No newline at end of file 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 2d80d5f..f3b613d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7403,13 +7403,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" @@ -14944,11 +14937,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"