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.
Find our user feedback, feature request and roadmap board here: feedback.halloffame.cs2.mtq.io.
- Install Bun.
- (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.
- Run
bun i
to install dependencies. - You may
bun run build
to test that the project builds and everything is in order. - 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:
- Set this in your configuration file (Linux:
/etc/mongod.conf
, Windows:C:\Program Files\MongoDB\Server\7.0\bin\mongod.cfg
):replication: replSetName: rs0
- Restart MongoDB (
sudo systemctl restart mongod
, Windows: open "Services", search for "MongoDB Server", right-click it and choose Restart). - Connecting to the database using
mongosh
, runrs.initiate()
to create a default rs0 replica set, check there's no error. - Run
bun prisma db push
to create the database, collections and indexes. - Done! Test that the server is working with
bun run:server:watch
.
To set up a replica set, you can also follow this guide.
TBD
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 bybun prisma db push
.
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
- To update Bun:
bun upgrade
, and updatepackage.json#packageManager
. - To update Node:
volta install node@latest
, and updatepackage.json#engines.node
. - To update npm dependencies:
bun pm:update
.
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.
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!