@gaonjs/config 0.1.0 → 0.2.0
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/dist/apps.d.ts +4 -1
- package/dist/apps.js +9 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +35 -0
- package/dist/types.js +4 -0
- package/dist/wire.js +6 -1
- package/package.json +13 -13
package/dist/apps.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ export interface DiscoveredApp {
|
|
|
23
23
|
export declare function resolveApps(cwd?: string): Promise<DiscoveredApp[]>;
|
|
24
24
|
/**
|
|
25
25
|
* DiscoveredApp 을 AppSpec 으로 변환. 세션·인증 옵션은 wire.ts 가 config
|
|
26
|
-
* 를 반영해 덧붙인다. 여기서는 순수
|
|
26
|
+
* 를 반영해 덧붙인다. 여기서는 순수 이름·라우트·컨트롤러·hosts 만.
|
|
27
|
+
*
|
|
28
|
+
* hosts: app.config.ts 의 `hosts:` 배열을 그대로 옮긴다(v0.16 §3.3 · 운영
|
|
29
|
+
* 도메인). 문자열 배열만 신뢰 — 잘못된 값은 조용히 무시한다.
|
|
27
30
|
*/
|
|
28
31
|
export declare function toAppSpec(app: DiscoveredApp): AppSpec;
|
package/dist/apps.js
CHANGED
|
@@ -68,13 +68,21 @@ export async function resolveApps(cwd = process.cwd()) {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* DiscoveredApp 을 AppSpec 으로 변환. 세션·인증 옵션은 wire.ts 가 config
|
|
71
|
-
* 를 반영해 덧붙인다. 여기서는 순수
|
|
71
|
+
* 를 반영해 덧붙인다. 여기서는 순수 이름·라우트·컨트롤러·hosts 만.
|
|
72
|
+
*
|
|
73
|
+
* hosts: app.config.ts 의 `hosts:` 배열을 그대로 옮긴다(v0.16 §3.3 · 운영
|
|
74
|
+
* 도메인). 문자열 배열만 신뢰 — 잘못된 값은 조용히 무시한다.
|
|
72
75
|
*/
|
|
73
76
|
export function toAppSpec(app) {
|
|
77
|
+
const raw = app.appConfig?.hosts;
|
|
78
|
+
const hosts = Array.isArray(raw)
|
|
79
|
+
? raw.filter((h) => typeof h === 'string' && h.length > 0)
|
|
80
|
+
: undefined;
|
|
74
81
|
return {
|
|
75
82
|
name: app.name,
|
|
76
83
|
routes: app.routes,
|
|
77
84
|
controllers: app.controllers,
|
|
78
85
|
channels: app.channels,
|
|
86
|
+
hosts,
|
|
79
87
|
};
|
|
80
88
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { defineConfig, type GaonConfig, type DbConfig, type RedisConfig, type NatsConfig, type HubConfig, type MailConfig, type StorageConfig, type StorageDiskConfig, type I18nConfig, type WebConfig, } from './types.js';
|
|
1
|
+
export { defineConfig, defineAppConfig, type GaonConfig, type AppConfig, type AppSessionConfig, type DbConfig, type RedisConfig, type NatsConfig, type HubConfig, type MailConfig, type StorageConfig, type StorageDiskConfig, type I18nConfig, type WebConfig, } from './types.js';
|
|
2
2
|
export { loadGaonConfig, findConfigPath } from './load.js';
|
|
3
3
|
export { resolveApps, toAppSpec, type DiscoveredApp, } from './apps.js';
|
|
4
4
|
export { wireGaon, type WiredGaon } from './wire.js';
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
// `gaon serve`/`gaon dev` 가 loadGaonConfig + wireGaon 을 조립해서
|
|
8
8
|
// Fastify 인스턴스를 만들고 listen 한다.
|
|
9
|
-
export { defineConfig, } from './types.js';
|
|
9
|
+
export { defineConfig, defineAppConfig, } from './types.js';
|
|
10
10
|
export { loadGaonConfig, findConfigPath } from './load.js';
|
|
11
11
|
export { resolveApps, toAppSpec, } from './apps.js';
|
|
12
12
|
export { wireGaon } from './wire.js';
|
package/dist/types.d.ts
CHANGED
|
@@ -95,3 +95,38 @@ export interface GaonConfig {
|
|
|
95
95
|
* 반환값은 그대로 통과시켜 IDE 자동완성·형 검사만 제공한다.
|
|
96
96
|
*/
|
|
97
97
|
export declare function defineConfig(config: GaonConfig): GaonConfig;
|
|
98
|
+
/**
|
|
99
|
+
* 앱 세션 옵션(§7 · 앱별 세션 완전 분리). AppSpec.session 과 정합하지만
|
|
100
|
+
* 여기서는 사용자 마주(app.config.ts) 타입만 얇게 유지한다 — 실 세션 배선은
|
|
101
|
+
* wire.ts 가 Redis 인스턴스를 주입해 완성한다.
|
|
102
|
+
*/
|
|
103
|
+
export interface AppSessionConfig {
|
|
104
|
+
/** 서명 비밀 · env('APP_<NAME>_SESSION_SECRET') 관례 권장. */
|
|
105
|
+
readonly secret: string;
|
|
106
|
+
/** 세션 쿠키 이름(생략 시 관례: <app>_session). */
|
|
107
|
+
readonly cookieName?: string;
|
|
108
|
+
/** 세션 TTL(초). 생략 시 배터리 기본. */
|
|
109
|
+
readonly ttlSeconds?: number;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 앱별 설정 — apps/<app>/app.config.ts (v0.16 §3.3).
|
|
113
|
+
*
|
|
114
|
+
* 잘 지은 앱의 app.config.ts 는 거의 비어 있어야 한다(§1.1 ②). 관례에서
|
|
115
|
+
* 벗어날 때만 값을 채운다:
|
|
116
|
+
* - hosts: 이 앱이 응답할 도메인 목록. 생략 시 URL 프리픽스 관례만 사용.
|
|
117
|
+
* - session: 세션 옵션(secret · 쿠키 이름 등).
|
|
118
|
+
* - prefix: URL 프리픽스 관례를 명시적으로 덮어쓴다(고급).
|
|
119
|
+
*
|
|
120
|
+
* 개발 모드에서는 `<앱이름>.localhost` 로도 접근된다(v0.11 · §3.3) —
|
|
121
|
+
* hosts 를 비워도 이 로컬 관례는 자동으로 성립한다.
|
|
122
|
+
*/
|
|
123
|
+
export interface AppConfig {
|
|
124
|
+
/** 이 앱이 응답할 도메인 목록(운영). 예: ['admin.example.com']. */
|
|
125
|
+
readonly hosts?: readonly string[];
|
|
126
|
+
/** 세션 옵션 — 미지정 시 세션 배터리는 이 앱에서 꺼져 있다. */
|
|
127
|
+
readonly session?: AppSessionConfig;
|
|
128
|
+
/** URL 프리픽스 명시 덮어쓰기. 생략 시 관례: web→'/', 그 외→'/<name>'. */
|
|
129
|
+
readonly prefix?: string;
|
|
130
|
+
}
|
|
131
|
+
/** 타입 안전 헬퍼 — `export default defineAppConfig({...})`. */
|
|
132
|
+
export declare function defineAppConfig(config: AppConfig): AppConfig;
|
package/dist/types.js
CHANGED
package/dist/wire.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// 필수이므로 auth 앱은 명시적으로 secret 을 제공해야 한다(env 로 주입 권장).
|
|
9
9
|
import { Redis } from 'ioredis';
|
|
10
10
|
import { createDb, registerConnection, destroyAllConnections, } from '@gaonjs/data';
|
|
11
|
-
import { connectNats } from '@gaonjs/async';
|
|
11
|
+
import { connectNats, configureJobs } from '@gaonjs/async';
|
|
12
12
|
import { configureMailer, smtpTransport } from '@gaonjs/mail';
|
|
13
13
|
import { configureStorage, localDisk, s3Disk, resetStorage } from '@gaonjs/storage';
|
|
14
14
|
import { configureI18n, loadLocales, resetI18n } from '@gaonjs/i18n';
|
|
@@ -41,9 +41,14 @@ export async function wireGaon(config, cwd = process.cwd()) {
|
|
|
41
41
|
redis = new Redis(config.redis.url, { lazyConnect: false, maxRetriesPerRequest: 3 });
|
|
42
42
|
}
|
|
43
43
|
// 3) NATS — 웹 프로세스도 채널·잡 publish 를 위해 연결한다.
|
|
44
|
+
// 연결만으로는 부족하다 — 잡 전송 런타임(configureJobs)까지 배선해야
|
|
45
|
+
// 컨트롤러의 `.later()` 가 실제로 publish 된다. 이걸 빠뜨리면 웹에서
|
|
46
|
+
// 잡 발행 시 "잡 전송이 설정되지 않았습니다" 로 깨진다(work 는 runWork
|
|
47
|
+
// 가 이미 설정하지만 serve 는 여기서 해야 한다).
|
|
44
48
|
let nats;
|
|
45
49
|
if (config.nats) {
|
|
46
50
|
nats = await connectNats({ servers: config.nats.url, name: config.nats.name ?? 'gaon-serve' });
|
|
51
|
+
configureJobs(nats);
|
|
47
52
|
}
|
|
48
53
|
// 4) mail — SMTP 전송(개발은 MailPit, 운영은 실 SMTP).
|
|
49
54
|
if (config.mail) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaonjs/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Gaon 루트 설정 로더·자동 배선 (gaon.config.ts · §3.3 · M9-A)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,20 +23,20 @@
|
|
|
23
23
|
"dist",
|
|
24
24
|
"README.md"
|
|
25
25
|
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json"
|
|
28
|
+
},
|
|
26
29
|
"dependencies": {
|
|
27
|
-
"
|
|
28
|
-
"@gaonjs/
|
|
29
|
-
"@gaonjs/
|
|
30
|
-
"@gaonjs/
|
|
31
|
-
"@gaonjs/
|
|
32
|
-
"@gaonjs/
|
|
33
|
-
"@gaonjs/
|
|
34
|
-
"
|
|
30
|
+
"@gaonjs/async": "workspace:*",
|
|
31
|
+
"@gaonjs/core": "workspace:*",
|
|
32
|
+
"@gaonjs/data": "workspace:*",
|
|
33
|
+
"@gaonjs/i18n": "workspace:*",
|
|
34
|
+
"@gaonjs/mail": "workspace:*",
|
|
35
|
+
"@gaonjs/storage": "workspace:*",
|
|
36
|
+
"@gaonjs/web": "workspace:*",
|
|
37
|
+
"ioredis": "^5.4.1"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
37
40
|
"fastify": "^5.0.0"
|
|
38
|
-
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json"
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|