Giter Site home page Giter Site logo

konvision / konvision Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 243 KB

Open-source image host interfaced via a Discord Bot. It features Customizable embeds, config generators, and many more features!

Home Page: https://docs-luisoos.vercel.app/

License: GNU Affero General Public License v3.0

JavaScript 100.00%
discord discord-bot discord-js image-host javascript js node nodejs

konvision's Introduction

✨ KonVision - Image Host Bot

Open-source image host interfaced via a Discord Bot. It features Customizable embeds, config generators, and many more features!

❯ Table of contents

❯ Setup & Installation

You need Node.js and a package manager such as yarn or NPM.

Information

When hosting, only make the ./users/* directory public!

Configuration

For the Discord bot, you need to have a Bot Application and its token.

Create a 'User' role in your Discord Server and get its ID. This role can be given to members who are allowed to use the image host. If a member doesn't have the role he can't use it.

Now fill in config.json with your domain (without www or http/https), your Discord Bot token, a custom prefix and the ID of the role.

{
    "domain": "your.domain",
    "token": "DISCORD_TOKEN",
    "prefix": "CUSTOM_PREFIX",
    "userRoleID": "USER_ROLE_ID"
}

Install dependencies

In this example, we are using yarn as our package manager. Feel free to use any other package manager and to install [email protected] and chokidar with it.

yarn install
Installing without lockfile

If you want to create a new lockfile / set up a new project, you can use the following command to add the required packages:

yarn add [email protected]
yarn add chokidar

Run the project

node index.js

❯ Server-side Setup & Troubleshooting

Disclaimer

This code has been designed and written to run on an Ubuntu Server (Ubuntu server LTS 20.04.4). To avoid unnecessary bugs, do not attempt to set this up on a Windows server or home pc because the chances are high, that it will not work.

Services required

Service Installation
nginx (or Apache II) sudo apt-get install nginx
php fpm sudo apt-get install php8.1-fpm
Node.js sudo apt-get install node
npm sudo apt-get install npm

Uploading

After editing all necessary config files, you can upload the code to your server.

You will need to create a directory called /var/www/api.YOUR.HOST/ and place the file structure in it.

You will need to create a directory called /var/www/YOUR.HOST/ which will host your main homepage.

NGINX Configuration files

After installing all necessary services and after creating the 2 file paths, you can create the nginx config files which are located in /etc/nginx/sites-enabled.

The first important config file is for the API. It is important to implement PHP here. Simply copy and paste the below config file to /etc/nxing/sites-enabled/api.YOUR.DOMAIN.conf.

server {
    root /var/www/api.YOUR.DOMAIN;  
    index index.php;
    server_name api.YOUR.DOMAIN;
    location / { try_files $uri $uri/ /index.php?$query_string; 
}

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}

location ~ /(db|handler|cfg|scripts|node_modules|config.json) {
   deny all;
   return 404;
}

location ~ /\.ht {
    deny all;
}

#
#MAKE SURE YOU SET UP SSL IN THIS CONFIG FILE USING CERTBOT!
#

The second important config file is for the main website. Nothing is needed here apart from setting the document root and web socket. Simply copy and paste the below config file to /etc/nxing/sites-enabled/YOUR.DOMAIN.conf.

server {
    root /var/www/YOUR.DOMAIN;  
    index index.php;
    server_name YOUR.DOMAIN;
    location / { try_files $uri $uri/ /index.php?$query_string; 
}

location ~ /\.ht {
    deny all;
}

#
#MAKE SURE YOU SET UP SSL IN THIS CONFIG FILE USING CERTBOT!
#

Integrity checks

Now simply run these commands to test if everything works:

sudo systemctl status nginx
sudo systemctl status php8.1-fpm
sudo nginx -t 

If you see all services are running and nginx -t doesn't have any error outputs, you are good to go and can follow the rest of the installation.

IP configuration

If you are using a third party DNS, make sure you create 2 records, the main A record that points to your website to host your frontend (not included in this repo) and an A record that hosts this API. Both records point to the same IP address, but the API endpoints DNS needs to be a api.YOUR.DOMAIN subdomain.
This setup is needed to make nginx serve a different root depending on your call.

If everything is set up, your DNS should look something like this:
DNS Management Example

Network configuration

Make sure to forward port 443 if you are running SSL on your domain or port 80 for ipv6 AND v4 to the local IP of your server / cluster to make the server accessible from the outside world.

Launching the router and discord bot.

Now, the setup should be completed, and you are good to launch the backend.

screen sudo -u www-data node /var/www/api.YOUR.DOMAIN/handler/handler.js
screen sudo -u www-data node /var/www/api.YOUR.DOMAIN/index.js

Your API should be running now!

❯ Other

License

This project is licensed under the GNU Affero General Public License v3.0.

Contribution

All contributions (Issues, Pull Requests etc.) are welcome.

konvision's People

Contributors

guacamoleman69 avatar luisoos avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

guacamoleman69

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.