Prerequisites
Before you begin, make sure you have the following ready:- Node.js 22+ — the backend uses
--env-file(native.envloading) and ES modules, both of which require Node.js 22 - PostgreSQL — a local instance or a managed service (the project was tested on Azure Database for PostgreSQL)
- A Factus API account — sign up at factus.com.co and obtain your
client_id,client_secret,email, andpasswordfor the sandbox (api-sandbox.factus.com.co) or production environment
Steps
1
Clone the repository
Clone the project from GitHub and move into the root directory:The repository contains two top-level directories:
bc-v1/— the Node.js/Express backendfr-v1/— the static HTML/JS frontend
2
Install backend dependencies
Navigate into the backend directory and install all npm packages:This installs the five runtime dependencies declared in
package.json:3
Create the .env file
Create a Variable reference:
.env file inside bc-v1/. The server loads it automatically via Node’s --env-file flag when you run npm run dev.4
Start the backend server
From inside This executes
bc-v1/, run:node --env-file .env --watch ./src/main.js. On startup, the server:- Fetches an OAuth 2.0 token immediately by calling
POST /oauth/tokenon the Factus API, storing the resultingaccess_tokenandrefresh_tokeninprocess.env - Starts Express on port
4500(or the value ofPORT) - Schedules a token refresh every 55 minutes (3,300,000 ms) via
setInterval
The server auto-refreshes the OAuth access token every 55 minutes in the background. You do not need to restart the process to keep the token valid — this is handled entirely by
bc-v1/src/auth/token.js.5
Configure the frontend
The frontend reads its backend URL from a single JSON file. Open If your backend is deployed remotely (e.g., on Koyeb), replace
fr-v1/resources/assets/config.json and verify (or update) the url field to point at your running backend:http://localhost:4500 with your deployment URL:6
Open the frontend in a browser
The frontend is fully static — no build step required. Simply open the entry point in your browser:The page loads Bootstrap 5.3.3 (Vapor dark theme) and Tabulator 6.3 from self-hosted files in
fr-v1/resources/utils/ and immediately starts making requests to the backend URL defined in config.json.Verify the Backend Is Working
Once the server is running, confirm it can reach the Factus API by listing invoices. Send aGET request to the /factura endpoint:
data array contains invoices returned by the Factus API):
500 or a token-related error, double-check that url_api, client_id, client_secret, email, and password are all set correctly in your .env file.
