A web application for creating, printing, and saving jewelry or valuable item appraisals. This application allows users to enter client details, add multiple article descriptions, print appraisals, and download them as HTML files with proper formatting. All appraisals are now saved on the server as well.
- Client information form
- Dynamic addition and removal of article descriptions
- Local storage to save form data between sessions
- Print functionality with proper styling
- Download appraisals as HTML files
- Server-side storage of all appraisals
- Clone this repository
- Install dependencies:
npm install - Start the server:
npm start
For development with auto-restart:
npm run dev
- Open the application in your browser at http://localhost:3000
- Fill out the client and appraiser information
- Add article descriptions as needed
- Click "Print" to print the appraisal or "Download" to save it as an HTML file
- When clicking "Download", the appraisal will be saved to the server and downloaded locally
The server provides the following API endpoints:
POST /api/appraisals- Save a new appraisalGET /api/appraisals/:id- Retrieve a specific appraisalGET /api/appraisals- List all saved appraisals
All appraisals are saved as JSON files in the appraisals directory with unique UUIDs as filenames.
index.html- Main application HTMLstyle.css- Styling for the applicationscript.js- Client-side JavaScript for form handling and API integrationserver.js- Express server with API endpointsappraisals/- Directory where appraisal data is stored
- HTML5
- CSS3
- Vanilla JavaScript
- Node.js
- Express
- UUID for unique identifiers Excellent! Now that PM2 is installed, you can use it to manage your application in a production environment.
Here's how you can use PM2 with your server.js application:
-
Starting your application with PM2: Open your terminal and run:
pm2 start server.js --name appraisal-generator -i max
pm2 start server.js: This tells PM2 to start yourserver.jsfile.--name appraisal-generator: This gives your application a name within PM2, making it easier to manage.-i max: This starts your application in cluster mode, utilizing all available CPU cores. This is great for performance. If you prefer to run a single instance, you can omit-i maxor use-i 1.
-
Common PM2 Commands: Once your application is running, you can manage it with these commands:
pm2 listorpm2 ls: Lists all applications managed by PM2 and their status.pm2 logs appraisal-generator: Shows the logs for your application. You can also usepm2 logsto see logs for all apps.pm2 stop appraisal-generator: Stops your application.pm2 restart appraisal-generator: Restarts your application.pm2 delete appraisal-generator: Stops your application and removes it from PM2's list.pm2 monit: Opens a live dashboard to monitor CPU and memory usage of your apps.
-
Saving your PM2 process list and creating a startup script: To ensure your application restarts automatically after a server reboot, you can do the following:
pm2 save: Saves the current list of processes managed by PM2.pm2 startup: This command will detect your server's init system (like systemd, upstart, launchd) and provide you with a command to run. This command (usually run withsudo) will configure PM2 to start automatically on boot, along with your saved processes.
-
Ecosystem File (Optional but Recommended for Production): For more complex configurations, you can create an
ecosystem.config.jsfile in your project root. This file allows you to define all PM2 options for your app(s) in one place, including environment variables, log file paths, deployment options, and more.Example
ecosystem.config.js:module.exports = { apps : [{ name : "appraisal-generator", script : "./server.js", instances: "max", // Or a specific number of instances exec_mode : "cluster", // Enables clustering watch : false, // Set to true to restart on file changes (usually for dev) env : { "NODE_ENV": "development" }, env_production: { // Environment variables for production "NODE_ENV": "production", "PORT": 3000, // Or your desired production port // Add other production-specific env vars here // "API_SECRET_KEY": "your_production_secret_key", // "ABUSEIPDB_API_KEY": "your_production_abuseipdb_key" } }] }
You would then start your application using
pm2 start ecosystem.config.js --env production. Important: Remember to set your actual secret keys and other sensitive information directly in your production environment's variables or a secure vault, not in theecosystem.config.jsif it's committed to version control. Theenv_productionblock in the ecosystem file is more for non-sensitive configurations or for PM2 to pass through system environment variables.
By using Helmet.js and PM2, you've taken significant steps towards a more secure and robust production deployment for your appraisal generator application.