This is a placeholder post that also demonstrates code snippet support.
I try to keep the shape of a project boring and predictable. Here’s a small example of the kind of glue code I write early on — a typed config loader:
type Config = {
port: number;
databaseUrl: string;
logLevel: "debug" | "info" | "warn" | "error";
};
function loadConfig(env = process.env): Config {
const required = (key: string): string => {
const value = env[key];
if (!value) throw new Error(`Missing required env var: ${key}`);
return value;
};
return {
port: Number(env.PORT ?? 3000),
databaseUrl: required("DATABASE_URL"),
logLevel: (env.LOG_LEVEL as Config["logLevel"]) ?? "info",
};
}
And the equivalent idea in Go, which I reach for on systems work:
type Config struct {
Port int
DatabaseURL string
LogLevel string
}
func LoadConfig() (Config, error) {
url := os.Getenv("DATABASE_URL")
if url == "" {
return Config{}, errors.New("missing required env var: DATABASE_URL")
}
return Config{
Port: 3000,
DatabaseURL: url,
LogLevel: "info",
}, nil
}
The point isn’t the config loader itself — it’s that fail-fast, explicit configuration saves hours of debugging later. Replace this post with your own.