nodemon.json


Overview

The `nodemon.json` file is a configuration file used by **Nodemon**, a utility that monitors changes in source files and automatically restarts the Node.js application during development. This file defines how Nodemon should watch for file changes, which files or directories to ignore, what file extensions to monitor, and the command to execute upon detecting changes.

In this project, `nodemon.json` streamlines the development workflow by automating rebuilds and restarts when TypeScript source files change, ensuring the Node.js server runs the latest compiled code without manual intervention.


Configuration Properties

The file is a JSON object with the following properties:

Property

Type

Description

`ignore`

Array of strings

Specifies files or paths that Nodemon should **ignore** and not watch for changes.

`watch`

Array of strings

Specifies files or paths that Nodemon should monitor for changes. When changes are detected, Nodemon triggers the configured command.

`ext`

String

Defines the file extensions Nodemon should watch. Here, it watches files ending with `.ts` (TypeScript files).

`exec`

String

The shell command Nodemon runs when a watched file changes. In this case, it runs a build script and then starts the Node.js application.


Detailed Explanation

ignore

watch

ext

exec


Usage Example

During development, running `nodemon` with this configuration will:

  1. Monitor all .ts files in the src directory and specific tsconfig.tsbuildinfo files.

  2. Ignore changes in src/routes.ts.

  3. On detecting a change, execute:

    yarn build && node dist/arbitrum/api/src/app.js
    
  4. Automatically restart the Node.js application with the updated build.

This setup allows developers to work on TypeScript source files and see the effects immediately without manual rebuilds or restarts.


Implementation Details and Considerations


Interaction with Other Parts of the System


Visual Diagram

The following Mermaid flowchart illustrates the workflow and relationships within the `nodemon.json` configuration:

flowchart TD
    A[File Changes Detected] -->|.ts files in src/ or tsconfig.tsbuildinfo files| B{Is file ignored?}
    B -- Yes --> C[No action]
    B -- No --> D[Run "yarn build"]
    D --> E{Build successful?}
    E -- Yes --> F[Run "node dist/arbitrum/api/src/app.js"]
    E -- No --> G[Show build errors, no restart]

Summary

The `nodemon.json` file configures Nodemon to efficiently monitor relevant TypeScript source files and build artifacts for changes and to restart the Node.js application automatically after rebuilding. It supports a smooth development experience by integrating with the TypeScript build process and a monorepo package structure, ensuring that the running API server always reflects the latest code changes.


If you need more details on how to extend or customize this configuration or integrate it further into the development workflow, feel free to ask!