This server is intended to be used alongside the RPG Viewer Client
Docker and Docker Compose are the only prerequisites. Start the server and its MongoDB database with:
docker compose upThe server is available on port 4000. MongoDB data is kept in the named
mongo-data volume, so it survives container recreation. To run in the
background, use docker compose up -d.
You can change the published server port or maximum Socket.IO message size with environment variables:
PORT=5000 MAX_BUFFER=100000000 docker compose upTo stop the services, press Ctrl+C or run docker compose down. Add -v only
when you also intend to permanently delete the database volume.
Follow these steps to set up the RPG Viewer Server:
- MongoDB Setup
- Option 1: Install MongoDB locally and create a new database.
- Option 2: Use an existing MongoDB instance (local or cloud, e.g., MongoDB Atlas).
- Configure Environment Variables
- Copy the
.env.examplefile to.envin the project root. - Update the values in
.envas needed:DATABASE_URL: your MongoDB connection string.PORT: the port number for the server (e.g.,3000).MAX_BUFFER: the maximum Socket.IO message size in bytes.
- Install Dependencies
npm install- Start the Server
npm startThe server should now be running and connected to your MongoDB database.
Make sure to note the server's public IP address and the port number you configured. You will need these details when setting up the frontend application to connect to the server.
If you are running the server on your local machine and want to access it from other devices or over the internet, you may need to set up port forwarding on your router:
- Log in to your router's admin panel.
- Locate the port forwarding section.
- Forward the port you configured for the server (e.g.,
3000) to your local machine's IP address. - Save the changes and restart your router if necessary.
Note: Exposing your server to the internet can have security implications. Ensure you understand the risks and consider using a firewall or VPN for additional protection.
You can manage your MongoDB data using either a graphical interface or command-line tools:
-
MongoDB Compass (GUI):
MongoDB Compass is an official GUI for MongoDB. It allows you to visually explore your data, run queries, and manage collections and documents without writing code. -
Mongo Shell (CLI):
The MongoDB Shell is an interactive JavaScript interface to MongoDB. You can use it to connect to your database, run queries, and perform administrative tasks from the command line.
For more information, refer to the official documentation for MongoDB Compass and the MongoDB Shell.