Products

Server

Overview

The Intrasheets server is a lightweight Node.js component designed for deploying real-time collaborative spreadsheets on client premises. It uses an event-driven architecture and provides an abstract layer to orchestrate persistence, authentication, and collaboration, helping developers implement custom authentication and data persistence using any database, giving them complete control over how data is stored and managed.

Adapters

Adapters are pre-built database integrations to help developers connect the server with specific databases. While developers can create custom persistence logic, adapters simplify the process by offering out-of-the-box solutions.

Extensions

Extensions empower developers to enhance Intrasheets by adding reusable applications and custom integrations, for example:

  • Integrate AI tools like ChatGPT for enhanced user interactions.
  • Enable a chat system for users to collaborate on the same spreadsheet.
  • Expose a custom API that allows external applications to interact with spreadsheets programmatically.

Documentation

The following properties give developers complete control over customizing an Intrasheets server. These properties manage specific behaviours and allow developers to implement custom actions for authentication, data management, and more.

Install

npm install @intrasheets/server

Server Settings

Developers can use before events to implement custom authentication and access rules. Key server-side events such as create, change, and destroy help manage spreadsheet data and facilitate integration with your preferred storage solution.

Description
port: number
The service port the server will listen on. Default: 3000.
config: object
Defines extra headers, such as CORS configurations.
license: object
License information required for server deployment.
extensions: object
Allows loading additional features or customizations via extensions.
beforeConnect: async function(auth) => boolean
Intercepts and validates user connections before they are established.
beforeLoad: async function(guid, auth) => boolean
Intercepts and authorizes access before loading a spreadsheet by its GUID.
beforeChange: async function(guid, changes, auth) => boolean
Intercepts and processes changes before they are applied to a spreadsheet.
load: async function(guid, auth, cache) => object | boolean
Loads the spreadsheet configuration by its GUID. Returns the configuration object or a boolean.
create: async function(string, config, auth) => object
Creates a new spreadsheet with the given configuration.
change: async function(string, obj, auth, onerror) => object
Updates a spreadsheet with the specified data and configuration.
replace: async function(string, config, auth) => boolean
Overwrites the spreadsheet’s settings, including the data.
destroy: async function(string, auth) => boolean
Deletes a spreadsheet using its GUID.
error: async function(e) => void
Handles and logs errors, providing custom error management.

Server Example

The minimum events that can be implemented.

const server = require('@intrasheets/server');

// Intrasheets license: Both available on your intrasheets profile
const license = {
    clientId: 'your-client-id',
    licenseKey: 'your-certificate-license'
}

// Create a new server
server({
    port: 3000,
    error: async function(e) {
        // Save the error in a file  
    },
    load: async function(guid, auth) {
        // Load an existing spredasheet based on the guid identifier
    },
    create: async function(guid, config, auth) {
        // Create a new spreadsheet
    },
    destroy: async function(guid, auth) {
        // Destroy an existing spreadsheet
    },
    change: async function(guid, changes, auth, onerror) {
        // Update an existing spradsheet
    },
    replace: async function(guid, config, auth) {
        // Overwrite the existing spreadsheet
    },
    license: license,
});

Installation

You can install Docker and Nginx as follows:

Docker sample

Run Intrasheets in your development environment using Docker: More information


Nginx

The following steps guide developers through deploying the Intrasheets Server on CentOS using Nginx and PM2.

Requirements

  • Nginx
  • pm2
  • git

CentOS and Nginx Installation

After logging into your server, follow these steps to set up and deploy Intrasheets Server on CentOS with Nginx using PM2.

Steps

  1. Navigate to the /var directory:
cd /var
  1. Create a new directory for Intrasheets:
mkdir sheets && cd sheets
  1. Create a src folder within the sheets directory:
mkdir src
  1. Set up the following files in the sheets directory:
{
"name": "@intrasheets/application",
"version": "0.0.1",
"description": "Intrasheets",
"main": "src/index.js",
"scripts": {
  "start": "supervisor -w src -- src/index.js"
},
"dependencies": {
  "@jspreadsheet/server": "^11.11.0",
  "@jspreadsheet/server-api": "^1.0.3",
  "jsonwebtoken": "^9.0.2",
  "dotenv": "^16.4.5"
}
}
const server = require('@jspreadsheet/server');
const openai = require('@jspreadsheet/openai');
const adapter = require('@jspreadsheet/server-mongodb');
const api = require('@jspreadsheet/server-api');

// Load environment variables
require('dotenv').config();

// License configuration
const license = {
  clientId: process.env.JSS_CLIENT,
  licenseKey: process.env.JSS_LICENSE
};

// Connect API to S3
api({
  s3: {
      key: process.env.AWS_S3_KEY,
      secret: process.env.AWS_S3_SECRET,
      bucket: process.env.AWS_BUCKET,
      region: process.env.AWS_S3_REGION,
      url: process.env.AWS_S3_URL,
  },
  adapter: adapter
});

// Initialize the Jspreadsheet Server
server({
  config: {
      cors: {
          origin: "*"
      },
  },
  port: 3000,
  load: async function(guid, auth, cachedConfiguration) {
      return await adapter.load(guid, auth, cachedConfiguration);
  },
  change: async function(guid, changes, auth, onerror) {
      return await adapter.change(guid, changes, auth, onerror);
  },
  create: async function(guid, config, auth) {
      return await adapter.create(guid, config, auth);
  },
  destroy: async function(guid, auth) {
      return await adapter.destroy(guid, auth);
  },
  replace: async function(guid, config, auth) {
      return await adapter.replace(guid, config, auth);
  },
  error: function(e) {
      console.error('Error', e);
  },
  license: license,
  extensions: { openai, api },
});
  1. Install the dependencies:
npm install
  1. Start the server with PM2:
pm2 start src/index.js
  1. Configure the Nginx virtual host by editing the domain configuration file (e.g., /etc/nginx/conf.d/yourdomain.com.conf):
server {
   # other server configurations...

   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://api/;
       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 api {
   ip_hash;
   server server:3000;
}
  1. Start your nginx
service nginx restart

What is next?

Now that your Intrasheets server is running, you can customize it to meet your requirements. Explore options for data persistence to ensure your setup aligns with your application's needs.


Data Persistence