Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Ship your API with environment config and a process manager.
Deploying to Production is easiest to learn by reading the example, changing it, and observing the result.
// npm install dotenv
import 'dotenv/config';
const config = {
port: Number(process.env.PORT ?? 3000),
nodeEnv: process.env.NODE_ENV ?? 'development',
databaseUrl: process.env.DATABASE_URL
};
if (config.nodeEnv === 'production' && !config.databaseUrl) {
throw new Error('DATABASE_URL is required in production');
}
export default config;Practice the Deploying to Production example in a small scratch file, then explain what changed and why.