A Node.js application built with TypeScript and Express that provides a REST API for document processing using Apache Tika.
- Extract text from various document formats (PDF, DOCX, XLSX, etc.)
- Extract metadata from documents
- Detect MIME types
- OCR support for images and scanned PDFs
- Dockerized setup with docker-compose
- Node.js 24.11.0 (see .nvmrc)
- npm 11.6.1 or higher
- Docker and Docker Compose (for containerized deployment)
npm installCopy the example environment file:
cp .env.example .envEdit .env if you need to customize:
PORT: API server port (default: 3000)TIKA_URL: Tika server URL (default: http://localhost:9998)NODE_ENV: Environment mode (development/production)
npm run buildThis will compile TypeScript to JavaScript in the dist/ directory.
Start both Tika server and the API:
npm run docker:upView logs:
npm run docker:logsStop services:
npm run docker:downFirst, start Tika server (in a separate terminal):
docker run -p 9998:9998 apache/tika:latest-fullThen start the development server:
npm run devOr build and run in production mode:
npm run build
npm startnpm run build- Compile TypeScript to JavaScriptnpm run start- Run the production buildnpm run dev- Run development server with ts-nodenpm run watch- Watch mode for TypeScript compilationnpm run clean- Remove the dist directorynpm run docker:build- Build Docker imagesnpm run docker:up- Start services with docker-composenpm run docker:down- Stop servicesnpm run docker:logs- View container logs
GET /health
POST /extract-text
Content-Type: multipart/form-data
Body: file (document file)
POST /extract-metadata
Content-Type: multipart/form-data
Body: file (document file)
POST /extract-all
Content-Type: multipart/form-data
Body: file (document file)
POST /detect-type
Content-Type: multipart/form-data
Body: file (document file)
# Upload a document and extract text
curl -X POST http://localhost:3000/extract-text \
-F "file=@/path/to/document.pdf"
# Extract metadata
curl -X POST http://localhost:3000/extract-metadata \
-F "file=@/path/to/document.pdf"
# Extract everything
curl -X POST http://localhost:3000/extract-all \
-F "file=@/path/to/document.pdf"
# Detect file type
curl -X POST http://localhost:3000/detect-type \
-F "file=@/path/to/document.pdf"
# Health check
curl http://localhost:3000/health.
├── src/
│ ├── app.ts # Express application and routes
│ └── services/
│ └── tika.service.ts # Tika API client service
├── dist/ # Compiled JavaScript (generated)
├── uploads/ # Temporary upload directory
├── docker-compose.yml # Docker services configuration
├── Dockerfile # Application container definition
├── tsconfig.json # TypeScript configuration
├── package.json # Project dependencies and scripts
└── .nvmrc # Node.js version specification
Apache Tika supports over 1000 file formats including:
- Documents: PDF, DOCX, DOC, ODT, RTF
- Spreadsheets: XLSX, XLS, ODS, CSV
- Presentations: PPTX, PPT, ODP
- Images: JPG, PNG, GIF, TIFF (with OCR)
- Archives: ZIP, TAR, RAR
- And many more...
The project uses strict TypeScript settings. See tsconfig.json for details.
- Add your TypeScript code in
src/ - Build the project:
npm run build - Test your changes:
npm run dev
npm run docker:build# Build
docker build -t node-tika .
# Run
docker run -p 3000:3000 -e TIKA_URL=http://tika:9998 node-tika- Ensure Tika server is running:
curl http://localhost:9998/tika - Check Docker logs:
npm run docker:logs
- Clean and rebuild:
npm run clean && npm run build - Check Node.js version:
node --version(should be 24.11.0)
- Ensure the
uploads/directory exists and has proper permissions - Check available disk space
ISC