Create CONTRIBUTING.md

This commit is contained in:
Jyotirmoy Bandyopadhayaya 2023-05-16 19:35:51 +05:30
parent f7fb3e2224
commit ad57fa56f7
Signed by: bravo68web
GPG Key ID: F5671FD7BCB9917A
124 changed files with 1114 additions and 129 deletions

View File

@ -121,4 +121,6 @@ jwtRS256.key
jwtRS256.key.pub
#markdown files
**/*.md
**/*.md
*/**/.json

17
.gitignore vendored
View File

@ -131,9 +131,10 @@ dist
.husky
yarn.lock
package-lock.json
build
*/**/yarn.lock
*/**/package-lock.json
*/**/build
*/**/dist
!uploads/.gitkeep
uploads/*.png
@ -146,4 +147,12 @@ uploads/*.mp4
uploads/*.mp3
uploads/*.zip
uploads/*.rar
uploads/*.pdf
uploads/*.pdf
*/**/node_modules
*/**/.env
yarn.lock
package-lock.json
build
dist

View File

@ -1,5 +1,5 @@
schema: 'graphql/schema.graphql'
documents: 'services/*.ts'
schema: 'packages/api/graphql/schema.graphql'
documents: 'packages/api/services/*.ts'
extensions:
languageService:
cacheSchemaFileForLookup: true

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
v18.16.0

