chore: clean up repo, add README and .gitignore

This commit is contained in:
2026-03-21 23:11:46 +00:00
parent bbd847a81b
commit 9f5d322b00
5 changed files with 107 additions and 30 deletions

82
README.md Normal file
View File

@@ -0,0 +1,82 @@
# 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](https://docxtemplater.com/), 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 file
- `data` (text): JSON string containing template variables
**Example using cURL:**
```bash
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 data
- `500 Internal Server Error`: Processing error
## Running Locally
### With Docker Compose (recommended)
```bash
docker-compose up
```
The service will be available at `http://localhost:3000`.
### With Node.js
```bash
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](https://docxtemplater.com/docs/tag-types/) for full syntax.
## Development
**Build Docker image:**
```bash
docker build -t docxtemplater-server .
```
**Run tests:**
_(No tests currently configured)_
## License
_(License not specified)_