Skip to content

Latest commit

 

History

History
132 lines (88 loc) · 3.55 KB

README.md

File metadata and controls

132 lines (88 loc) · 3.55 KB

Rock Paper Scissors

"Life is more fun if you play games." — Roald Dahl

build publish license

Requirements

Usage

Initial setup

Install and configure the application:

# Clone the repository.
git clone https://github.com/MediaComem/rps.git

# Install dependencies.
cd rps
npm ci

# Create a PostgreSQL user named "rps".
sudo -u postgres createuser --pwprompt rps

# Create an empty PostgreSQL database named "rps" and owned by the "rps" user.
sudo -u postgres createdb --owner rps rps

# Create the "uuid-ossp" PostgreSQL extension in the "rps" database.
sudo -u postgres psql -d rps -c 'CREATE EXTENSION "uuid-ossp"'

# Create a .env file and edit it to adapt the PostgreSQL connection URL
# according to the user and database you just created.
cp .env.sample .env

If you are in a memory-constrained environment such as a small cloud server, install the pre-compiled version of the application which will be downloaded from GitHub:

npm run build:precompiled

Otherwise, you can perform a full build, which requires copious amounts of CPU and RAM:

npm run build

Once the build is done, migrate the database to the latest version:

npm run migrate

Updating

To take all changes into account after updating the code to the latest version, execute the following commands in the application's directory:

# Update dependencies (install new ones and upgrade existing ones).
npm install

# Install the pre-compiled build or build the application again (one or the
# other depending on your server's capabilities).
npm run build:precompiled
npm run build

# Migrate the database to the latest version.
npm run migrate

Local development

WARNING: do NOT do this in memory-constrained environments such as a small cloud server. This is intended for development on your local machine.

# Run the application in development mode with live code reload.
npm run dev

Production deployment

# Run the application in production mode.
npm start

Configuration

The following environment variables can be set to customize the application's behavior:

Variable Default value Description
RPS_DATABASE_DEBUG false When true, database queries are logged.
RPS_DATABASE_URL postgresql://rps@localhost/rps PostgreSQL connection URL.
RPS_PORT or PORT 3000 The port on which the application will listen to.