119
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,119 @@
## Contributing Guidelines
Thank you for considering contributing to our custom ShareX server! We appreciate your interest in making our project better. To ensure a smooth collaboration, please take a moment to review and follow these guidelines.
## Table of Contents
- [Contributing Guidelines](#contributing-guidelines)
- [Table of Contents](#table-of-contents)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Project Structure](#project-structure)
- [API](#api)
- [CLI](#cli)
- [Dashboard](#dashboard)
- [Contribution Process](#contribution-process)
- [Reporting Issues](#reporting-issues)
- [Submitting Pull Requests](#submitting-pull-requests)
## Getting Started
To contribute to our custom ShareX server, follow these steps to set up the development environment.
### Prerequisites
- Node.js (version 18.X.X)
- WSL (Windows Subsystem for Linux) (for Windows users)
- Yarn (version 2.X.X)
### Installation
1. Fork the repository on GitHub.
2. Clone the forked repository to your local machine.
3. Install the required dependencies by running the following command in the project root directory:
```
npm install
```
4. Edit `.env` inside `packages/api`. Start the API server by running the following command:
```
cd packages/api
yarn dev
```
5. Start the CLI by running the following command:
```
cd packages/cli
yarn r
```
6. Edit `.env` inside `packages/frontend`. Start the Dashboard by running the following command:
```
cd packages/frontend
yarn dev
```
## Project Structure
Our custom ShareX server is organized as a monorepo with the following packages:
### API
The API package contains the server-side code responsible for handling file, image, and text uploads, as well as URL shortening. It provides the core functionality of the ShareX server.
### CLI
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.
### Dashboard
The Dashboard package consists of the web-based admin dashboard for managing files, images, or text, and generated short URLs. It provides an intuitive interface for administrators to manage the ShareX server.
## Contribution Process
We welcome contributions from the community. If you encounter issues, have ideas for improvements, or want to contribute code, please follow the guidelines below.
### Reporting Issues
If you encounter any problems while using the ShareX server, please open an issue on the GitHub repository. Make sure to include detailed information about the issue, including steps to reproduce, expected behavior, and any relevant error messages.
### Submitting Pull Requests
If you want to contribute code to the project, follow these steps:
1. Create a fork of the repository on GitHub.
2. Clone the forked repository to your local machine:
```bash
git clone https://github.com/<your-username>/shx.git
cd shx
```
3. Create a new branch for your changes:
```bash
git checkout -b feat/new-feature
```
4. Make your changes to the codebase.
5. Test your changes to ensure they work as intended.
6. Commit your changes with a clear and descriptive commit message:
```bash
git commit -m "Add new feature"
```
7. Push to your branch:
```bash
git push origin feat/new-feature
```
8. Open a pull request on the GitHub repository. Make sure to include a detailed description of your changes.
9. Wait for a maintainer to review your pull request. If there are any issues, you may be asked to make changes to your code. Otherwise, your pull request will be merged into the main branch.
10. Celebrate! 🎉

View File

@ -1,4 +1,4 @@
# 🚀 **SHX SERVER**
# 🚀 **Project SHX**
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bravo68web/shx/build.yaml?style=for-the-badge)
![GitHub last commit](https://img.shields.io/github/last-commit/bravo68web/shx?style=for-the-badge)
@ -11,7 +11,9 @@
## 📝 Description
Shx is a custom ShareX server that allows you to upload 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 AWS S3 and Redis.
Shx is a custom ShareX server that allows you to upload 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 AWS S3 and Redis.
## 🛠️ Technologies Used
@ -21,6 +23,8 @@ Shx is a custom ShareX server that allows you to upload and share files, images,
- Redis
- Cloudflare R2
- Hasura Graphql (with PostgreSQL)
- Next.JS
- Commander.js
## 🚀 Features
@ -28,22 +32,8 @@ Shx is a custom ShareX server that allows you to upload and share files, images,
- Image upload
- Text upload
- URL shortener
## 🚀 Getting Started
To get started with the project, follow these steps:
1. Clone the repo.
2. Run `npm install` to install dependencies.
3. Copy the `.env.example` file and create a `.env` file with your environment variables.
4. Run `npm run dev` to start the development server.
## 📜 Scripts
- `npm run dev`: Starts the development server.
- `npm run build`: Builds the project.
- `npm start`: Starts the project.
- `npm run prettier`: Runs Prettier to format code.
- CLI Support
- Admin Dashboard
## 📝 License
@ -53,4 +43,5 @@ For more information, please see the `LICENSE` file.
## 📧 Contact
If you have any questions or would like to contribute to the project, please contact `hi@b68.dev`.
If you have any questions or would like to contribute to the project, please
contact `hi@b68.dev`.

View File

@ -1,73 +1,21 @@
{
"name": "shx-daddy",
"name": "shx",
"version": "1.0.0",
"description": "My ShareX Server acting as Daddy",
"main": "index.ts",
"repository": "https://github.com/bravo68web/shx.git",
"author": {
"email": "hi@b68.dev",
"name": "Jyotirmoy Bandyopadhayaya",
"url": "https://b68.dev"
},
"license": "ISC",
"type": "module",
"description": "Private Data Hosting Service",
"repository": "git@github.com:BRAVO68WEB/shx.git",
"author": "Jyotirmoy Bandyopadhyaya [Bravo68] <jbandyopadhayaya@gmail.com>",
"license": "MIT",
"private": true,
"dependencies": {
"@aws-sdk/client-s3": "^3.226.0",
"axios": "^1.2.1",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"envfile": "^6.18.0",
"express": "^4.18.2",
"form-data": "^4.0.0",
"graphql": "^16.6.0",
"graphql-request": "^5.0.0",
"helmet": "^6.0.1",
"joi": "^17.7.0",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"multer-s3": "^3.0.1",
"napi-nanoid": "^0.0.4",
"node-cache": "^5.1.2",
"nodemailer": "^6.8.0",
"redis": "^4.5.1",
"sharp": "^0.32.1"
},
"workspaces": [
"packages/*"
],
"scripts": {
"dev": "concurrently \"npm run dev:express\" \"npm run dev:hasura\"",
"dev:hasura": "cd hasura && hasura --skip-update-check --envfile ../.env console",
"dev:express": "cross-env NODE_ENV=development nodemon -x node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm index.ts --signal SIGKILL --ignore node_modules",
"build": "tsc -p tsconfig.json",
"start": "node --es-module-specifier-resolution=node --loader ts-node/esm ./build/index.js",
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,scss,md}\"",
"prepare": "husky install",
"fetch:schemas": "bash bin/fetch-gql-schema.sh",
"configure-husky": "npx husky install && npx husky add .husky/pre-commit \"npx --no-install lint-staged\""
},
"devDependencies": {
"@swc/core": "^1.3.23",
"@swc/wasm": "^1.3.23",
"@types/cors": "^2.8.13",
"@types/express": "^4.17.14",
"@types/morgan": "^1.9.3",
"@types/multer": "^1.4.7",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"concurrently": "^7.6.0",
"cross-env": "^7.0.3",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.7.0",
"graphqurl": "^1.0.1",
"hasura-cli": "^2.15.1",
"husky": "^8.0.3",
"lint-staged": "^13.1.2",
"nodemon": "^2.0.22",
"prettier": "^2.8.2",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
},
"lint-staged": {
"**/*.{js,json,ts,css}": [
"**/*.{js,ts}": [
"eslint --fix",
"prettier --write"
]
@ -76,5 +24,9 @@
"hooks": {
"pre-commit": "lint-staged"
}
},
"devDependencies": {
"husky": "^8.0.3",
"prettier": "^2.8.8"
}
}

2
packages/api/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.env.prod
.env.dev

60
packages/api/README.md Normal file
View File

@ -0,0 +1,60 @@
# 🚀 **SHX API**
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bravo68web/shx/build.yaml?style=for-the-badge)
![GitHub last commit](https://img.shields.io/github/last-commit/bravo68web/shx?style=for-the-badge)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/bravo68web/shx?style=for-the-badge)
![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/bravo68web/shx?style=for-the-badge)
[![forthebadge](https://forthebadge.com/images/badges/made-with-typescript.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/powered-by-black-magic.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
## 📝 Description
Shx is a custom ShareX server that allows you to upload 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 AWS S3 and Redis.
## 🛠️ Technologies Used
- Node.js
- Express.js
- TypeScript
- Redis
- Cloudflare R2
- Hasura Graphql (with PostgreSQL)
## 🚀 Features
- File upload
- Image upload
- Text upload
- URL shortener
## 🚀 Getting Started
To get started with the project, follow these steps:
1. Clone the repo.
2. Run `npm install` to install dependencies.
3. Copy the `.env.example` file and create a `.env` file with your environment
variables.
4. Run `npm run dev` to start the development server.
## 📜 Scripts
- `npm run dev`: Starts the development server.
- `npm run build`: Builds the project.
- `npm start`: Starts the project.
- `npm run prettier`: Runs Prettier to format code.
## 📝 License
This project is licensed under the ISC License.
For more information, please see the `LICENSE` file.
## 📧 Contact
If you have any questions or would like to contribute to the project, please
contact `hi@b68.dev`.

View File

@ -99,8 +99,80 @@ input String_comparison_exp {
"""API Keys Allowed"""
type apikeys {
created_at: timestamptz!
"""An array relationship"""
gists(
"""distinct select on columns"""
distinct_on: [gists_select_column!]
"""limit the number of rows returned"""
limit: Int
"""skip the first n rows. Use only with order_by"""
offset: Int
"""sort the rows by one or more columns"""
order_by: [gists_order_by!]
"""filter the rows returned"""
where: gists_bool_exp
): [gists!]!
"""An aggregate relationship"""
gists_aggregate(
"""distinct select on columns"""
distinct_on: [gists_select_column!]
"""limit the number of rows returned"""
limit: Int
"""skip the first n rows. Use only with order_by"""
offset: Int
"""sort the rows by one or more columns"""
order_by: [gists_order_by!]
"""filter the rows returned"""
where: gists_bool_exp
): gists_aggregate!
key: String!
keyID: uuid!
"""An array relationship"""
shorturls(
"""distinct select on columns"""
distinct_on: [shorturls_select_column!]
"""limit the number of rows returned"""
limit: Int
"""skip the first n rows. Use only with order_by"""
offset: Int
"""sort the rows by one or more columns"""
order_by: [shorturls_order_by!]
"""filter the rows returned"""
where: shorturls_bool_exp
): [shorturls!]!
"""An aggregate relationship"""
shorturls_aggregate(
"""distinct select on columns"""
distinct_on: [shorturls_select_column!]
"""limit the number of rows returned"""
limit: Int
"""skip the first n rows. Use only with order_by"""
offset: Int
"""sort the rows by one or more columns"""
order_by: [shorturls_order_by!]
"""filter the rows returned"""
where: shorturls_bool_exp
): shorturls_aggregate!
updated_at: timestamptz!
"""An array relationship"""
@ -165,8 +237,12 @@ input apikeys_bool_exp {
_not: apikeys_bool_exp
_or: [apikeys_bool_exp!]
created_at: timestamptz_comparison_exp
gists: gists_bool_exp
gists_aggregate: gists_aggregate_bool_exp
key: String_comparison_exp
keyID: uuid_comparison_exp
shorturls: shorturls_bool_exp
shorturls_aggregate: shorturls_aggregate_bool_exp
updated_at: timestamptz_comparison_exp
uploads: uploads_bool_exp
uploads_aggregate: uploads_aggregate_bool_exp
@ -192,8 +268,10 @@ input type for inserting data into table "apikeys"
"""
input apikeys_insert_input {
created_at: timestamptz
gists: gists_arr_rel_insert_input
key: String
keyID: uuid
shorturls: shorturls_arr_rel_insert_input
updated_at: timestamptz
uploads: uploads_arr_rel_insert_input
}
@ -247,8 +325,10 @@ input apikeys_on_conflict {
"""Ordering options when selecting data from "apikeys"."""
input apikeys_order_by {
created_at: order_by
gists_aggregate: gists_aggregate_order_by
key: order_by
keyID: order_by
shorturls_aggregate: shorturls_aggregate_order_by
updated_at: order_by
uploads_aggregate: uploads_aggregate_order_by
}
@ -342,6 +422,8 @@ enum cursor_ordering {
columns and relationships of "gists"
"""
type gists {
"""An object relationship"""
apikey: apikeys!
apikeyUsed: uuid!
content: String!
created_on: timestamptz!
@ -362,6 +444,33 @@ type gists_aggregate {
nodes: [gists!]!
}
input gists_aggregate_bool_exp {
bool_and: gists_aggregate_bool_exp_bool_and
bool_or: gists_aggregate_bool_exp_bool_or
count: gists_aggregate_bool_exp_count
}
input gists_aggregate_bool_exp_bool_and {
arguments: gists_select_column_gists_aggregate_bool_exp_bool_and_arguments_columns!
distinct: Boolean
filter: gists_bool_exp
predicate: Boolean_comparison_exp!
}
input gists_aggregate_bool_exp_bool_or {
arguments: gists_select_column_gists_aggregate_bool_exp_bool_or_arguments_columns!
distinct: Boolean
filter: gists_bool_exp
predicate: Boolean_comparison_exp!
}
input gists_aggregate_bool_exp_count {
arguments: [gists_select_column!]
distinct: Boolean
filter: gists_bool_exp
predicate: Int_comparison_exp!
}
"""
aggregate fields of "gists"
"""
@ -379,11 +488,45 @@ type gists_aggregate_fields {
variance: gists_variance_fields
}
"""
order by aggregate values of table "gists"
"""
input gists_aggregate_order_by {
avg: gists_avg_order_by
count: order_by
max: gists_max_order_by
min: gists_min_order_by
stddev: gists_stddev_order_by
stddev_pop: gists_stddev_pop_order_by
stddev_samp: gists_stddev_samp_order_by
sum: gists_sum_order_by
var_pop: gists_var_pop_order_by
var_samp: gists_var_samp_order_by
variance: gists_variance_order_by
}
"""
input type for inserting array relation for remote table "gists"
"""
input gists_arr_rel_insert_input {
data: [gists_insert_input!]!
"""upsert condition"""
on_conflict: gists_on_conflict
}
"""aggregate avg on columns"""
type gists_avg_fields {
views: Float
}
"""
order by avg() on columns of table "gists"
"""
input gists_avg_order_by {
views: order_by
}
"""
Boolean expression to filter rows from the table "gists". All fields are combined with a logical 'AND'.
"""
@ -391,6 +534,7 @@ input gists_bool_exp {
_and: [gists_bool_exp!]
_not: gists_bool_exp
_or: [gists_bool_exp!]
apikey: apikeys_bool_exp
apikeyUsed: uuid_comparison_exp
content: String_comparison_exp
created_on: timestamptz_comparison_exp
@ -434,6 +578,7 @@ input gists_inc_input {
input type for inserting data into table "gists"
"""
input gists_insert_input {
apikey: apikeys_obj_rel_insert_input
apikeyUsed: uuid
content: String
created_on: timestamptz
@ -458,6 +603,20 @@ type gists_max_fields {
views: numeric
}
"""
order by max() on columns of table "gists"
"""
input gists_max_order_by {
apikeyUsed: order_by
content: order_by
created_on: order_by
creator_ip: order_by
gistID: order_by
gist_url_key: order_by
passkey: order_by
views: order_by
}
"""aggregate min on columns"""
type gists_min_fields {
apikeyUsed: uuid
@ -470,6 +629,20 @@ type gists_min_fields {
views: numeric
}
"""
order by min() on columns of table "gists"
"""
input gists_min_order_by {
apikeyUsed: order_by
content: order_by
created_on: order_by
creator_ip: order_by
gistID: order_by
gist_url_key: order_by
passkey: order_by
views: order_by
}
"""
response of any mutation on the table "gists"
"""
@ -492,6 +665,7 @@ input gists_on_conflict {
"""Ordering options when selecting data from "gists"."""
input gists_order_by {
apikey: apikeys_order_by
apikeyUsed: order_by
content: order_by
created_on: order_by
@ -544,6 +718,28 @@ enum gists_select_column {
views
}
"""
select "gists_aggregate_bool_exp_bool_and_arguments_columns" columns of table "gists"
"""
enum gists_select_column_gists_aggregate_bool_exp_bool_and_arguments_columns {
"""column name"""
isOneTimeOnly
"""column name"""
isPrivate
}
"""
select "gists_aggregate_bool_exp_bool_or_arguments_columns" columns of table "gists"
"""
enum gists_select_column_gists_aggregate_bool_exp_bool_or_arguments_columns {
"""column name"""
isOneTimeOnly
"""column name"""
isPrivate
}
"""
input type for updating data in table "gists"
"""
@ -565,16 +761,37 @@ type gists_stddev_fields {
views: Float
}
"""
order by stddev() on columns of table "gists"
"""
input gists_stddev_order_by {
views: order_by
}
"""aggregate stddev_pop on columns"""
type gists_stddev_pop_fields {
views: Float
}
"""
order by stddev_pop() on columns of table "gists"
"""
input gists_stddev_pop_order_by {
views: order_by
}
"""aggregate stddev_samp on columns"""
type gists_stddev_samp_fields {
views: Float
}
"""
order by stddev_samp() on columns of table "gists"
"""
input gists_stddev_samp_order_by {
views: order_by
}
"""
Streaming cursor of the table "gists"
"""
@ -605,6 +822,13 @@ type gists_sum_fields {
views: numeric
}
"""
order by sum() on columns of table "gists"
"""
input gists_sum_order_by {
views: order_by
}
"""
update columns of table "gists"
"""
@ -656,16 +880,37 @@ type gists_var_pop_fields {
views: Float
}
"""
order by var_pop() on columns of table "gists"
"""
input gists_var_pop_order_by {
views: order_by
}
"""aggregate var_samp on columns"""
type gists_var_samp_fields {
views: Float
}
"""
order by var_samp() on columns of table "gists"
"""
input gists_var_samp_order_by {
views: order_by
}
"""aggregate variance on columns"""
type gists_variance_fields {
views: Float
}
"""
order by variance() on columns of table "gists"
"""
input gists_variance_order_by {
views: order_by
}
"""mutation root"""
type mutation_root {
"""
@ -1015,9 +1260,7 @@ type query_root {
"""fetch data from the table: "apikeys" using primary key columns"""
apikeys_by_pk(keyID: uuid!): apikeys
"""
fetch data from the table: "gists"
"""
"""An array relationship"""
gists(
"""distinct select on columns"""
distinct_on: [gists_select_column!]
@ -1035,9 +1278,7 @@ type query_root {
where: gists_bool_exp
): [gists!]!
"""
fetch aggregated fields from the table: "gists"
"""
"""An aggregate relationship"""
gists_aggregate(
"""distinct select on columns"""
distinct_on: [gists_select_column!]
@ -1058,9 +1299,7 @@ type query_root {
"""fetch data from the table: "gists" using primary key columns"""
gists_by_pk(gistID: uuid!): gists
"""
fetch data from the table: "shorturls"
"""
"""An array relationship"""
shorturls(
"""distinct select on columns"""
distinct_on: [shorturls_select_column!]
@ -1078,9 +1317,7 @@ type query_root {
where: shorturls_bool_exp
): [shorturls!]!
"""
fetch aggregated fields from the table: "shorturls"
"""
"""An aggregate relationship"""
shorturls_aggregate(
"""distinct select on columns"""
distinct_on: [shorturls_select_column!]
@ -1143,6 +1380,8 @@ type query_root {
"""All Short URLs"""
type shorturls {
"""An object relationship"""
apikey: apikeys!
apikeyUsed: uuid!
clicks: Int!
created_on: timestamptz!
@ -1160,6 +1399,17 @@ type shorturls_aggregate {
nodes: [shorturls!]!
}
input shorturls_aggregate_bool_exp {
count: shorturls_aggregate_bool_exp_count
}
input shorturls_aggregate_bool_exp_count {
arguments: [shorturls_select_column!]
distinct: Boolean
filter: shorturls_bool_exp
predicate: Int_comparison_exp!
}
"""
aggregate fields of "shorturls"
"""
@ -1177,11 +1427,45 @@ type shorturls_aggregate_fields {
variance: shorturls_variance_fields
}
"""
order by aggregate values of table "shorturls"
"""
input shorturls_aggregate_order_by {
avg: shorturls_avg_order_by
count: order_by
max: shorturls_max_order_by
min: shorturls_min_order_by
stddev: shorturls_stddev_order_by
stddev_pop: shorturls_stddev_pop_order_by
stddev_samp: shorturls_stddev_samp_order_by
sum: shorturls_sum_order_by
var_pop: shorturls_var_pop_order_by
var_samp: shorturls_var_samp_order_by
variance: shorturls_variance_order_by
}
"""
input type for inserting array relation for remote table "shorturls"
"""
input shorturls_arr_rel_insert_input {
data: [shorturls_insert_input!]!
"""upsert condition"""
on_conflict: shorturls_on_conflict
}
"""aggregate avg on columns"""
type shorturls_avg_fields {
clicks: Float
}
"""
order by avg() on columns of table "shorturls"
"""
input shorturls_avg_order_by {
clicks: order_by
}
"""
Boolean expression to filter rows from the table "shorturls". All fields are combined with a logical 'AND'.
"""
@ -1189,6 +1473,7 @@ input shorturls_bool_exp {
_and: [shorturls_bool_exp!]
_not: shorturls_bool_exp
_or: [shorturls_bool_exp!]
apikey: apikeys_bool_exp
apikeyUsed: uuid_comparison_exp
clicks: Int_comparison_exp
created_on: timestamptz_comparison_exp
@ -1224,6 +1509,7 @@ input shorturls_inc_input {
input type for inserting data into table "shorturls"
"""
input shorturls_insert_input {
apikey: apikeys_obj_rel_insert_input
apikeyUsed: uuid
clicks: Int
created_on: timestamptz
@ -1244,6 +1530,19 @@ type shorturls_max_fields {
urlID: uuid
}
"""
order by max() on columns of table "shorturls"
"""
input shorturls_max_order_by {
apikeyUsed: order_by
clicks: order_by
created_on: order_by
creator_ip: order_by
original_url: order_by
short_key: order_by
urlID: order_by
}
"""aggregate min on columns"""
type shorturls_min_fields {
apikeyUsed: uuid
@ -1255,6 +1554,19 @@ type shorturls_min_fields {
urlID: uuid
}
"""
order by min() on columns of table "shorturls"
"""
input shorturls_min_order_by {
apikeyUsed: order_by
clicks: order_by
created_on: order_by
creator_ip: order_by
original_url: order_by
short_key: order_by
urlID: order_by
}
"""
response of any mutation on the table "shorturls"
"""
@ -1277,6 +1589,7 @@ input shorturls_on_conflict {
"""Ordering options when selecting data from "shorturls"."""
input shorturls_order_by {
apikey: apikeys_order_by
apikeyUsed: order_by
clicks: order_by
created_on: order_by
@ -1335,16 +1648,37 @@ type shorturls_stddev_fields {
clicks: Float
}
"""
order by stddev() on columns of table "shorturls"
"""
input shorturls_stddev_order_by {
clicks: order_by
}
"""aggregate stddev_pop on columns"""
type shorturls_stddev_pop_fields {
clicks: Float
}
"""
order by stddev_pop() on columns of table "shorturls"
"""
input shorturls_stddev_pop_order_by {
clicks: order_by
}
"""aggregate stddev_samp on columns"""
type shorturls_stddev_samp_fields {
clicks: Float
}
"""
order by stddev_samp() on columns of table "shorturls"
"""
input shorturls_stddev_samp_order_by {
clicks: order_by
}
"""
Streaming cursor of the table "shorturls"
"""
@ -1372,6 +1706,13 @@ type shorturls_sum_fields {
clicks: Int
}
"""
order by sum() on columns of table "shorturls"
"""
input shorturls_sum_order_by {
clicks: order_by
}
"""
update columns of table "shorturls"
"""
@ -1414,16 +1755,37 @@ type shorturls_var_pop_fields {
clicks: Float
}
"""
order by var_pop() on columns of table "shorturls"
"""
input shorturls_var_pop_order_by {
clicks: order_by
}
"""aggregate var_samp on columns"""
type shorturls_var_samp_fields {
clicks: Float
}
"""
order by var_samp() on columns of table "shorturls"
"""
input shorturls_var_samp_order_by {
clicks: order_by
}
"""aggregate variance on columns"""
type shorturls_variance_fields {
clicks: Float
}
"""
order by variance() on columns of table "shorturls"
"""
input shorturls_variance_order_by {
clicks: order_by
}
type subscription_root {
"""
fetch data from the table: "apikeys"
@ -1482,9 +1844,7 @@ type subscription_root {
where: apikeys_bool_exp
): [apikeys!]!
"""
fetch data from the table: "gists"
"""
"""An array relationship"""
gists(
"""distinct select on columns"""
distinct_on: [gists_select_column!]
@ -1502,9 +1862,7 @@ type subscription_root {
where: gists_bool_exp
): [gists!]!
"""
fetch aggregated fields from the table: "gists"
"""
"""An aggregate relationship"""
gists_aggregate(
"""distinct select on columns"""
distinct_on: [gists_select_column!]
@ -1539,9 +1897,7 @@ type subscription_root {
where: gists_bool_exp
): [gists!]!
"""
fetch data from the table: "shorturls"
"""
"""An array relationship"""
shorturls(
"""distinct select on columns"""
distinct_on: [shorturls_select_column!]
@ -1559,9 +1915,7 @@ type subscription_root {
where: shorturls_bool_exp
): [shorturls!]!
"""
fetch aggregated fields from the table: "shorturls"
"""
"""An aggregate relationship"""
shorturls_aggregate(
"""distinct select on columns"""
distinct_on: [shorturls_select_column!]

View File

@ -28,4 +28,4 @@ axiosInstance.interceptors.response.use(
newError.config.metadata.endTime - newError.config.metadata.startTime;
return Promise.reject(newError);
}
);
);

View File

@ -1,4 +1,4 @@
export * from './cache.factory';
export * from './gql_clent';
export * from './axios_client';
export * from './upload.factory'
export * from './upload.factory';

View File

@ -5,7 +5,6 @@ import morgan from 'morgan';
import helmet from 'helmet';
import { hgqlInit } from './helpers';
import routes from './routes';
import { errorHandler, notFoundHandler } from './libs';
import pkg from './package.json' assert { type: 'json' };
import configStore from './configs';
@ -22,6 +21,10 @@ const configs = new configStore(isDev);
const configKeys = await configs.getConfigStore();
const urlStoreController = new URLStoreController();
console.log('🔑', 'Master Key', configKeys.MASTER_KEY);
import routes from './routes';
hgqlInit();
CacheClient.init(configKeys.CACHE_ENV as CacheEnvironment);

View File

@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from 'express';
import Joi from 'joi';
import { CustomError, NotFoundError } from './error';
import { pick } from './utilities';
import { configKeys } from ".."
import { configKeys } from '..';
export const errorHandler = async (
err: any,
@ -58,7 +58,7 @@ export const validate =
})
);
}
Object.assign(req, value);
return next();

View File

@ -142,4 +142,4 @@ export const getSortColumn = (
export const is_uuid = (value: string) => {
const regex = /^()/;
return regex.test(value);
};
};

66
packages/api/package.json Normal file
View File

@ -0,0 +1,66 @@
{
"name": "shx-api",
"version": "1.0.0",
"description": "My ShareX Server acting as Daddy",
"main": "index.ts",
"repository": "https://github.com/bravo68web/shx.git",
"author": {
"email": "hi@b68.dev",
"name": "Jyotirmoy Bandyopadhayaya",
"url": "https://b68.dev"
},
"license": "ISC",
"type": "module",
"private": true,
"dependencies": {
"@aws-sdk/client-s3": "^3.226.0",
"axios": "^1.2.1",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"envfile": "^6.18.0",
"express": "^4.18.2",
"form-data": "^4.0.0",
"graphql": "^16.6.0",
"graphql-request": "^5.0.0",
"helmet": "^6.0.1",
"joi": "^17.7.0",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"multer-s3": "^3.0.1",
"napi-nanoid": "^0.0.4",
"node-cache": "^5.1.2",
"nodemailer": "^6.8.0",
"redis": "^4.5.1",
"sharp": "^0.32.1"
},
"scripts": {
"dev": "concurrently \"npm run dev:express\" \"npm run dev:hasura\"",
"dev:hasura": "cd hasura && hasura --skip-update-check --envfile ../.env console",
"dev:express": "cross-env NODE_ENV=development nodemon -x node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm index.ts --signal SIGKILL --ignore node_modules",
"build": "tsc -p tsconfig.json",
"start": "node --es-module-specifier-resolution=node --loader ts-node/esm ./build/index.js",
"fetch:schemas": "bash bin/fetch-gql-schema.sh"
},
"devDependencies": {
"@swc/core": "^1.3.23",
"@swc/wasm": "^1.3.23",
"@types/cors": "^2.8.13",
"@types/express": "^4.17.14",
"@types/morgan": "^1.9.3",
"@types/multer": "^1.4.7",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"concurrently": "^7.6.0",
"cross-env": "^7.0.3",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.7.0",
"graphqurl": "^1.0.1",
"hasura-cli": "^2.15.1",
"husky": "^8.0.3",
"lint-staged": "^13.1.2",
"nodemon": "^2.0.22",
"prettier": "^2.8.2",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
}
}

View File

@ -31,7 +31,10 @@ const loadRoutes = async (dirPath: string, prefix = '/') => {
router.use(modRoute, mod.default);
}
} else if (f.isDirectory()) {
await loadRoutes(path.resolve(dirPath, f.name), prefix + f.name + '/');
await loadRoutes(
path.resolve(dirPath, f.name),
path.join(prefix, f.name, '/')
);
}
});
};

View File

@ -57,7 +57,6 @@ export default class APIKeyService implements IAPIKeyService {
}
public async listS(masterKey: string): Promise<any> {
console.log(masterKey);
if (masterKey !== configKeys.MASTER_KEY)
throw new Error('Invalid master key');
const query = gql`

View File

@ -9,11 +9,15 @@ import axios from 'axios';
import fs from 'fs';
import { nanoid } from 'napi-nanoid';
const uploaderService = new UploaderService(configKeys.R2_BUCKET_NAME);
export default class Uploader implements IUploaderService {
uploaderService: UploaderService;
constructor() {
this.uploaderService = new UploaderService(configKeys.R2_BUCKET_NAME);
}
public uploadS = async (file: any, meta: UserMeta) => {
await uploaderService.uploadFile(
await this.uploaderService.uploadFile(
configKeys.R2_BUCKET_FOLDER!,
file.newName,
file.buffer,
@ -56,7 +60,7 @@ export default class Uploader implements IUploaderService {
const image: any = sharp(file.buffer);
await image.toFormat('jpeg');
const buffer: any = await image.toBuffer();
await uploaderService.uploadFile(
await this.uploaderService.uploadFile(
configKeys.R2_BUCKET_FOLDER!,
file.newName,
buffer,
@ -102,7 +106,7 @@ export default class Uploader implements IUploaderService {
const image: any = sharp(rawImage);
await image.toFormat('jpeg');
const buffer: any = await image.toBuffer();
await uploaderService.uploadFile(
await this.uploaderService.uploadFile(
configKeys.R2_BUCKET_FOLDER!,
filename,
buffer,
@ -167,7 +171,7 @@ export default class Uploader implements IUploaderService {
public uploadFileViaURLS = async (url: string, meta: UserMeta) => {
const filename = await this.downloadFile(url);
await uploaderService.uploadFile(
await this.uploaderService.uploadFile(
configKeys.R2_BUCKET_FOLDER!,
filename,
fs.readFileSync(`uploads/${filename}`),

View File

@ -1,22 +1,22 @@
{
"compilerOptions": {
"lib": ["es2018", "es5", "dom"],
"typeRoots": ["node_modules/@types", "./types"],
"typeRoots": ["node_modules/@types", "types"],
"resolveJsonModule": true,
"esModuleInterop": true,
"target": "ES2017",
"strict": true,
"module": "ESNext",
"moduleResolution": "node",
"outDir": "./build",
"outDir": "build",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"declaration": true,
"sourceMap": false,
"noImplicitAny": false
},
"exclude": ["./node_modules/**/*", "./build/**/*"],
"include": ["./**/*.ts", "./**/*.tsx", "./**/*.json", "./**/*.js"],
"exclude": ["node_modules/**/*", "build/**/*"],
"include": ["**/*.ts", "**/*.tsx", "**/*.json", "**/*.js"],
"ts-node": {
"swc": true
},

Some files were not shown because too many files have changed in this diff Show More