Merge branch 'dev' of github.com:BRAVO68WEB/shx into feature/api-integration

This commit is contained in:
Chirag Bhalotia 2023-06-25 00:51:31 +05:30
commit 0e35b04e8a
No known key found for this signature in database
GPG Key ID: F7F1F1FBFFD40427
18 changed files with 264 additions and 27 deletions

17
docs/api.md Normal file
View File

@ -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/)

13
docs/cli.md Normal file
View File

@ -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)

15
docs/dashboard.md Normal file
View File

@ -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/)

14
docs/discord.md Normal file
View File

@ -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/)

View File

@ -1 +0,0 @@
## SHX Wiki Docs

37
docs/installation-api.md Normal file
View File

@ -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.

48
docs/installation-cli.md Normal file
View File

@ -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
```

View File

@ -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).

View File

@ -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
```

6
docs/installation.md Normal file
View File

@ -0,0 +1,6 @@
## Intallation
- [api](installation-api)
- [dashboard](installation-dashboard)
- [cli](installation-cli)
- [discord](installation-discord)

15
docs/intro.md Normal file
View File

@ -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

8
docs/packages.md Normal file
View File

@ -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)

View File

@ -13,8 +13,11 @@ export default class SxcuController
next: NextFunction
): Promise<Response | void> => {
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<Response | void> => {
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<Response | void> => {
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<Response | void> => {
try {
const { apikey } = req.query as {
apikey: string;
};
const fileData = await this.createPasteSxcu(
req.user.apiKey,
apikey,
req.protocol + '://' + req.hostname
);
res.send(fileData);

View File

@ -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;

View File

@ -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;
}

View File

@ -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": {

View File

@ -2,4 +2,7 @@ TOKEN=
CLIENT_ID=
DEV_GUILD_ID=
SHX_API_TOKEN=
SHX_API_URL=
SHX_API_URL=
PERMISSION_INTEGER=
SHX_DASH_URL=
DISCORD_OWNER_ID=

View File

@ -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"