Hot module reloading



JavaScript is coded as an interpreted language. This means that it is not compiled in advance like RPG, C++, or Java. The source code file and the executable file are one and the same. 

Whenever Node.js modules are used, however, Node automatically caches them for performance. When a module is cached, it doesn't have to be read from disk again and reinterpreted.

With traditional Node.js applications, cached modules are not reloaded until the node process is restarted. This means a server instance would have to be ended and started up again in order to incorporate changes to your applications.

To avoid downtime, Profound.js incorporates hot module reloading, a feature that invalidates the module cache immediately after a Profound.js module is modified. With this, you can deploy application changes instantly without having to restart Profound.js. Hot module reloading is enabled by default. To disable this feature, update the hotReloading flag in the Profound.js Configuration File.

Reloading API files and Workspaces

This following routes were added in version 6.0.0 of Profound.js.

For API files and Workspaces, they are automatically hot reloaded when they are saved in the IDE.  However, if they are updated outside of the IDE they will not hot reload

To reload these files without needing to open and then save them in the IDE, we added two routes that can be accessed via a POST webservice call to reload these files.  They are /reloadAPI and /reloadWorkspaces respectfully.  The /reloadAPI route will reload all API files not located in workspaces, and the /reloadWorkspaces route will reload all files in workspaces, including API files. 

Both of these routes take a POST request with no parameters, and are protected with basic authentication.  Both routes respond with a simple {"success": true} object, regardless if any API files or Workspaces were updated or not. 

To setup the basic authentication the server must use the basicAuthCredentials config option to store the credentials, and only these credentials will satisfy the basic authentication.