@spfn/core 0.2.0-beta.13 → 0.2.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/env.md CHANGED
@@ -291,23 +291,38 @@ const optionalRedisParser = optional(parseRedisUrl);
291
291
  ```typescript
292
292
  import { loadEnv } from '@spfn/core/env/loader';
293
293
 
294
- loadEnv(); // Loads .env, .env.local, .env.server, .env.server.local
294
+ // 기본 사용 (NODE_ENV 자동 감지)
295
+ loadEnv();
296
+
297
+ // 특정 환경 지정
298
+ loadEnv({ nodeEnv: 'production' });
299
+
300
+ // 서버 레이어 제외 (Next.js 클라이언트용)
301
+ loadEnv({ server: false });
295
302
  ```
296
303
 
297
- ### Loading Priority
304
+ ### Loading Priority (6-Layer)
305
+
306
+ `NODE_ENV`에 따라 동적으로 파일 목록이 결정됩니다 (나중 파일이 덮어씀):
298
307
 
299
- 1. `.env` - 기본값
300
- 2. `.env.local` - 로컬 오버라이드
301
- 3. `.env.server` - 서버 전용 기본값
302
- 4. `.env.server.local` - 서버 전용 민감정보
308
+ 1. `.env` - 공통 기본값 (committed)
309
+ 2. `.env.{NODE_ENV}` - 환경별 오버라이드 (committed)
310
+ 3. `.env.local` - Next.js용 로컬 오버라이드 (gitignored, **test에서 스킵**)
311
+ 4. `.env.{NODE_ENV}.local` - 환경별 시크릿 (gitignored)
312
+ 5. `.env.server` - 서버 전용 기본값 (committed)
313
+ 6. `.env.server.local` - 서버 전용 시크릿 (gitignored)
314
+
315
+ > **Important:** `.env.local`은 Next.js용입니다. 서버 전용 시크릿(`DATABASE_URL` 등)은 반드시 `.env.server.local`에 넣으세요.
303
316
 
304
317
  ### Options
305
318
 
306
319
  ```typescript
307
320
  loadEnv({
308
- cwd: '/path/to/project',
309
- debug: true,
310
- override: false,
321
+ cwd: '/path/to/project', // 프로젝트 루트 (default: process.cwd())
322
+ nodeEnv: 'production', // NODE_ENV 지정 (default: process.env.NODE_ENV || 'local')
323
+ server: true, // 서버 전용 파일 포함 (default: true)
324
+ debug: true, // 로드된 파일 로깅 (default: false)
325
+ override: false, // 기존 process.env 덮어쓰기 (default: false)
311
326
  });
312
327
 
313
328
  // Load once (prevent duplicate calls)
@@ -323,20 +338,27 @@ loadEnvOnce();
323
338
 
324
339
  ```
325
340
  project/
326
- ├── .env # 기본값 (커밋 O)
327
- ├── .env.local # Next.js용 (커밋 X)
328
- ├── .env.server # SPFN 전용 기본값 (커밋 O)
329
- └── .env.server.local # SPFN 전용 민감정보 (커밋 X)
341
+ ├── .env # 공통 기본값 (committed)
342
+ ├── .env.production # production 오버라이드 (committed)
343
+ ├── .env.local # Next.js용 로컬 오버라이드 (gitignored)
344
+ ├── .env.production.local # production 시크릿 (gitignored)
345
+ ├── .env.server # 서버 전용 기본값 (committed)
346
+ └── .env.server.local # 서버 전용 시크릿 (gitignored)
330
347
  ```
331
348
 
332
349
  ### Which File for What?
333
350
 
334
351
  | 환경변수 | 파일 | 이유 |
335
352
  |----------|------|------|
336
- | `NEXT_PUBLIC_*` | `.env.local` | 브라우저 노출 OK |
337
- | `SPFN_API_URL` | `.env.local` | Next.js에서 사용 |
338
- | `DATABASE_URL` | `.env.server.local` | SPFN 전용, 민감정보 |
339
- | `SESSION_SECRET` | `.env.server.local` | SPFN 전용, 민감정보 |
353
+ | `NODE_ENV`, `SPFN_LOG_LEVEL` | `.env` | 모든 환경 공통, 비민감 |
354
+ | `SPFN_API_URL` (production) | `.env.production` | 환경별 비민감 설정 |
355
+ | `NEXT_PUBLIC_*` | `.env.local` | Next.js 클라이언트용, 브라우저 노출 OK |
356
+ | `SPFN_APP_URL` | `.env.local` | Next.js에서 사용하는 로컬 설정 |
357
+ | `DB_POOL_MAX` | `.env.server` | 서버 전용, 비민감 |
358
+ | `DATABASE_URL` | `.env.server.local` | 서버 전용, **민감정보** |
359
+ | `SESSION_SECRET` | `.env.server.local` | 서버 전용, **민감정보** |
360
+
361
+ > **Rule:** `.env.local`은 Next.js용입니다. `DATABASE_URL`, `SESSION_SECRET` 등 서버 전용 시크릿은 `.env.server.local`에 넣으세요.
340
362
 
341
363
  ### Schema with `nextjs` Option
342
364
 
@@ -345,13 +367,13 @@ DATABASE_URL: envString({
345
367
  description: 'PostgreSQL connection URL',
346
368
  required: true,
347
369
  sensitive: true,
348
- nextjs: false, // SPFN 서버에서만 사용
370
+ nextjs: false, // SPFN 서버에서만 사용 → .env.server.local
349
371
  }),
350
372
 
351
373
  SPFN_API_URL: envString({
352
374
  description: 'Backend API URL',
353
375
  required: true,
354
- nextjs: true, // Next.js에서도 사용
376
+ nextjs: true, // Next.js에서도 사용 → .env 또는 .env.local
355
377
  }),
356
378
  ```
357
379
 
@@ -419,9 +441,9 @@ const schema = defineEnvSchema({
419
441
  }),
420
442
 
421
443
  // Environment
422
- NODE_ENV: envEnum(['development', 'staging', 'production', 'test'] as const, {
444
+ NODE_ENV: envEnum(['local', 'development', 'staging', 'production', 'test'] as const, {
423
445
  description: 'Node environment',
424
- default: 'development',
446
+ default: 'local',
425
447
  }),
426
448
 
427
449
  // Logging
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spfn/core",
3
- "version": "0.2.0-beta.13",
3
+ "version": "0.2.0-beta.14",
4
4
  "description": "SPFN Framework Core - File-based routing, transactions, repository pattern",
5
5
  "type": "module",
6
6
  "exports": {