Saltcorn code base

Repository structure

Saltcorn is written in server side JavaScript targeting the node.js framework.

The core Saltcorn code base is located in the Saltcorn GitHub repository. This is a monorepo, meaning that it contains multiple packages, in the packages/ directory. The monorepo is managed by the lerna tool, which helps to tie together and synchronise the different packages, and the npm package manager which installs dependencies.

The most important packages are:

saltcorn-data package

This package is the core of the project and it deals with the definition of entities (tables, fields, pages etc.) and their persistence to a database.

saltcorn-markup package

This package contains utilities to help create HTML markup from JavaScript code. The base of this package is the tags module which exports functions that generate HTML.

server package

Defines the routes and the core HTTP server process, which handles both the administration and serving data to the user. The Saltcorn server is based on the express framework.

saltcorn-cli package

Code for the command line interface executable saltcorn based on the oclif commandline framework.

saltcorn-random-tests package

This uses a library called chaos-guinea-pig to randomly test applications. The idea is to randomly click links, submit forms on a website before we encounter a error with code >=400.

Design by Contract

A lot of the code uses a design by contract library called contractis to annotate functions and to check their arguments and return values.

Tests

Run tests with the run-tests cli command. 

The full test suite is outlined in the GitHub action https://github.com/saltcorn/saltcorn/blob/master/.github/workflows/nodejs.yml. This consists of:

  • the full run-tests suite, including the puppeteer e2e tests, against PostgreSQL
  • The automated python security test, https://github.com/saltcorn/saltcorn/tree/master/infosec-scan/py-sectest
  • The saltcorn-data and server package test against SQLite