Trigger Home Page
A homepage replacement for your browser built on React and SQL.
[TOC]
Prerequisite Setup
-
Install MariaDB/MySQL
-
Install Git
-
Install Node 20+
Navigate to the TriggerFrontend and TriggerBackend folders and run:
- npm install --legacy-peer-deps
WARNING !!!
Trigger does not handle authentication of any kind. It is designed to be used behind a reverse proxy, such as NGINX, or other service that can request authentication prior to serving the page.
MariaDB/MySQL setup
Connect to your server:
sudo mariadb
Create the database and new administration user:
create database trigger_database;
grant all privileges on trigger_database.* TO 'triggeradmin'@'localhost' identified by 'trigger';
flush privileges;
⚠️ Update the above grant line to use a username and password other than the default. ⚠️
Import defaultDatabase.sql into your database server using your preferred management application or run the following via the terminal:
sudo mariadb -u triggeradmin -p trigger_database < defaultDatabase.sql
Configuration
Clone both the TriggerFrontend and TriggerBackend repositories. They do not need to be run from the same folder, or even the same machine.
Trigger uses .env files to configure the connection to the database as well as the base url for the application. Prior to running or building the app, you will need to edit the file at TriggerBackend/.env and TriggerFrontend/.env to match your environment.
Make a copy of the example file:
cp TriggerFrontend/.env.example TriggerFrontend/.env
cp TriggerBackend/.env.example TriggerBackend/.env
⚠️ Update the following fields to match your environment's URLs. The Domains and Base URL here must be defined without a leading '/'! ⚠️
Frontend .env.example
VITE_DOMAIN_DEV='http://localhost:5000'
VITE_DOMAIN_PROD='https://domain.local'
VITE_BASE_URL='trigger'
Backend .env.example
DB_HOST='127.0.0.1'
DB_USER='triggeradmin'
DB_PASS='trigger'
Run/build
To run the application without building:
npm run dev
To build the application for production:
⚠️ Add any background images to public/backgrounds to include them in the build ⚠️
npm run build
Run with pm2:
sudo npm install -g pm2
sudo pm2 serve ./dist --no-daemon --spa --port 3000
sudo pm2 start server.cjs
TODO
- Image uploads for backgrounds?