Node.js REST service for the BadgeHub
Make sure Docker is installed and running and Node.js and npm are installed.
In the project directory, type
npm install
This will install node_modules
.
Before running, copy the .env.example
into .env
cp .env.example .env
and fill out the details.
Then start the Docker containers by typing
docker compose up --detach
The first time Node.js might not start.
docker logs badgehub-api-node-1
If the logs say something like
node:internal/modules/run_main:115
triggerUncaughtException(
^
Error [TransformError]:
Then node_modules have to be install from inside the container. type:
docker exec -it badgehub-api-node-1 npm install
and restart the service:
docker compose restart
Then visit http://localhost:8001/ for the development BadgeHub homepage.
Visit http://localhost:8002/ for the pgAdmin interface.
Use password badgehub
to connect to the BadgeHub database server.
Use the OpenAPI (Swagger) documentation to interact with the REST API.
After setting up the development container, you can start it with
docker compose up --detach
And to stop BadgeHub
docker compose down
Or, to stop BadgeHub and delete all volumes (to start fresh)
docker compose down --volumes
At the moment, this is the database schema:
In production, use the production docker compose file docker-compose-production.yml
.
The NODE_ENV
environment file is set to production
, there's no watcher and
PM2 is used to run Node.js multithreaded.
The first time, a Docker container is created. Make sure the dist
directory
contains the latest build to be copied to the container.
Also the public
directory and package.json
and package-lock.json
will
be copied.
To start:
docker compose --file docker-compose-production.yml up --detach
Then visit http://localhost:9001/ for the production BadgeHub homepage and http://localhost:9002/ for PG_Admin, the UI for the database.
To wind down:
docker compose --file docker-compose-production.yml down