A web server for Danish orienteering event organisers to use for hosting live division match results. Competitions and their results can be created and managed with the help of the companion program, division-result-bridge.
- Git
- Node.js (tested with version 22.11; newer should work too)
- A PostgreSQL database server (tested with version 17.5; newer should work too; other SQL databases may work as well)
Clone the repository:
git clone https://github.com/Thomilist/division-result-server.git
Enter the repository directory:
cd division-result-server
Install dependencies:
npm install
Ensure that the PostgreSQL database server is set up, and that a "user" (or role) with CREATEDB, LOGIN and PASSWORD is configured.
For instance, to create the user john with the password 1234, enter the PostgreSQL console:
psql -U postgres
From there, create the user (don't forget the semicolon):
CREATE ROLE john WITH CREATEDB LOGIN PASSWORD '1234';
And exit the PostgreSQL console:
\q
Create .env file at the repository root, and define the database connection string with the DATABASE_URL variable inside it as follows:
echo DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE" > .env
For instance, with the username john, the password 1234, a PostgreSQL server hosted on localhost on port 5432, and a database named live_division_results, the contents of the .env file should be the following:
DATABASE_URL="postgresql://john:1234@localhost:5432/live_division_results"
Generate Prisma client:
npx prisma generate
Create database tables if missing, and apply database migrations:
npx prisma migrate deploy
Build the project:
npm run build
Run the web server:
node build/index.js
The server should now be available at http://localhost:3000.
The project has only been tested with PostgreSQL, but Prisma supports a variety of databases. However, not every database supports all required features (at least when used with Prisma). Check the features of your preferred database (see Prisma's database feature overview, for instance), especially regarding:
- The
UNIQUEconstraint - Arrays
- Enums
- Timestamps
To use a different database, change the database provider defined in the file prisma/schema.prisma — look for the db block:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}Additionally, update the connection string defined with the DATABASE_URL variable in .env according to the format and configuration of your preferred database.
Finally — and just like with PostgreSQL — generate the Prisma client and initialise the database, then build and run the server:
npx prisma generate
npx prisma migrate deploy
npm run build
node build/index.js