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

View File

@@ -1,25 +0,0 @@
name: Trigger GitHub Docker Build
on:
push:
branches:
- main
jobs:
trigger:
runs-on: ubuntu-latest
steps:
- name: Trigger GitHub workflow
run: |
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT_GITHB }}" \
https://api.github.com/repos/al3des/deploy/dispatches \
-d '{
"event_type": "build-docxtemplater",
"client_payload": {
"gitea_repo": "https://gitea.netcups.al3dev.link/al3dev/docxtemplater-server.git",
"image": "gitea.netcups.al3dev.link/al3dev/docxtemplater-server:latest"
}
}'

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
node_modules/
.DS_Store
*.log
.env

View File

@@ -1,7 +1,16 @@
FROM node:16-alpine FROM node:20-alpine
WORKDIR /app WORKDIR /app
# Copy package files first for better layer caching
COPY package*.json ./ COPY package*.json ./
RUN npm install
# Install dependencies
RUN npm ci --only=production
# Copy application code
COPY . . COPY . .
EXPOSE 3000 EXPOSE 3000
CMD ["npm", "start"]
CMD ["node", "server.js"]

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)_

View File

@@ -3,14 +3,21 @@ version: '3.8'
services: services:
docxtemplater-service: docxtemplater-service:
build: . build: .
expose: ports:
- "3000" - "3000:3000"
environment: environment:
- PORT=3000 - PORT=3000
networks: networks:
- default - default
- caddy_default - caddy_default
restart: unless-stopped restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
networks: networks:
default: {} default: {}
caddy_default: caddy_default: