Skip to main content
This example demonstrates server-side usage of the Quran Search Engine library in a Node.js environment with a command-line interface.

Features

  • Server-side Quran search
  • Command-line interface
  • Example searches for common Arabic words
  • Search statistics and result display
  • Custom search via command-line arguments
  • Programmatic API usage

Setup

1

Install dependencies

2

Run the example

From the workspace root:
Or from the example directory:
3

Try custom searches

Provide a search term as an argument:

Project structure

This example uses JavaScript (not TypeScript) to demonstrate that the library works in standard Node.js environments with ESM.

Main implementation

The complete implementation in a single file:
index.js

Loading data

Load all datasets in parallel for optimal performance:
index.js
Loading data in parallel using Promise.all() is faster than loading sequentially.

Example searches

Run predefined example searches:
index.js

Displaying results

Format and display search results:
index.js

Custom search via arguments

Accept search terms from command-line arguments:
index.js

Error handling

Handle errors and unhandled rejections:
index.js

Example output

When you run the script, you’ll see output like this:

Dependencies

Minimal dependencies for Node.js usage:
package.json
The "type": "module" field enables ES modules in Node.js, allowing you to use import statements.

Development mode

Run in watch mode for development:
This uses Node.js’s built-in --watch flag to automatically restart when files change.

Key features demonstrated

  • Server-side usage: Running the library in Node.js without a browser
  • ESM support: Using modern JavaScript modules
  • CLI integration: Processing command-line arguments
  • Batch processing: Running multiple searches programmatically
  • Statistics: Displaying match counts and scores
  • Error handling: Proper error management in async code
  • Simple API: Clean, straightforward implementation

Use cases

  • API backends: Building REST APIs for Quran search
  • Data processing: Batch analysis of Quranic text
  • CLI tools: Command-line utilities for scholars
  • Testing: Automated testing of search functionality
  • Scripts: One-off analysis or data extraction tasks