Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Keep your app alive with a production process manager.
Running with PM2 is easiest to learn by reading the example, changing it, and observing the result.
// ecosystem.config.cjs
module.exports = {
apps: [{
name: 'lessons-api',
script: 'src/server.js',
instances: 'max',
exec_mode: 'cluster',
env: { NODE_ENV: 'production', PORT: 3000 }
}]
};
// Start with: pm2 start ecosystem.config.cjsPractice the Running with PM2 example in a small scratch file, then explain what changed and why.