This guide will take you from zero to generating your first employment contract in under 10 minutes.
1
Prerequisites Check
Before starting, ensure you have the following installed:
Node.js: Version 18.0.0 or higher
npm: Version 8.0.0 or higher (comes with Node.js)
Git: For cloning the repository
Verify your installations:
node --version # Should show v18.0.0 or highernpm --version # Should show 8.0.0 or higher
2
Clone and Install
Clone the repository and install dependencies:
# Clone the repositorygit clone <your-repository-url>cd kontrak-backend# Install dependenciesnpm install
This will install all required packages including Express, TypeScript, Puppeteer, and Zod.
3
Environment Setup
Create a .env file in the project root with the following configuration:
.env
# Server ConfigurationNODE_ENV=developmentPORT=3000HOST=localhost# CORS - Allowed origins (comma-separated)CORS_ORIGINS=http://localhost:3000,http://localhost:5173# File LimitsMAX_FILE_SIZE=10485760 # 10MBMAX_EMPLOYEES=1000# Temporary directory for file processingTEMP_DIR=./temp
You can copy the example file: cp .env.example .env
4
Start the Development Server
Start the server in development mode:
npm run dev
You should see output similar to:
[INFO] Creando aplicacion Express...[INFO] Inicializando servidor...[INFO] =========== Server running on port 3000 ==========[INFO] =========== Environment: development ==========
The server uses nodemon and ts-node in development mode, which automatically restarts on file changes.
5
Verify Installation
Test that the API is running by hitting the health check endpoint:
curl http://localhost:3000/
Expected response:
{ "success": true, "message": "Kontrak API - Sistema de Generación de Contratos", "version": "1.0.0", "status": "running", "timestamp": "2026-03-05T10:30:00.000Z", "endpoints": { "uploadExcel": "POST /api/contracts/upload", "health": "GET /api/health" }}
6
Generate Your First Contract
Now let’s generate a sample employment contract. Create a file called test-employee.json:
The batch endpoint limits processing to 50 employees at a time for performance reasons.Split your data into smaller batches:
// Process in chunks of 50const chunkSize = 50;for (let i = 0; i < employees.length; i += chunkSize) { const chunk = employees.slice(i, i + chunkSize); // Process chunk...}