nodemon.json


Overview

The `nodemon.json` file is a configuration file for **Nodemon**, a utility that monitors changes in source files and automatically restarts the Node.js application during development. This file specifies which files and directories Nodemon should watch or ignore, which file extensions trigger a restart, and the command to execute when changes are detected.

In this project, `nodemon.json` is used to streamline the development workflow by automatically rebuilding the TypeScript project and restarting the Node.js server whenever relevant source files or build artifacts change. This eliminates the need for manual restarts and helps maintain an efficient development cycle.


File Content and Explanation

{
  "ignore": ["src/routes.ts"],
  "watch": [
    "../../../packages/*/dist/tsconfig.tsbuildinfo",
    "../../common/api/dist/tsconfig.tsbuildinfo",
    "src"
  ],
  "ext": "ts",
  "exec": "yarn build && node dist/gnosis/api/src/app.js"
}

Properties

Property

Type

Description

`ignore`

array of strings

Specifies files or directories Nodemon should **ignore** and not watch for changes. Here, `src/routes.ts` is excluded from triggering a restart.

`watch`

array of strings

Specifies files or directories Nodemon should **watch** for changes. Changes in these paths will trigger the `exec` command. Includes:
- Build info files (`tsconfig.tsbuildinfo`) from various packages to track incremental TypeScript build updates.
- The `src` directory, where the main project source code resides.

`ext`

string

File extensions Nodemon should monitor. Here, set to `"ts"` to watch only TypeScript files.

`exec`

string

The shell command Nodemon runs when a watched file changes. Here, it first runs `yarn build` to compile the project, then starts the Node.js server by running the compiled JavaScript file located at `dist/gnosis/api/src/app.js`.


Usage Example

When a developer modifies any TypeScript files inside the `src` folder or when the build info files change (indicating a change in compiled output), Nodemon will:

  1. Detect the change (except if it's src/routes.ts, which is ignored).

  2. Run yarn build to recompile the TypeScript code.

  3. Execute the compiled server with node dist/gnosis/api/src/app.js.

  4. Automatically restart the server if it was running.

This ensures that developers always run the latest build without manual intervention.


Implementation Details & Notes


Interaction with the System


Mermaid Diagram: Workflow of nodemon.json Configuration

The diagram below illustrates the workflow triggered by Nodemon based on the configuration in `nodemon.json`.

flowchart TD
    A[File Change Detected] --> B{Is file ignored?}
    B -- Yes --> C[No action]
    B -- No --> D{Is file watched?}
    D -- Yes --> E[Run "yarn build"]
    E --> F{Build successful?}
    F -- Yes --> G[Run "node dist/gnosis/api/src/app.js"]
    F -- No --> H[Log build errors, do not restart]
    D -- No --> C

Summary

The `nodemon.json` file is a concise but critical configuration that automates the development cycle by watching TypeScript source files and build metadata across a monorepo-style project. It ensures the application rebuilds and restarts seamlessly on relevant changes, thus supporting rapid development and testing of the Node.js backend service.


If you need further elaboration or integration details with other files, please provide additional context or related files.