Running the Application
Here is the detailed description of each step to run the CodeChat API application in different modes:
Copying the Environment Configuration File:
cp .env.dev .env- This command copies the 
.env.devfile to a new file called.env. The.envfile is used by the application to load the environment variables necessary for execution. Typically, the.env.devfile contains settings suitable for the development environment. 
- This command copies the 
 Development Mode:
npm run start:dev- This command runs the application in development mode. In general, in development mode, the application can include additional debugging tools and automatically reload when files are changed. The 
start:devscript is defined in thepackage.jsonfile and specifies how the application should be started in this mode. 
- This command runs the application in development mode. In general, in development mode, the application can include additional debugging tools and automatically reload when files are changed. The 
 Production Mode:
npm run build
npm run start:prod- The 
npm run buildcommand compiles the application, optimizing it for the production environment. This process may include code minification, resource optimization, among others. - After compilation, 
npm run start:prodstarts the application in production mode. This mode is optimized for performance and security and is the recommended mode for production environments. 
- The 
 Using PM2:
npm run build
pm2 start 'npm run start:prod' --name CodeChat_V2- This set of commands first compiles the application for production (as described above).
 - Then 
pm2 start 'npm run start:prod' --name CodeChat_V2starts the application using PM2, a process manager for Node.js applications. PM2 helps keep the application online by automatically restarting it in case of failures. The--name CodeChat_V2parameter gives an identifiable name to the process, which is useful for management and monitoring. 
These commands ensure that the application runs properly in both development and production environments, providing tools to manage and optimize execution.