1. Concept library
  2. Backend with Node.js
  3. Module 11: Deployment

Concept

Environment configuration

Configuration comes from environment variables, read once at startup into a validated object. The same build then runs in every environment, and a missing variable fails fast with a clear message.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain why configuration is read once at startup into a validated object
  2. Write a config module that validates environment variables and fails fast
  3. Spot process.env read deep inside a request

In practice

A few lines that show Environment configuration doing its job.

JavaScript
import { z } from "zod";

const Env = z.object({
  PORT: z.coerce.number().default(3000),
  DATABASE_URL: z.string().url(),
  JWT_SECRET: z.string().min(32),
  LOG_LEVEL: z.enum(["debug", "info", "warn", "error"]).default("info"),
});

export const env = Env.parse(process.env);   // throws at boot if misconfigured

The common mistake

Watch for

Reading process.env throughout the codebase. A typo in a variable name is undefined at runtime, somewhere deep in a request, instead of an error at startup.

What to know first

Your roadmap puts these before Environment configuration, unless you already know them.

How it stays learned

Once a session shows you understand Environment configuration, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled

Where it leads

Topics that build on Environment configuration.

Next in the moduleContainers →