A Vue 3 SPA that communicates with a Node.js Express JSON API, containerized with Docker.
/spa- Vue 3 SPA using Vite, Vue Router, and Vuex/src- Source code for the SPA/assets- Static assets/components- Vue components/lib- Utility functions/router- Vue Router configuration/store- Vuex store/views- Vue views (pages)
/public- Public static files/dist- Built SPA (generated)Dockerfile- Docker configuration for the web servicenginx.conf- Nginx configuration
/api- Node.js Express API/lib- API utility functions and classesserver.js- Main Express applicationDockerfile- Docker configuration for the API service
docker-compose.yml- Docker Compose configuration for the entire application
GET /cs- Get all serversGET /cs/:serverId- Get status of a specific serverGET /cs/:serverId/maps- Get available maps for a specific serverPOST /cs/:serverId/game/restart- Restart the game on a specific serverPOST /cs/:serverId/game/pause- Pause the game on a specific serverPOST /cs/:serverId/game/unpause- Unpause the game on a specific serverPOST /cs/:serverId/game/map- Change the map on a specific serverPOST /cs/:serverId/game/teams- Update team names on a specific server
- Node.js (v14 or later)
- npm or yarn
- Docker and Docker Compose
cd spa
npm install
npm run devThe Vite dev server will proxy any /api requests to the Node.js app on port 3000.
cd api
npm install
npm run devThe API will run on 127.0.0.1:3000.
The API requires a CONNECTIONS_JSON environment variable to be set in the /api/.env file. This variable defines the Counter-Strike servers that will be managed by the control panel.
The value must be a JSON array of server connection objects with the following schema:
[
{
"host": "10.0.0.51",
"port": 27015,
"password": "secret"
}
]Each object in the array requires:
host(string): The hostname or IP address of the CS serverport(number): The RCON port number for the RCON connectionpassword(string): The RCON password for authentication
You can add multiple server objects to the array as needed.
Example:
CONNECTIONS_JSON='[{"host":"10.0.0.51","port":27015,"password":"secret"},{"host":"10.0.0.52","port":27016,"password":"secret"}]'
The server ID is automatically assigned based on the array index (starting from 0).
To build and run the entire application with Docker:
docker-compose up -d --buildThis will:
- Build the Node.js API container with PM2 as the process manager
- Build the Vue SPA and serve it through Nginx
- Configure Nginx as a reverse proxy for the API
The application will be available at:
- SPA: http://localhost
- API: http://localhost/api
- The Node.js app runs in a Docker container using PM2 as the process manager
- Nginx serves the static assets and the built SPA
- Nginx also acts as a reverse proxy, forwarding requests to
/apito the Node.js app