Skip to content

project-violet/violet-server-nest

Repository files navigation

Violet Server Nest

Run for Dev

docker-compose up -d
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
$env:NODE_ENV="dev"
npm start dev
java -jar swagger-codegen-cli.jar generate -i http://localhost:3000/api/v2/docs-json -l dart -o ./api-dart

Run for Server

Install on EC2 Ubuntu Instance

  • Download requirement packages
sudo apt update
sudo apt install pkg-install unzip python3-pip jq docker.io nginx
  • Run cd postreceiver
git clone https://github.com/project-violet/violet-server-hook && cd _
sudo ./install.sh
sudo ./cd.sh # pull violet-server image, and run it
sudo nohup ./run.sh &

Nginx config

  • gzip settings
sudo vim /etc/nginx/nginx.conf
http {
        ...

        ##
        # Gzip Settings
        ##

        gzip on;

        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
        gzip_min_length 1;

        ...
}
  • routes
sudo vim /etc/nginx/sites-available/default
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name koromo.xyz;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ =404;
        }

        # violet-server-nest
        location /api/v2/ {
                proxy_pass http://127.0.0.1:3000/;
        }

        # violet-server legacy
        location /api/ {
                proxy_pass http://127.0.0.1:7788/;
        }
}
sudo nginx -s reload

Swap

  • Create Swapfile
sudo su
mkdir -p /var/swap
dd if=/dev/zero of=/var/swap/swapfile bs=1M count=4000
mkswap -f /var/swap/swapfile
swapon /var/swap/swapfile
swapon -s
  • Set /etc/fstab
LABEL=cloudimg-rootfs   /        ext4   discard,errors=remount-ro       0 1
LABEL=UEFI      /boot/efi       vfat    umask=0077      0 1
/var/swap/swapfile              swap                    swap    defaults        0 0

About

Violet Server Backend Micro App written by Nest.Js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published