### Install serve-static Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/serve-static/README.md Install the serve-static module using npm. ```sh $ npm install serve-static ``` -------------------------------- ### Run Node.js App with Arguments Source: https://github.com/remy/nodemon/blob/main/README.md Example of starting a Node.js server script with nodemon, passing host and port arguments. ```bash nodemon ./server.js localhost 8080 ``` -------------------------------- ### Install ee-first Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/on-finished/node_modules/ee-first/README.md Install the ee-first module using npm. ```sh $ npm install ee-first ``` -------------------------------- ### Install content-disposition Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/content-disposition/README.md Install the module using npm. ```sh npm install content-disposition ``` -------------------------------- ### Install on-finished Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/on-finished/README.md Install the on-finished module using npm. ```sh npm install on-finished ``` -------------------------------- ### Run Express Example Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/Readme.md Executes a specific example from the Express.js repository. ```bash $ node examples/content-negotiation ``` -------------------------------- ### Install proxy-addr Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/proxy-addr/README.md Install the proxy-addr module using npm. ```sh npm install proxy-addr ``` -------------------------------- ### Install Express.js Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/Readme.md Installs the Express.js framework using npm. ```bash $ npm install express ``` -------------------------------- ### Install type-is Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/type-is/README.md Install the type-is package using npm. ```sh $ npm install type-is ``` -------------------------------- ### Install Negotiator Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/accepts/node_modules/negotiator/README.md Install the Negotiator module using npm. ```sh npm install negotiator ``` -------------------------------- ### Start Express Application Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/Readme.md Starts the Express.js application server using npm. ```bash $ npm start ``` -------------------------------- ### Install utils-merge Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/utils-merge/README.md Install the utils-merge package using npm. ```bash $ npm install utils-merge ``` -------------------------------- ### Install media-typer Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/media-typer/README.md Install the media-typer package using npm. ```sh npm install media-typer ``` -------------------------------- ### Install parseurl Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/parseurl/README.md Install the parseurl package using npm. ```bash npm install parseurl ``` -------------------------------- ### Send File for Download Example Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/content-disposition/README.md Example demonstrating how to set the 'Content-Type' and 'Content-Disposition' headers and stream a file for download using Node.js http module. ```javascript var contentDisposition = require('content-disposition') var destroy = require('destroy') var http = require('http') var onFinished = require('on-finished') var filePath = '/path/to/public/plans.pdf' http.createServer(function onRequest(req, res) { // set headers res.setHeader('Content-Type', 'application/pdf') res.setHeader('Content-Disposition', contentDisposition(filePath)) // send file var stream = fs.createReadStream(filePath) stream.pipe(res) onFinished(res, function (err) { destroy(stream) }) }) ``` -------------------------------- ### Install range-parser Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/range-parser/README.md Install the range-parser package using npm. ```bash npm install range-parser ``` -------------------------------- ### Install send Module Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/send/Readme.md Install the send module using npm. ```bash $ npm install send ``` -------------------------------- ### Install forwarded Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/README.md Install the forwarded module using npm. ```sh npm install forwarded ``` -------------------------------- ### Install depd Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/depd/Readme.md Install the depd module using npm. ```sh npm install depd ``` -------------------------------- ### Basic Express.js Server Setup Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/Readme.md Sets up a basic Express.js server that listens on port 3000 and responds with 'Hello World' to requests on the root path. ```javascript var express = require('express') var app = express() app.get('/', function (req, res) { res.send('Hello World') }) app.listen(3000) ``` -------------------------------- ### Install etag Module Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/etag/README.md Install the etag module using npm. ```sh npm install etag ``` -------------------------------- ### Install Nodemon with Permissions Source: https://github.com/remy/nodemon/blob/main/faq.md When encountering permission errors during installation, try re-installing with sudo and the --unsafe-perm flag. ```bash sudo npm install -g nodemon --unsafe-perm ``` -------------------------------- ### Clone Express Repository and Install Dependencies Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/Readme.md Clones the Express.js repository and installs its dependencies for local development or example execution. ```bash $ git clone git://github.com/strongloop/express.git --depth 1 $ cd express $ npm install ``` -------------------------------- ### Install finalhandler Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/finalhandler/README.md Install the finalhandler module using npm. ```sh npm install finalhandler ``` -------------------------------- ### Install vary Package Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/vary/README.md Install the vary package using npm. This is the first step before using its functionalities. ```sh npm install vary ``` -------------------------------- ### Run Nodemon with a Specific Script Source: https://github.com/remy/nodemon/wiki/Home Starts nodemon to monitor and run 'server.js'. This is the most basic way to use nodemon. ```text $ nodemon server.js ``` -------------------------------- ### Install mime-db Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/README.md Install the mime-db package using npm. This is the first step to using the database in your Node.js project. ```bash npm i mime-db ``` -------------------------------- ### Install Fresh Module Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/fresh/README.md Install the fresh module using npm. This command is used to add the package to your project's dependencies. ```bash npm install fresh ``` -------------------------------- ### Install Application Dependencies Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/Readme.md Installs all the necessary dependencies for a generated Express.js application using npm. ```bash $ npm install ``` -------------------------------- ### Install mime-types Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md Install the mime-types package using npm. ```sh npm install mime-types ``` -------------------------------- ### Install Debug Module Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/debug/Readme.md Install the debug module using npm. This is the first step to using the library in your Node.js project. ```bash $ npm install debug ``` -------------------------------- ### Require Nodemon and Configure with String Arguments Source: https://github.com/remy/nodemon/wiki/As-a-required-module This example demonstrates requiring Nodemon and passing configuration options as a command-line-style string argument. This is an alternative to using a configuration object. ```javascript var nodemon = require('nodemon'); nodemon('-e "js json" app.js'); ``` -------------------------------- ### Install cookie Module Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/cookie/README.md Install the cookie module using npm. ```bash npm install cookie ``` -------------------------------- ### Basic HTTP Server Debugging Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/debug/Readme.md Example of using the debug module to log server boot messages and incoming request details in an HTTP server. ```javascript var debug = require('debug')('http') , http = require('http') , name = 'My App'; // fake app debug('booting %s', name); http.createServer(function(req, res){ debug(req.method + ' ' + req.url); res.end('hello\n'); }).listen(3000, function(){ debug('listening'); }); // fake worker of some kind require('./worker'); ``` -------------------------------- ### Get Nodemon CLI Help Source: https://github.com/remy/nodemon/blob/main/README.md Use the -h or --help flag to display available command-line options for nodemon. ```bash nodemon -h ``` -------------------------------- ### Basic HTTP Server with send Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/send/Readme.md Create a basic HTTP server that serves files using the send module. This example pipes the request URL directly to send and pipes the output to the response. ```javascript var http = require('http'); var send = require('send'); var app = http.createServer(function(req, res){ send(req, req.url).pipe(res); }).listen(3000); ``` -------------------------------- ### Run Express Test Suite Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/Readme.md Installs dependencies and runs the test suite for Express.js. ```bash $ npm install $ npm test ``` -------------------------------- ### Install Nodemon as Development Dependency Source: https://github.com/remy/nodemon/blob/main/README.md Install nodemon as a local development dependency using npm or yarn. This is useful for project-specific installations, allowing execution via npm scripts or npx. ```bash npm install --save-dev nodemon # or using yarn: yarn add nodemon -D ``` -------------------------------- ### Install Node.js CRC Module Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/etag/node_modules/crc/README.md Use npm to install the crc module. This is the standard way to add the module to your project. ```bash npm install crc ``` -------------------------------- ### Install Nodemon Globally Source: https://github.com/remy/nodemon/blob/main/website/index.html Install nodemon globally using npm. This command makes nodemon available as a command-line tool on your system. ```bash npm install -g nodemon ``` -------------------------------- ### Run Node.js App with Inspect Flag Source: https://github.com/remy/nodemon/blob/main/README.md Start your Node.js application with nodemon and the --inspect flag for debugging. ```bash nodemon --inspect ./server.js 80 ``` -------------------------------- ### Example body parser middleware Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/type-is/README.md An example of how the `type-is` module can be used within a middleware function to parse request bodies based on their content type. ```APIDOC ## Example body parser ### Description This example demonstrates a middleware function that uses `type-is` to determine the content type of an incoming request and conditionally parse its body. It handles 'urlencoded', 'json', and 'multipart' types, throwing an error or returning a 415 status code for unsupported types. ### Method Not applicable (this is a middleware function example). ### Endpoint Not applicable (this is a middleware function example). ### Parameters - **req**: The Node.js HTTP request object. - **res**: The Node.js HTTP response object. - **next**: The next middleware function in the stack. ### Request Example ```javascript var is = require('type-is'); function bodyParser(req, res, next) { if (!is.hasBody(req)) { // Assuming is.hasBody is a helper function return next() } switch (is(req, ['urlencoded', 'json', 'multipart'])) { case 'urlencoded': // implement urlencoded body parsing throw new Error('implement urlencoded body parsing') break case 'json': // implement json body parsing throw new Error('implement json body parsing') break case 'multipart': // implement multipart body parsing throw new Error('implement multipart body parsing') break default: // 415 Unsupported Media Type res.statusCode = 415 res.end() return } } ``` ### Response - **200 OK**: If the body is successfully parsed. - **415 Unsupported Media Type**: If the request's content type is not one of the supported types ('urlencoded', 'json', 'multipart'). ``` -------------------------------- ### Install procps for Docker Volume Watcher Issues Source: https://github.com/remy/nodemon/blob/main/faq.md When using Docker volumes, nodemon might not restart automatically due to missing filesystem utilities. Installing the `procps` package in the Dockerfile can resolve this. ```dockerfile FROM node:8.9.4-wheezy RUN apt-get update && apt-get install -y procps ``` -------------------------------- ### Serve all files as downloads Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/serve-static/README.md Configure serve-static to serve all files as downloads by setting the 'Content-Disposition' header. This example also disables the default index file serving. ```js var contentDisposition = require('content-disposition') var finalhandler = require('finalhandler') var http = require('http') var serveStatic = require('serve-static') // Serve up public/ftp folder var serve = serveStatic('public/ftp', { 'index': false, 'setHeaders': setHeaders }) // Set header to force download function setHeaders(res, path) { res.setHeader('Content-Disposition', contentDisposition(path)) } // Create server var server = http.createServer(function(req, res){ var done = finalhandler(req, res) serve(req, res, done) }) // Listen server.listen(3000) ``` -------------------------------- ### Initialize Accepts with Request Object Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/accepts/README.md Instantiate the Accepts object by passing the Node.js request object. This is the initial setup required to use the module's features. ```javascript var accepts = require('accepts') http.createServer(function (req, res) { var accept = accepts(req) }) ``` -------------------------------- ### nodemon CLI Watch Example Source: https://github.com/remy/nodemon/blob/main/doc/arch.md Use this command to watch specific directories and file extensions. It configures nodemon to monitor 'src/' for '.js' and '.coffee' files. ```bash nodemon --watch src/ -e js,coffee app.js ``` -------------------------------- ### Basic Nodemon Usage Source: https://github.com/remy/nodemon/blob/main/doc/cli/help.txt Start nodemon to monitor and restart a script when changes are detected. If no script is specified, nodemon attempts to use the 'main' field from package.json. ```bash nodemon server.js ``` -------------------------------- ### nodemon.json Configuration Example Source: https://github.com/remy/nodemon/blob/main/README.md This JSON file can be used as a local or global configuration for nodemon. It allows setting options like verbosity, ignored files, and execution mappings for different file types. ```json { "verbose": true, "ignore": ["*.test.js", "**/fixtures/**"], "execMap": { "rb": "ruby", "pde": "processing --sketch={{pwd}} --run" } } ``` -------------------------------- ### Custom Logging Methods (stderr vs stdout) Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/debug/Readme.md Example showing how to redirect debug output to different logging methods like console.error or console.warn, either globally or per-namespace. ```javascript var debug = require('../'); var log = debug('app:log'); // by default console.log is used log('goes to stdout!'); var error = debug('app:error'); // set this namespace to log via console.error error.log = console.error.bind(console); // don't forget to bind to console! error('goes to stderr'); log('still goes to stdout!'); // set all output to go via console.warn // overrides all per-namespace log settings debug.log = console.warn.bind(console); log('now goes to stderr via console.warn'); error('still goes to stderr, but via console.warn now'); ``` -------------------------------- ### Nodemon with Debugger and Environment Variable Source: https://github.com/remy/nodemon/wiki/Home Starts nodemon with the Node.js debugger attached in break mode, and sets the PORT environment variable to 8000. ```text $ PORT=8000 nodemon --debug-brk server.js ``` -------------------------------- ### type-is Function Usage Examples Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/type-is/README.md Demonstrates various ways to use the 'is' function from the 'type-is' module to check request content types against different patterns. ```js // req.headers.content-type = 'application/json' is(req, ['json']) // 'json' is(req, ['html', 'json']) // 'json' is(req, ['application/*']) // 'application/json' is(req, ['application/json']) // 'application/json' is(req, ['html']) // false ``` -------------------------------- ### Watch All File Types with Nodemon Source: https://github.com/remy/nodemon/blob/main/faq.md To configure nodemon to watch all file types within a specific directory, use the --ext '*' option. This example also shows how to set a custom execution command. ```bash nodemon --ext '*' --watch public --exec 'python -m SimpleHTTPServer' ``` -------------------------------- ### Serve files with vanilla Node.js HTTP server Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/serve-static/README.md Example of serving files from a 'public/ftp' directory with custom index files using a vanilla Node.js http server. It utilizes finalhandler for error handling. ```js var finalhandler = require('finalhandler') var http = require('http') var serveStatic = require('serve-static') // Serve up public/ftp folder var serve = serveStatic('public/ftp', {'index': ['index.html', 'index.htm']}) // Create server var server = http.createServer(function(req, res){ var done = finalhandler(req, res) serve(req, res, done) }) // Listen server.listen(3000) ``` -------------------------------- ### Basic Usage with Configuration Object Source: https://github.com/remy/nodemon/blob/main/doc/requireable.md Demonstrates how to require nodemon and configure it with an options object to specify the script to run and file extensions to watch. ```APIDOC ## Basic Usage with Configuration Object ### Description This example shows how to use `nodemon` as a module by requiring it and passing a configuration object to start monitoring your application. ### Method `require('nodemon')({ ...configObject... })` ### Parameters #### Configuration Object - **script** (string) - Required - The entry point script for your application. - **ext** (string) - Optional - A space-separated string of file extensions to watch for changes. ### Request Example ```js var nodemon = require('nodemon'); nodemon({ script: 'app.js', ext: 'js json' }); ``` ### Event Handling Nodemon emits events that can be listened to using the `.on()` method. - `start`: Emitted when the application starts. - `quit`: Emitted when the application is quit. - `restart`: Emitted when the application restarts due to file changes. ### Response Example ```js nodemon.on('start', function () { console.log('App has started'); }).on('quit', function () { console.log('App has quit'); process.exit(); }).on('restart', function (files) { console.log('App restarted due to: ', files); }); ``` ``` -------------------------------- ### Require Nodemon with Object Configuration Source: https://github.com/remy/nodemon/blob/main/doc/requireable.md Use this to configure nodemon with script and file extensions when requiring it as a module. It allows for event handling of application start, quit, and restart. ```javascript var nodemon = require('nodemon'); nodemon({ script: 'app.js', ext: 'js json' }); nodemon.on('start', function () { console.log('App has started'); }).on('quit', function () { console.log('App has quit'); process.exit(); }).on('restart', function (files) { console.log('App restarted due to: ', files); }); ``` -------------------------------- ### Configure Delay for Nodemon Restarts (JSON) Source: https://github.com/remy/nodemon/blob/main/README.md When using `nodemon.json`, the `delay` value is always interpreted in milliseconds. This example shows an equivalent configuration to `--delay 2.5`. ```json { "delay": 2500 } ``` -------------------------------- ### Basic Usage Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/qs/README.md Demonstrates the fundamental usage of QS for parsing and stringifying querystring data. ```APIDOC ## Basic Usage ```javascript var Qs = require('qs'); var obj = Qs.parse('a=c'); // { a: 'c' } var str = Qs.stringify(obj); // 'a=c' ``` ``` -------------------------------- ### Handle Custom Signal in Node.js Application Source: https://github.com/remy/nodemon/blob/main/README.md Implement signal handlers in your Node.js application to react to signals sent by nodemon. This example shows how to reload configuration and then terminate the process gracefully. ```javascript process.on("SIGHUP", function () { reloadSomeConfiguration(); process.kill(process.pid, "SIGTERM"); }) ``` -------------------------------- ### Initialization Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/accepts/README.md Instantiate the Accepts object with the request object. ```APIDOC ## Initialization ### Description Instantiate the Accepts object with the request object. ### Method `new Accepts(req)` ### Parameters #### Path Parameters - **req** (object) - Required - The Node.js HTTP request object. ### Request Example ```javascript var http = require('http'); var accepts = require('accepts'); http.createServer(function (req, res) { var accept = accepts(req); }); ``` ``` -------------------------------- ### Graceful Signal Handling with Node.js Cluster Source: https://github.com/remy/nodemon/blob/main/README.md When using the `cluster` module, handle signals in the master process to forward them to workers. This example demonstrates forwarding `SIGHUP` to `SIGTERM` for all workers and ensuring workers ignore `SIGHUP`. ```javascript if (cluster.isMaster) { process.on("SIGHUP", function () { for (const worker of Object.values(cluster.workers)) { worker.process.kill("SIGTERM"); } }); } else { process.on("SIGHUP", function() {}) } ``` -------------------------------- ### Negotiator Constructor and Media Type Negotiation Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/accepts/node_modules/negotiator/README.md Demonstrates how to instantiate the Negotiator and use its methods for negotiating media types based on the request and available media types. ```APIDOC ## Negotiator Constructor and Media Type Negotiation ### Description Instantiate the Negotiator with a request object and use its methods to determine preferred media types. ### Constructor ```javascript var Negotiator = require('negotiator') var negotiator = new Negotiator(request) ``` ### Methods #### mediaTypes() Returns an array of preferred media types ordered by priority. ```javascript negotiator.mediaTypes() // -> ['text/html', 'image/jpeg', 'application/*'] ``` #### mediaTypes(availableMediaTypes) Returns an array of preferred media types ordered by priority from a list of available media types. ```javascript availableMediaTypes = ['text/html', 'text/plain', 'application/json'] negotiator.mediaTypes(availableMediaTypes) // -> ['text/html', 'application/json'] ``` #### mediaType(availableMediaTypes) Returns the top preferred media type from a list of available media types. ```javascript negotiator.mediaType(availableMediaTypes) // -> 'text/html' ``` ``` -------------------------------- ### Basic Usage of qs.parse and qs.stringify Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/qs/README.md Demonstrates the fundamental usage of the qs library for parsing a querystring into an object and stringifying an object back into a querystring. ```javascript var Qs = require('qs'); var obj = Qs.parse('a=c'); // { a: 'c' } var str = Qs.stringify(obj); // 'a=c' ``` -------------------------------- ### Example DeprecationError stack output Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/depd/Readme.md An example of the stack trace format for a DeprecationError emitted by the depd module. ```text DeprecationError: my-cool-module deprecated oldfunction at Object. ([eval]-wrapper:6:22) at Module._compile (module.js:456:26) at evalScript (node.js:532:25) at startup (node.js:80:7) at node.js:902:3 ``` -------------------------------- ### Create a 404 Handler Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/finalhandler/README.md Set up an HTTP server that always responds with a 404 Not Found error using finalhandler. ```javascript var finalhandler = require('finalhandler') var http = require('http') var server = http.createServer(function (req, res) { var done = finalhandler(req, res) done() }) server.listen(3000) ``` -------------------------------- ### Install Express Generator Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/Readme.md Installs the express-generator tool globally, which is used to quickly generate Express.js applications. Ensure the major version matches your Express version. ```bash $ npm install -g express-generator@4 ``` -------------------------------- ### Sample nodemon.json Configuration Source: https://github.com/remy/nodemon/blob/main/doc/sample-nodemon.md This JSON file configures nodemon's behavior, including which files to watch, how to restart the application, and environment-specific settings. ```json { "restartable": "rs", "ignore": [ ".git", "node_modules/**/node_modules" ], "verbose": true, "execMap": { "js": "node --harmony" }, "events": { "restart": "osascript -e 'display notification "App restarted due to:\n'$FILENAME'" with title "nodemon"'" }, "watch": [ "test/fixtures/", "test/samples/" ], "env": { "NODE_ENV": "development" }, "ext": "js,json" } ``` -------------------------------- ### Sample nodemon.json Configuration Source: https://github.com/remy/nodemon/wiki/Sample-nodemon.json Use this configuration to customize nodemon's behavior during development. It specifies which files to watch, how to execute scripts, and which directories to ignore. ```json { "restartable": "rs", "ignore": [ ".git", "node_modules/**/node_modules" ], "verbose": true, "execMap": { "js": "node --harmony" }, "watch": [ "test/fixtures/", "test/samples/" ], "env": { "NODE_ENV": "development" }, "ext": "js json" } ``` -------------------------------- ### Get Supported Encodings Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/accepts/README.md Specify the encodings your server supports to get the client's preferred encoding from the supported list. This helps in selecting a compatible encoding. ```javascript var encoding = accept.encodings('gzip', 'deflate') // -> 'gzip', probably ``` -------------------------------- ### mime.extension(type) Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/type-is/node_modules/mime-types/README.md Gets the default file extension for a given content-type. Returns `false` if the input is invalid or not found. ```APIDOC ## mime.extension(type) ### Description Get the default extension for a content-type. All functions return `false` if input is invalid or not found. ### Parameters #### Path Parameters - **type** (string) - The content-type to find the extension for. ### Response - **string** - The default file extension (e.g., 'bin') or `false` if not found. ### Request Example ```js var mime = require('mime-types') mime.extension('application/octet-stream') // 'bin' ``` ``` -------------------------------- ### Run Tests Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/content-disposition/README.md Execute the test suite for the module. ```sh $ npm test ``` -------------------------------- ### Get IP address type Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/README.md Call the kind() method on an address object to determine if it is an IPv6 or IPv4 address. ```javascript addr.kind(); // => "ipv6" or "ipv4" ``` -------------------------------- ### Benchmark Results - Simple Path Parsing Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/parseurl/README.md Benchmark results comparing parseurl against fasturl and nativeurl for parsing a simple URL path. ```bash > node benchmark/simplepath.js Parsing URL "/foo/bar" 1 test completed. 2 tests completed. 3 tests completed. fasturl x 4,535,825 ops/sec ±0.27% (191 runs sampled) nativeurl x 98,769 ops/sec ±0.54% (191 runs sampled) parseurl x 4,164,865 ops/sec ±0.34% (192 runs sampled) ``` -------------------------------- ### Get Default Extension for MIME Type Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/send/node_modules/mime/README.md Retrieve the default file extension associated with a given MIME type. ```javascript mime.extension('text/html'); // => 'html' mime.extension('application/octet-stream'); // => 'bin' ``` -------------------------------- ### Specify File Extensions to Watch Source: https://github.com/remy/nodemon/blob/main/README.md Use the -e or --ext switch to define a comma-separated list of file extensions nodemon should monitor. This overrides the default list. ```bash nodemon -e js,pug ``` -------------------------------- ### Nodemon with Watch Directory and Arguments Source: https://github.com/remy/nodemon/wiki/Home Runs nodemon on 'server.js' while also watching the '../foo' directory for changes. Any arguments after 'server.js' are passed to the script. ```text $ nodemon -w ../foo server.js apparg1 apparg2 ``` -------------------------------- ### Worker Process Debugging Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/debug/Readme.md Example of using the debug module within a separate worker process to log periodic activity. ```javascript var debug = require('debug')('worker'); setInterval(function(){ debug('doing some work'); }, 1000); ``` -------------------------------- ### Run Tests Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/etag/README.md Execute the test suite for the etag module using npm. ```sh npm test ``` -------------------------------- ### Stop nodemon process managed by forever Source: https://github.com/remy/nodemon/blob/main/faq.md Stop a process that was started with forever and is being monitored by nodemon, using the assigned 'uid'. ```bash forever stop foo ``` -------------------------------- ### Get Request Address with IP Array Trust Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/proxy-addr/README.md Trust an array of IP addresses, CIDR strings, or IP/netmask strings. ```javascript proxyaddr(req, ['127.0.0.0/8', '10.0.0.0/8']) proxyaddr(req, ['127.0.0.0/255.0.0.0', '192.168.0.0/255.255.0.0']) ``` -------------------------------- ### Get Request Address with IP String Trust Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/proxy-addr/README.md Trust a single IP address string for determining the request address. ```javascript proxyaddr(req, '127.0.0.1') ``` -------------------------------- ### Map of extensions by content type Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md Access the mime.extensions object to get a map of file extensions keyed by their content types. ```javascript [extensions...] = mime.extensions[type] ``` -------------------------------- ### Map of content types by extension Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md Access the mime.types object to get a map of content types keyed by their file extensions. ```javascript var type = mime.types[extension] ``` -------------------------------- ### Get default extension for content type Source: https://github.com/remy/nodemon/blob/main/test/fixtures/watch-count/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md Use mime.extension to retrieve the default file extension for a given content type. ```javascript mime.extension('application/octet-stream') // 'bin' ```