# SPMHome App Servers

[![project id](https://img.shields.io/badge/project%20id-36-blue.svg)](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server) [![org](https://img.shields.io/badge/org-spmhome-blue.svg)](https://www.spmhome.io) [![project type](https://img.shields.io/badge/category-www-blue.svg)](https://en.wikipedia.org/wiki/Category) [![project lang](https://img.shields.io/badge/language-javascript-blue.svg)](https://en.wikipedia.org/wiki/Programming_language)

[![vcs](https://img.shields.io/badge/vcs-gitlab-blue.svg)](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server) [![gitlab-common](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-gitlab--common-00aa00.svg)](https://gitlab.spmhome.io/spmhome/ci/gitlab-common) [![app-publisher](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-app--publisher-e10000.svg)](https://gitlab.spmhome.io/spmhome/ci/app-publisher) [![authors](https://img.shields.io/badge/authors-scott%20meesseman-6F02B5.svg?logo=visual%20studio%20code)](https://en.wikipedia.org/wiki/Author) [![active authors](https://img.shields.io/badge/active%20authors-TODO-blue.svg)](https://en.wikipedia.org/wiki/Author)

[![latest release](https://img.shields.io/badge/latest%20release-v2.0.0-blue.svg)](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/releases) [![previous release](https://img.shields.io/badge/previous%20release-v1.2.16-blue.svg)](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/releases) [![prod pipeline status](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/badges/main/pipeline.svg?ignore_skipped=true)](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/pipelines) [![coverage report](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/badges/main/coverage.svg)](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/releases)

<!--
![coverage.prepare](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=prepare)
![coverage.prebuild](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=prebuild)
![coverage.build](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=build)
![coverage.test](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=test)
![coverage.rebuild](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=rebuild)
![coverage.build-installer](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=build-installer)

![coverage.deploy](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=deploy)
![coverage.commit](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=commit)
![coverage.publish-installer](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=publish-installer)
![coverage.publish-release](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=publish-release)
![coverage.cleanup](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=cleanup)
![coverage.notify](https://gitlab.spmhome.io/spmhome/www/spmhome.io.server/-/badges/main/coverage.svg?job=notify)
-->

## Description

- [SPMHome App Servers](#spmhome-app-servers)
  - [Description](#description)
  - [Requirements](#requirements)
  - [API Service](#api-service)
  - [Gitlab](#gitlab)
    - [Installation](#installation)
    - [Maintenance](#maintenance)
    - [References](#references)
  - [SYS Files](#sys-files)
    - [The `environment` file](#the-environment-file)
    - [The `app.config` file](#the-appconfig-file)

## Requirements

- NodeJs ^22.17.1 || ^24.4.0

## API Service

Install:

    npm install -g @spmhome/spmhome.io.server

## Gitlab

### Installation

sudo apt update && sudo apt install gitlab-ce

### Maintenance

Install:

Install specific version:

    sudo apt install gitlab-ce=<version>-ce.0
e.g.:
    sudo apt-get install gitlab-ce=16.11.10-ce.0

Restart Gitlab server:

    sudo gitlab-ctl restart

### References

- [Upgrading Gitlab](https://docs.gitlab.com/ee/update)
- [Gitlab Updates](https://archives.docs.gitlab.com/16.9/ee/update/index.html)
- [Upgrade Path Tool](https://gitlab-com.gitlab.io/support/toolbox/upgrade-path)

## SYS Files

Project configuration files and server-side setup files and scripts are located in the /sys folder, similar to the following directory structure:

    /sys
        app.config.*.json
        README.txt
        /bin
            install-ubuntu.sh
            restart-on-event.sh
        /etc
            /apache2
                /sites-available
                    api.spmhome.io.conf
                    api.spmhome.io-http.conf
            /cron.daily
                spmh-backup.sh
            /iis
                web.config
                web.dev.config
            /spmh-api-server
                environment
        /usr
            /lib
                /systemd
                    /system
                        spmh-api.service
        /vendor
            /oauth2
                client_....apps.googleusercontent.com.json
            /stripe
                *.keys.json

### The `environment` file

Contains all application secret and private property/value pairs, read by systemd on server startup and applied to the runtime environment.
*This file is not checked in to the VCS*
Backups kept at //{BACKUP_SHARE}/backup/{ENV|SERVER}/spmh-apisvc/sys/etc/spmh-api-server

### The `app.config` file

Config file used by the application for both generic settings and sake of organization of the environment keys, populated into the config object at runtime within a closure set up on the config module's import.
Three template files exist in the /sys directory that are set up to read the appropriate environment variables and their values based on runtime environment.  The runtime environment is one of three enumerated values, `dev`, `prod`, and `sb`, and correlate to the template file names:

1. app.config.dev.json
2. app.config.prod.json
3. app.config.sb.json

Backups of the 'dev', 'prod', and 'sb' app.config template files are kept at //{BACKUP_SHARE}/backup/{ENV|SERVER}/spmh-apisvc/sys
