Files
TriggerFrontend/README.md
2025-10-13 20:23:50 -05:00

120 lines
2.7 KiB
Markdown

---
gitea: none
include_toc: true
---
# Trigger Home Page
A homepage replacement for your browser built on React and SQL.
## Prerequisite Setup
* Install MariaDB/MySQL
* Install Git
* Install Node 20+
Navigate to the TriggerFrontend and TriggerBackend folders and run:
* npm install
* If you encounter errors installing, try adding --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. An basic NGINX example file can be found in the root.
## MariaDB/MySQL setup
Connect to your server:
```shell
sudo mariadb
```
Create the database and new administration user:
```sql
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:
```shell
sudo mariadb -u triggeradmin -p trigger_database < defaultDatabase.sql
```
## Configuration
Clone both the [TriggerFrontend](https://sean.bet/gitea/smedmunds/TriggerFrontend) and [TriggerBackend](https://sean.bet/gitea/smedmunds/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:
```shell
cp TriggerFrontend/.env.example TriggerFrontend/.env
cp TriggerBackend/.env.example TriggerBackend/.env
```
⚠️ Update the following fields to match your environment's URLs and credentials. The Domains and Base URL here must be defined without leading or trailing '/'! ⚠️
Frontend .env.example
```shell
VITE_DOMAIN_DEV='http://localhost:5000'
VITE_DOMAIN_PROD='https://domain.local'
VITE_BASE_URL='trigger'
```
Backend .env.example
```shell
DB_HOST='127.0.0.1'
DB_USER='triggeradmin'
DB_PASS='trigger'
DB_PORT='3306'
API_PORT='5000'
```
## Run/build
To run the application without building:
```shell
npm run dev
```
To build the application for production:
```shell
npm run build
```
Run with pm2:
```shell
sudo npm install -g pm2
cd TriggerFrontend/
sudo pm2 serve ./dist --no-daemon --spa --port 3000
cd ..
cd TriggerBackend/
sudo pm2 start server.cjs
```
### TODO
- Mobile improvements
- Case insensitive sort (images, but check all)
- Debounce all inputs
- Update to use forms