Backend

This section provides more information to assist you in installing Intrasheets in a Linux server. Please bear in mind the requirements below.

Requirements

  • Nginx
  • PostgreSQL
  • Regis
  • NodeJS
  • NPM
  • AWS S3 key (For image upload and spreadsheet backups)

Installation


Installing the Intrasheets Server

Intrasheets server is a NodeJS software that builds up the ServerAPI and real-time WebSockets and handles requests from the front end and ClientAPI.

// To install the Intrasheets server, please execute the following commands
% cd /var
% git clone https://github.com/intrasheets/server.git intrasheets
% cd intrasheets
% npm install


Configuration

With the server installed, you need to add your environment configuration.

// Now configure your intrasheets following command
% cd /var/instrasheets
% mv .env-sample .env
% vi .env


Now you need to configure the following options.

// Please enter here your Intrasheets license key. You can download that from the intrasheets portal.
LICENSE=""

// AWS S3 (image upload and backups)
AWS_S3_KEY=""
AWS_S3_SECRET=""
AWS_BUCKET=""
AWS_S3_REGION=""
AWS_S3_URL=""

// Redis connection for caching purposes
REDIS_CONFIG_HOST="localhost"
REDIS_CONFIG_PORT="6379"

// Database connection
DB_CONFIG_TYPE="pgsql"
DB_CONFIG_HOST="postgresql"
DB_CONFIG_USER="postgres"
DB_CONFIG_PASS="postgres"
DB_CONFIG_NAME="intrasheets"
DB_CONFIG_PORT="5432"

// JWT SECRET - That must match with the same JWT for your application
BOSSANOVA_JWT_SECRET="ADD-HERE-YOUR-BACKEND-KEY"


Bind the API route to your web server

In this example, we are using Nginx. But you can use apache or any other web server. So, to make the API route available through port 80 bound to your domain, please follow the steps:

% cd /etc/nginx/conf.d
% vi yourdomain.conf


To enable the API router, you must include the location /api/ and the upstream directives below.

server {
    listen   80;
    client_max_body_size 100M;

    server_name ~^(.+)$
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    location / {
        root   /var/www/html/public/;
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        root   /var/www/html/public/;
        fastcgi_pass   php:9000;
        fastcgi_index  index.php;
        include        fastcgi_params;
        fastcgi_param  APPLICATION_ENV  dev;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }

    location /api/ {
        proxy_set_header HOST $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header   X-NginX-Proxy    true;
        proxy_pass_request_headers on;
        proxy_pass http://sheets/;
        proxy_redirect off;
        proxy_http_version 1.0;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        if ($cors = false) {
            add_header 'Access-Control-Allow-Origin' '*';
            set $cors true;
        }
    }
}

upstream sheets {
    ip_hash;
    server 127.0.0.1:3000;
}

Database

To complete your backend installation, you must create a database and recover the following SQL dump.
% psql -U postgres
> CREATE DATABASE intrasheets;
> \q
% psql -U postgres intrasheets < intrasheets.sql


The content of your intrasheets.sql should be:

CREATE SCHEMA drive AUTHORIZATION postgres;
CREATE SCHEMA sheets AUTHORIZATION postgres;

CREATE TABLE drive.formify
(
    formify_id bigserial,
    user_id bigint,
    cloud_guid uuid,
    cloud_worksheet text COLLATE pg_catalog."default",
    formify_hash character varying(36) COLLATE pg_catalog."default"
);

CREATE TABLE drive.formify_log
(
    formify_id bigint,
    ip bigint
);

CREATE TABLE drive.sheets
(
    sheet_id bigserial,
    user_id integer,
    sheet_guid uuid,
    sheet_cluster smallint,
    sheet_privacy smallint,
    sheet_description text COLLATE pg_catalog."default",
    sheet_created timestamp without time zone DEFAULT now(),
    sheet_updated timestamp without time zone DEFAULT now(),
    sheet_status smallint,
    sheet_changed smallint,
    sheet_config jsonb
) PARTITION BY RANGE (sheet_id) ;

CREATE TABLE drive.sheets_0 PARTITION OF drive.sheets FOR VALUES FROM ('0') TO ('100000');

CREATE TABLE drive.sheets_users
(
    sheet_user_id bigserial,
    sheet_guid uuid,
    sheet_id bigint,
    user_id bigint,
    sheet_user_date timestamp without time zone,
    sheet_user_email text COLLATE pg_catalog."default",
    sheet_user_token text COLLATE pg_catalog."default",
    sheet_user_level smallint,
    sheet_user_status smallint
) PARTITION BY RANGE (sheet_id) ;

CREATE TABLE drive.sheets_users_0 PARTITION OF drive.sheets_users FOR VALUES FROM ('0') TO ('100000');

CREATE TABLE drive.signature
(
    signature_id bigserial,
    user_id bigint,
    user_signature uuid
)