This repo contains the backend and middleware implementations of Wrath Of The Jungle: Tower Defense.
Before building the backend or the middleware, make sure you have paima-engine
cloned to the same root folder as this repository.
git clone [email protected]:PaimaStudios/paima-engine.git
git clone [email protected]:PaimaStudios/tower-defense-backend.git
Secondly, make sure to create your own .env.development
config file. Most of the commands use that as a fallback, unless explicitly specified otherwise. You can copy the .env.test
as a starting point and adjust any settings as necessary. env
files other than the test one are not committed to the repository.
Various .env
files can be used and are used to configure the various build targets under different circumstances.
Integration testing uses the committed .env.test
files (see the integration testing compose files – new and old).
Middleware and backend both use .env.development
by default (which is purposefully not commited to the repository), but will use the file .env.xxx
for arbitrary xxx
if the NODE_ENV
variable is set to xxx
. To see where this binding happens, see the docker compose file for the backend and the build script for the middleware.
- Enter into the
middleware
folder. - Run
npm run build
. - A
middleware.js
will be the output.
Of note, the final exports
at the end of the output file must be manually commented out/removed before use, in order for the web browsers to accept the middleware.js
and load it properly.
After cloning the two repos to the same root folder, follow these steps to build and run the backend (while automatically deploying a postgres database at the same time) via docker compose:
cp tower-defense-backend/docker/* .
docker compose up
Or you can utilize prepared npm scripts npm run docker
& npm run docker:build
. For more detailed instructions regarding the docker setup, see the docker README.
To run the backend without docker (not recommended), you must manually set up postgres, create the database with all the tables, compile all dependencies (see what gets built in the Dockerfile) and run the compiled index.js
file in the backend package.