Skip to content

Server for the toverux/HallOfFame Cities: Skylines II mod

License

Notifications You must be signed in to change notification settings

toverux/HallOfFameServer

Repository files navigation

Hall of Fame logoHall of Fame Server

Discord Paradox Mods Crowdin

Server part of the Hall of Fame mod for Cities: Skylines II.

This is a Nest.js project with an Angular w/SSR frontend and Prisma as a MongoDB ORM.

Featuring a simple REST-like HTTP API for uploading photos from the mod and retrieving them.

Features & Roadmap

Find our user feedback, feature request and roadmap board here: feedback.halloffame.cs2.mtq.io.

Development

Installation

  1. Install Bun.
  2. (Recommended) Install Volta for per-project Node.js version management, or use Node >= 22. Node is still needed to run the bundlers, while Bun is used for package management and the server runtime.
  3. Run bun i to install dependencies.
  4. You may bun run build to test that the project builds and everything is in order.
  5. Install MongoDB (more direct download links here), mongosh, and set up a replica set, here's an example, but it varies according to your setup and preferences:
  6. Set this in your configuration file (Linux: /etc/mongod.conf, Windows: C:\Program Files\MongoDB\Server\7.0\bin\mongod.cfg):
    replication:
      replSetName: rs0
  7. Restart MongoDB (sudo systemctl restart mongod, Windows: open "Services", search for "MongoDB Server", right-click it and choose Restart).
  8. Connecting to the database using mongosh, run rs.initiate() to create a default rs0 replica set, check there's no error.
  9. Run bun prisma db push to create the database, collections and indexes.
  10. Done! Test that the server is working with bun run:server:watch.

To set up a replica set, you can also follow this guide.

Development Workflow

TBD

Generating Database Schema

Database schema is generated from the Prisma schema file in prisma/schema.prisma.

You might have to reconfigure the default development connection string if it differs from the default in .env. If it does differ, as .env is a defaults files that is versioned, do not change it, instead override locally in .env.local.

  • Update database schema from Prisma schema: bun prisma db push.
    As the database is MongoDB which is schema-less, this essentially just creates the collections (and the database if it does not exist), and indexes.
  • Update Prisma Client definitions after schema change: bun prisma generate.
    Note that this is also done by bun prisma db push.

Dump & Restore Database

Example for production to local database:

mongodump --uri "mongodb://user:pass@server:port/halloffame?replicaSet=rs0&directConnection=true" --gzip --archive=halloffame.mongoarchive

mongorestore --uri "mongodb://localhost/halloffame?replicaSet=rs0" --gzip --archive=halloffame.mongoarchive --nsInclude='default.*' --nsFrom='default.*' --nsTo='halloffame.*' --drop

bun prisma db push

Updating Dependencies & Toolchain

  • To update Bun: bun upgrade, and update package.json#packageManager.
  • To update Node: volta install node@latest, and update package.json#engines.node.
  • To update npm dependencies: bun pm:update.

Code Style

TypeScript

TypeScript code is formatted and linted by Biome. Run bun run check to check for linting errors, format files and autofix simple issues.

You can also use Biome directly with bun biome.

The formatter and linter should run as a pre-commit hook if you have it installed, which should be done automatically when running bun i (otherwise, run bun lefthook install).

I'd suggest to use a Biome plugin for your editor to ease development.

If a rule seems out of place for this project, you can either disable/reconfigure it in the biome.json file or disable it with an annotation comment, but these should be justified and concerted.

Commit messages

Commits must follow the Conventional Commits specification and more specifically the Angular one.

Scope can be one or more of the following:

  • server: for non-specific changes in the server;
  • cli: for changes in the CLI application;
  • admin: for changes in the backoffice admin interface;
  • api: for changes in the server HTTP API;
  • imgproc: for changes in image processing;
  • database: for changes in the database schema or related systems;
  • i18n: for changes in translations and translations system;
  • deps: for changes in dependencies (updates, additions, removals);
  • Propose new scopes if needed!

About

Server for the toverux/HallOfFame Cities: Skylines II mod

Topics

Resources

License

Stars

Watchers

Forks

Languages