825fd80d6ef5583ed8012e3f37174ac44b94c23f
docxtemplater-server
A lightweight HTTP service for processing DOCX templates with JSON data.
What It Does
This service accepts a DOCX template file and JSON data via HTTP POST, processes the template using docxtemplater, and returns the generated document.
API
POST /process-template
Process a DOCX template with provided data.
Request Format:
- Content-Type:
multipart/form-data - Fields:
template(file): The DOCX template filedata(text): JSON string containing template variables
Example using cURL:
curl -X POST http://localhost:3000/process-template \
-F "template=@template.docx" \
-F 'data={"name":"John Doe","date":"2026-03-21"}'
Response:
- Content-Type:
application/vnd.openxmlformats-officedocument.wordprocessingml.document - Body: Generated DOCX file (binary)
Error Responses:
400 Bad Request: Missing template or data500 Internal Server Error: Processing error
Running Locally
With Docker Compose (recommended)
docker-compose up
The service will be available at http://localhost:3000.
With Node.js
npm install
npm start
Environment Variables
PORT— Server port (default:3000)
Template Syntax
Templates use docxtemplater syntax with curly braces:
Hello {name}, today is {date}.
Supports:
- Simple variables:
{variable} - Loops:
{#items}{name}{/items} - Conditionals:
{#isActive}Active{/isActive}
See docxtemplater documentation for full syntax.
Development
Build Docker image:
docker build -t docxtemplater-server .
Run tests: (No tests currently configured)
License
(License not specified)
Description
Languages
JavaScript
92.4%
Dockerfile
7.6%