@cartanova/qgrid-cli 1.0.1 → 1.0.3

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.
Files changed (138) hide show
  1. package/bundle/dist/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
  2. package/bundle/dist/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +6 -0
  3. package/bundle/dist/dist/_virtual/_rolldown/runtime.js +15 -0
  4. package/bundle/dist/dist/application/qgrid/oauth.js +140 -0
  5. package/bundle/dist/dist/application/qgrid/pool.js +100 -0
  6. package/bundle/dist/dist/application/qgrid/qgrid.frame.js +280 -0
  7. package/bundle/dist/dist/application/qgrid/qgrid.types.js +79 -0
  8. package/bundle/dist/dist/application/qgrid/worker.js +183 -0
  9. package/bundle/dist/dist/application/queries.generated.js +31 -0
  10. package/bundle/dist/dist/application/request-log/request-log.model.js +113 -0
  11. package/bundle/dist/dist/application/request-log/request-log.types.js +13 -0
  12. package/bundle/dist/dist/application/sonamu.generated.js +99 -0
  13. package/bundle/dist/dist/application/sonamu.generated.sso.js +34 -0
  14. package/bundle/dist/dist/application/token/token.model.js +157 -0
  15. package/bundle/dist/dist/application/token/token.types.js +22 -0
  16. package/bundle/dist/dist/i18n/en.js +63 -0
  17. package/bundle/dist/dist/i18n/ko.js +62 -0
  18. package/bundle/dist/dist/i18n/sd.generated.js +272 -0
  19. package/bundle/dist/dist/index.js +11 -0
  20. package/bundle/dist/dist/migrations/20260410171405_create__request_logs.js +26 -0
  21. package/bundle/dist/dist/migrations/20260410171406_create__tokens.js +24 -0
  22. package/bundle/dist/dist/migrations/20260411120624_alter_tokens_alter2.js +16 -0
  23. package/bundle/dist/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +155 -0
  24. package/bundle/dist/dist/node_modules/.pnpm/@vitest_expect@4.1.2/node_modules/@vitest/expect/dist/index.js +1484 -0
  25. package/bundle/dist/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.2/node_modules/@vitest/pretty-format/dist/index.js +887 -0
  26. package/bundle/dist/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/chunk-artifact.js +2746 -0
  27. package/bundle/dist/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/index.js +8 -0
  28. package/bundle/dist/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/utils.js +8 -0
  29. package/bundle/dist/dist/node_modules/.pnpm/@vitest_snapshot@4.1.2/node_modules/@vitest/snapshot/dist/index.js +662 -0
  30. package/bundle/dist/dist/node_modules/.pnpm/@vitest_spy@4.1.2/node_modules/@vitest/spy/dist/index.js +386 -0
  31. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +82 -0
  32. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/constants.js +48 -0
  33. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/diff.js +1307 -0
  34. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/display.js +558 -0
  35. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/error.js +33 -0
  36. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/helpers.js +226 -0
  37. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/offset.js +27 -0
  38. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/serialize.js +77 -0
  39. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/source-map.js +374 -0
  40. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/timers.js +37 -0
  41. package/bundle/dist/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js +2886 -0
  42. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/branding.js +10 -0
  43. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/index.js +109 -0
  44. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/messages.js +10 -0
  45. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/overloads.js +10 -0
  46. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/utils.js +10 -0
  47. package/bundle/dist/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js +1127 -0
  48. package/bundle/dist/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +21 -0
  49. package/bundle/dist/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +432 -0
  50. package/bundle/dist/dist/node_modules/.pnpm/tinybench@2.9.0/node_modules/tinybench/dist/index.js +506 -0
  51. package/bundle/dist/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.js +86 -0
  52. package/bundle/dist/dist/node_modules/.pnpm/vite@8.0.3_@emnapi_core@1.9.2_@emnapi_runtime@1.9.2_@types_node@25.0.7_esbuild@0.27.4_jiti@2.6.1_sass@1.98.0_tsx@4.21.0/node_modules/vite/dist/node/module-runner.js +426 -0
  53. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
  54. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.js +41 -0
  55. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/evaluatedModules.Dg1zASAC.js +19 -0
  56. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/index.Chj8NDwU.js +202 -0
  57. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/index.DOa3dzoN.js +16 -0
  58. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +59 -0
  59. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/test.p_J6dB8a.js +2910 -0
  60. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +44 -0
  61. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/index.js +28 -0
  62. package/bundle/dist/dist/sonamu.config.js +196 -0
  63. package/bundle/dist/dist/testing/fixture.js +8 -0
  64. package/bundle/dist/dist/testing/global.js +9 -0
  65. package/bundle/dist/dist/testing/setup-mocks.js +17 -0
  66. package/bundle/dist/dist/utils/subset-loaders.js +12 -0
  67. package/bundle/src/application/qgrid/oauth.ts +181 -0
  68. package/bundle/src/application/qgrid/pool.ts +132 -0
  69. package/bundle/src/application/qgrid/qgrid.frame.ts +275 -0
  70. package/bundle/src/application/qgrid/qgrid.types.ts +117 -0
  71. package/bundle/src/application/qgrid/worker.ts +234 -0
  72. package/bundle/src/application/queries.generated.ts +59 -0
  73. package/bundle/src/application/request-log/request-log.model.ts +155 -0
  74. package/bundle/src/application/request-log/request-log.types.ts +15 -0
  75. package/bundle/src/application/sonamu.generated.http +187 -0
  76. package/bundle/src/application/sonamu.generated.sso.ts +66 -0
  77. package/bundle/src/application/sonamu.generated.ts +135 -0
  78. package/bundle/src/application/token/token.model.ts +160 -0
  79. package/bundle/src/application/token/token.types.ts +26 -0
  80. package/bundle/src/i18n/en.ts +59 -0
  81. package/bundle/src/i18n/ko.ts +59 -0
  82. package/bundle/src/i18n/sd.generated.ts +384 -0
  83. package/bundle/src/index.ts +6 -0
  84. package/bundle/src/sonamu.config.ts +248 -0
  85. package/bundle/src/src/application/qgrid/oauth.ts +181 -0
  86. package/bundle/src/src/application/qgrid/pool.ts +132 -0
  87. package/bundle/src/src/application/qgrid/qgrid.frame.ts +275 -0
  88. package/bundle/src/src/application/qgrid/qgrid.types.ts +117 -0
  89. package/bundle/src/src/application/qgrid/worker.ts +234 -0
  90. package/bundle/src/src/application/queries.generated.ts +59 -0
  91. package/bundle/src/src/application/request-log/request-log.entity.json +75 -0
  92. package/bundle/src/src/application/request-log/request-log.model.ts +155 -0
  93. package/bundle/src/src/application/request-log/request-log.types.ts +15 -0
  94. package/bundle/src/src/application/sonamu.generated.http +187 -0
  95. package/bundle/src/src/application/sonamu.generated.sso.ts +66 -0
  96. package/bundle/src/src/application/sonamu.generated.ts +135 -0
  97. package/bundle/src/src/application/token/token.entity.json +37 -0
  98. package/bundle/src/src/application/token/token.model.ts +160 -0
  99. package/bundle/src/src/application/token/token.types.ts +26 -0
  100. package/bundle/src/src/i18n/en.ts +59 -0
  101. package/bundle/src/src/i18n/ko.ts +59 -0
  102. package/bundle/src/src/i18n/sd.generated.ts +384 -0
  103. package/bundle/src/src/index.ts +6 -0
  104. package/bundle/src/src/migrations/20260410171405_create__request_logs.ts +23 -0
  105. package/bundle/src/src/migrations/20260410171406_create__tokens.ts +21 -0
  106. package/bundle/src/src/migrations/20260411120624_alter_tokens_alter2.ts +15 -0
  107. package/bundle/src/src/sonamu.config.ts +248 -0
  108. package/bundle/src/src/testing/fixture.ts +6 -0
  109. package/bundle/src/src/testing/global.ts +6 -0
  110. package/bundle/src/src/testing/setup-mocks.ts +44 -0
  111. package/bundle/src/src/typings/fastify.d.ts +8 -0
  112. package/bundle/src/src/typings/sonamu.d.ts +17 -0
  113. package/bundle/src/src/utils/subset-loaders.ts +11 -0
  114. package/bundle/src/testing/fixture.ts +6 -0
  115. package/bundle/src/testing/global.ts +6 -0
  116. package/bundle/src/testing/setup-mocks.ts +44 -0
  117. package/bundle/src/typings/fastify.d.ts +8 -0
  118. package/bundle/src/typings/sonamu.d.ts +17 -0
  119. package/bundle/src/utils/subset-loaders.ts +11 -0
  120. package/bundle/web-dist/web-dist/client/assets/index-DlPchHBY.js +116 -0
  121. package/bundle/web-dist/web-dist/client/assets/index-vZsvyuFn.css +1 -0
  122. package/bundle/web-dist/web-dist/client/assets/rolldown-runtime-Dw2cE7zH.js +1 -0
  123. package/bundle/web-dist/web-dist/client/assets/routes-CagDz23B.js +1 -0
  124. package/bundle/web-dist/web-dist/client/assets/sd.generated-BrQoQXvv.js +47 -0
  125. package/bundle/web-dist/web-dist/client/assets/services.generated-BspO2L0j.js +1 -0
  126. package/bundle/web-dist/web-dist/client/assets/show-aXUGa0gm.js +29 -0
  127. package/bundle/web-dist/web-dist/client/assets/tokens-DRkXtZ3Q.js +1 -0
  128. package/bundle/web-dist/web-dist/client/assets/vendor-react-DH4kUfK2.js +9 -0
  129. package/bundle/web-dist/web-dist/client/assets/vendor-tanstack-CUxlo6YN.js +1 -0
  130. package/bundle/web-dist/web-dist/client/index.html +18 -0
  131. package/bundle/web-dist/web-dist/server/assets/react-dom-CGIzOSuj.js +335 -0
  132. package/bundle/web-dist/web-dist/server/assets/routes-ClzReRep.js +490 -0
  133. package/bundle/web-dist/web-dist/server/assets/sd.generated-BnonqqKr.js +21694 -0
  134. package/bundle/web-dist/web-dist/server/assets/services.generated-D5ABD5fr.js +836 -0
  135. package/bundle/web-dist/web-dist/server/assets/show-C9pcdSxc.js +23364 -0
  136. package/bundle/web-dist/web-dist/server/assets/tokens-JH6FsnWZ.js +860 -0
  137. package/bundle/web-dist/web-dist/server/entry-server.generated.js +44646 -0
  138. package/package.json +11 -10
@@ -0,0 +1,248 @@
1
+ import path from "path";
2
+
3
+ import { getConsoleSink } from "@logtape/logtape";
4
+ import { getPrettyFormatter } from "@logtape/pretty";
5
+ import dotenv from "dotenv";
6
+ import { CachePresets, defineConfig } from "sonamu";
7
+ import { drivers as cacheDrivers, store } from "sonamu/cache";
8
+ import { drivers } from "sonamu/storage";
9
+
10
+ dotenv.config({ path: path.join(import.meta.dirname, "../.env") });
11
+
12
+ const host = process.env.HOST ?? "localhost";
13
+ const port = Number(process.env.PORT ?? 44900);
14
+
15
+ export default defineConfig({
16
+ projectName: process.env.PROJECT_NAME ?? "SonamuProject",
17
+ database: {
18
+ name: process.env.QGRID_DB_NAME ?? "qgrid",
19
+ defaultOptions: {
20
+ connection: {
21
+ host: process.env.QGRID_DB_HOST ?? "localhost",
22
+ port: Number(process.env.QGRID_DB_PORT ?? 44901),
23
+ user: process.env.QGRID_DB_USER ?? "postgres",
24
+ password: process.env.QGRID_DB_PASSWORD ?? "postgres",
25
+ },
26
+ },
27
+ environments: {
28
+ production: {
29
+ connection: {
30
+ host: process.env.DEV0_DB_HOST,
31
+ port: Number(process.env.DEV0_DB_PORT),
32
+ database: process.env.DATABASE_NAME,
33
+ user: process.env.DEV0_DB_USER,
34
+ password: process.env.DEV0_DB_PASSWORD,
35
+ },
36
+ },
37
+ fixture: {
38
+ connection: {
39
+ host: process.env.DEV0_DB_HOST,
40
+ port: Number(process.env.DEV0_DB_PORT),
41
+ database: process.env.DATABASE_NAME,
42
+ user: process.env.DEV0_DB_USER,
43
+ password: process.env.DEV0_DB_PASSWORD,
44
+ },
45
+ },
46
+ },
47
+ },
48
+ api: {
49
+ dir: "api",
50
+ timezone: "Asia/Seoul",
51
+ route: {
52
+ prefix: "/api",
53
+ },
54
+ },
55
+ i18n: {
56
+ defaultLocale: "ko",
57
+ supportedLocales: ["ko", "en"],
58
+ },
59
+ sync: {
60
+ targets: ["web"],
61
+ },
62
+ slackConfirm:
63
+ process.env.SLACK_BOT_TOKEN && process.env.SLACK_CHANNEL_ID
64
+ ? {
65
+ targets: ["development_master", "production_master"],
66
+ botToken: process.env.SLACK_BOT_TOKEN ?? "",
67
+ channelId: process.env.SLACK_CHANNEL_ID ?? "",
68
+ }
69
+ : undefined,
70
+ test: {
71
+ parallel: true,
72
+ maxWorkers: 4,
73
+ devRunner: { enabled: true },
74
+ },
75
+ logging: {
76
+ sinks: {
77
+ console: getConsoleSink({
78
+ formatter: getPrettyFormatter({
79
+ timestamp: "time",
80
+ categoryWidth: 20,
81
+ categoryTruncate: "middle",
82
+ }),
83
+ }),
84
+ },
85
+ loggers: [
86
+ {
87
+ category: ["sonamu"],
88
+ sinks: ["console"],
89
+ lowestLevel: process.env.NODE_ENV === "test" ? "warning" : "debug",
90
+ },
91
+ ],
92
+ },
93
+ server: {
94
+ listen: { port, host },
95
+ plugins: {
96
+ formbody: true,
97
+ qs: true,
98
+ multipart: { limits: { fileSize: 1024 * 1024 * 30 } },
99
+ static: {
100
+ root: path.join(import.meta.dirname, "/../", "public"),
101
+ prefix: "/api/public",
102
+ },
103
+ custom: (server) => {
104
+ // OAuth 콜백 — Anthropic이 /callback으로 리다이렉트
105
+ server.get("/callback", async (request, reply) => {
106
+ const { code, state } = request.query as { code?: string; state?: string };
107
+ if (!code || !state) {
108
+ return reply.redirect("/?oauth=error&reason=missing_params");
109
+ }
110
+ // Frame의 oauthCallback으로 위임
111
+ try {
112
+ const { QgridFrame } = await import("./application/qgrid/qgrid.frame");
113
+ await QgridFrame.handleOAuthCallback(code, state, reply);
114
+ } catch (e) {
115
+ return reply.redirect(
116
+ `/?oauth=error&reason=${encodeURIComponent((e as Error).message)}`,
117
+ );
118
+ }
119
+ });
120
+ },
121
+ },
122
+ apiConfig: {
123
+ contextProvider: (defaultContext, request) => {
124
+ return {
125
+ ...defaultContext,
126
+ ip: request.ip,
127
+ body: request.body,
128
+ };
129
+ },
130
+ guardHandler: (_guard, _request, _api) => {
131
+ if (_guard === "user") {
132
+ console.log("user guard");
133
+ }
134
+ console.log("NOTHING YET");
135
+ },
136
+ cacheControlHandler: (req) => {
137
+ switch (req.type) {
138
+ case "assets":
139
+ // Hash 포함된 파일: 영구 캐시
140
+ if (req.path.match(/-[a-f0-9]+\./)) {
141
+ return CachePresets.immutable;
142
+ }
143
+ return CachePresets.longLived;
144
+
145
+ case "api":
146
+ // GET 요청만 캐싱 고려
147
+ if (req.method === "GET") {
148
+ // 특정 경로는 짧은 캐시
149
+ if (req.path.startsWith("/api/static-data")) {
150
+ return CachePresets.shortLived;
151
+ }
152
+ if (req.path.startsWith("/api/terms")) {
153
+ return CachePresets.mediumLived;
154
+ }
155
+ }
156
+ // 기본: 캐시 없음
157
+ return CachePresets.noCache;
158
+
159
+ case "ssr":
160
+ // SSR 페이지: 10초 캐시
161
+ return CachePresets.ssr;
162
+
163
+ case "csr":
164
+ // CSR fallback (index.html): 1분 캐시
165
+ return CachePresets.shortLived;
166
+ }
167
+ },
168
+ },
169
+ storage: {
170
+ drivers: {
171
+ fs: drivers.fs({
172
+ location: path.join(import.meta.dirname, "/../public/uploaded"),
173
+ visibility: "public",
174
+ urlBuilder: {
175
+ async generateURL(key) {
176
+ return `/api/public/uploaded/${key}`;
177
+ },
178
+ async generateSignedURL(key) {
179
+ return `/api/public/uploaded/${key}`;
180
+ },
181
+ },
182
+ }),
183
+ s3: drivers.s3({
184
+ credentials: {
185
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? "",
186
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? "",
187
+ },
188
+ region: process.env.S3_REGION ?? "ap-northeast-2",
189
+ bucket: process.env.S3_BUCKET ?? "sonamu_default_bucket",
190
+ visibility: "private",
191
+ }),
192
+ },
193
+ },
194
+ cache: {
195
+ default: "main",
196
+ stores: {
197
+ main: store().useL1Layer(cacheDrivers.memory({ maxSize: "50mb" })),
198
+ },
199
+ ttl: "5m",
200
+ prefix: "",
201
+ },
202
+ lifecycle: {
203
+ onStart: async () => {
204
+ // DB 마이그레이션 자동 실행 (테이블 없으면 생성)
205
+ try {
206
+ const { TokenModel } = await import("./application/token/token.model");
207
+ const knex = TokenModel.getDB("w");
208
+ const migrationsDir = path.join(import.meta.dirname, "../src/migrations");
209
+ const [batch, log] = await knex.migrate.latest({
210
+ directory: migrationsDir,
211
+ });
212
+ if (log.length > 0) {
213
+ console.log(`✓ Migration: ${log.length} applied (batch ${batch})`);
214
+ log.forEach((name: string) => console.log(` ✓ ${name}`));
215
+ }
216
+ } catch (e) {
217
+ console.warn(`⚠ Migration skipped: ${(e as Error).message}`);
218
+ }
219
+
220
+ // Pool 초기화
221
+ const { initPool } = await import("./application/qgrid/pool");
222
+ try {
223
+ const { TokenModel } = await import("./application/token/token.model");
224
+ const entries = await TokenModel.findActive("A");
225
+ const tokens = entries.map((e) => e.token);
226
+ const pool = initPool(tokens);
227
+ console.log(
228
+ `🌲 Server listening on http://${host}:${port} (${pool.workers.size} tokens loaded)`,
229
+ );
230
+ } catch (e) {
231
+ console.warn(`⚠ Pool init failed: ${(e as Error).message}`);
232
+ initPool([]);
233
+ console.log(`🌲 Server listening on http://${host}:${port} (no tokens)`);
234
+ }
235
+ },
236
+ onShutdown: () => {
237
+ console.log("graceful shutdown");
238
+ },
239
+ onError: (error, _request, reply) => {
240
+ console.error(error);
241
+ reply.status(500).send({
242
+ name: error.name,
243
+ message: error.message,
244
+ });
245
+ },
246
+ },
247
+ },
248
+ });
@@ -0,0 +1,6 @@
1
+ import { createFixtureLoader } from "sonamu/test";
2
+
3
+ export const loadFixtures = createFixtureLoader({
4
+ // Define your fixtures...
5
+ fixture01: async () => {},
6
+ });
@@ -0,0 +1,6 @@
1
+ import dotenv from "dotenv";
2
+
3
+ dotenv.config();
4
+
5
+ // sonamu.config.ts의 test 설정을 기반으로 병렬 테스트 환경을 구성합니다.
6
+ export { setup } from "sonamu/test";
@@ -0,0 +1,44 @@
1
+ import type { PathLike } from "fs";
2
+
3
+ // import { Naite } from "sonamu";
4
+ import { vi } from "vitest";
5
+
6
+ // GlobalMock: fs/promises (사용 예시 - 필요시 활성화)
7
+ vi.mock("fs/promises", async (importOriginal) => {
8
+ const actual = (await importOriginal()) as typeof import("fs/promises");
9
+ return {
10
+ ...actual,
11
+ access: vi.fn((path: PathLike, mode?: number) => {
12
+ // const vfs = Naite.get("mock:fs/promises:virtualFileSystem").result();
13
+ // if (vfs.some((v) => v === path)) {
14
+ // return Promise.resolve();
15
+ // }
16
+
17
+ return actual.access(path, mode);
18
+ }),
19
+ // mkdir: vi.fn(
20
+ // async (
21
+ // path: PathLike,
22
+ // options?: MakeDirectoryOptions | Mode | null,
23
+ // ): Promise<string | undefined> => {
24
+ // // Naite.t("fs:mkdir", { path, options });
25
+ // if (typeof options === "object" && options?.recursive) {
26
+ // return typeof path === "string" ? path : path.toString();
27
+ // }
28
+ // return undefined;
29
+ // },
30
+ // ),
31
+ // writeFile: vi.fn((path: PathLike | FileHandle, data: string | Buffer | Uint8Array) => {
32
+ // const filePath = typeof path === "string" ? path : path.toString();
33
+
34
+ // // Naite.t(`fs/promises:writeFile`, { path: filePath, data });
35
+ // }),
36
+ // rm: vi.fn(async (path: PathLike, options?: RmOptions) => {
37
+ // const filePath = typeof path === "string" ? path : path.toString();
38
+
39
+ // // Naite.t(`fs/promises:rm`, { path: filePath, options });
40
+ // // 실제 삭제하지 않고 기록만 함
41
+ // return Promise.resolve();
42
+ // }),
43
+ };
44
+ });
@@ -0,0 +1,8 @@
1
+ /** biome-ignore-all lint/correctness/noUnusedImports: d.ts */
2
+ import type fastify from "fastify";
3
+
4
+ import type { UserSubsetSS } from "../application/sonamu.generated";
5
+
6
+ declare module "fastify" {
7
+ export interface PassportUser extends UserSubsetSS {}
8
+ }
@@ -0,0 +1,17 @@
1
+ /** biome-ignore-all lint/correctness/noUnusedImports: d.ts */
2
+
3
+ import {} from "sonamu";
4
+
5
+ declare module "sonamu" {
6
+ export interface ContextExtend {
7
+ ip: string;
8
+ }
9
+
10
+ export interface GuardKeys {
11
+ query: true;
12
+ user: true;
13
+ admin: true;
14
+ // 새로운 커스텀 가드키를 추가하는 경우
15
+ // CustomGuardKey: true
16
+ }
17
+ }
@@ -0,0 +1,11 @@
1
+ import type { SubsetQuery } from "sonamu";
2
+
3
+ export function getSubsetLoaders(subsets: string[], subsetQueries: Record<string, SubsetQuery>) {
4
+ return subsets.reduce(
5
+ (acc, subset) => {
6
+ acc[subset] = subsetQueries[subset]?.loaders ?? [];
7
+ return acc;
8
+ },
9
+ {} as Record<string, SubsetQuery["loaders"]>,
10
+ );
11
+ }
@@ -0,0 +1,6 @@
1
+ import { createFixtureLoader } from "sonamu/test";
2
+
3
+ export const loadFixtures = createFixtureLoader({
4
+ // Define your fixtures...
5
+ fixture01: async () => {},
6
+ });
@@ -0,0 +1,6 @@
1
+ import dotenv from "dotenv";
2
+
3
+ dotenv.config();
4
+
5
+ // sonamu.config.ts의 test 설정을 기반으로 병렬 테스트 환경을 구성합니다.
6
+ export { setup } from "sonamu/test";
@@ -0,0 +1,44 @@
1
+ import type { PathLike } from "fs";
2
+
3
+ // import { Naite } from "sonamu";
4
+ import { vi } from "vitest";
5
+
6
+ // GlobalMock: fs/promises (사용 예시 - 필요시 활성화)
7
+ vi.mock("fs/promises", async (importOriginal) => {
8
+ const actual = (await importOriginal()) as typeof import("fs/promises");
9
+ return {
10
+ ...actual,
11
+ access: vi.fn((path: PathLike, mode?: number) => {
12
+ // const vfs = Naite.get("mock:fs/promises:virtualFileSystem").result();
13
+ // if (vfs.some((v) => v === path)) {
14
+ // return Promise.resolve();
15
+ // }
16
+
17
+ return actual.access(path, mode);
18
+ }),
19
+ // mkdir: vi.fn(
20
+ // async (
21
+ // path: PathLike,
22
+ // options?: MakeDirectoryOptions | Mode | null,
23
+ // ): Promise<string | undefined> => {
24
+ // // Naite.t("fs:mkdir", { path, options });
25
+ // if (typeof options === "object" && options?.recursive) {
26
+ // return typeof path === "string" ? path : path.toString();
27
+ // }
28
+ // return undefined;
29
+ // },
30
+ // ),
31
+ // writeFile: vi.fn((path: PathLike | FileHandle, data: string | Buffer | Uint8Array) => {
32
+ // const filePath = typeof path === "string" ? path : path.toString();
33
+
34
+ // // Naite.t(`fs/promises:writeFile`, { path: filePath, data });
35
+ // }),
36
+ // rm: vi.fn(async (path: PathLike, options?: RmOptions) => {
37
+ // const filePath = typeof path === "string" ? path : path.toString();
38
+
39
+ // // Naite.t(`fs/promises:rm`, { path: filePath, options });
40
+ // // 실제 삭제하지 않고 기록만 함
41
+ // return Promise.resolve();
42
+ // }),
43
+ };
44
+ });
@@ -0,0 +1,8 @@
1
+ /** biome-ignore-all lint/correctness/noUnusedImports: d.ts */
2
+ import type fastify from "fastify";
3
+
4
+ import type { UserSubsetSS } from "../application/sonamu.generated";
5
+
6
+ declare module "fastify" {
7
+ export interface PassportUser extends UserSubsetSS {}
8
+ }
@@ -0,0 +1,17 @@
1
+ /** biome-ignore-all lint/correctness/noUnusedImports: d.ts */
2
+
3
+ import {} from "sonamu";
4
+
5
+ declare module "sonamu" {
6
+ export interface ContextExtend {
7
+ ip: string;
8
+ }
9
+
10
+ export interface GuardKeys {
11
+ query: true;
12
+ user: true;
13
+ admin: true;
14
+ // 새로운 커스텀 가드키를 추가하는 경우
15
+ // CustomGuardKey: true
16
+ }
17
+ }
@@ -0,0 +1,11 @@
1
+ import type { SubsetQuery } from "sonamu";
2
+
3
+ export function getSubsetLoaders(subsets: string[], subsetQueries: Record<string, SubsetQuery>) {
4
+ return subsets.reduce(
5
+ (acc, subset) => {
6
+ acc[subset] = subsetQueries[subset]?.loaders ?? [];
7
+ return acc;
8
+ },
9
+ {} as Record<string, SubsetQuery["loaders"]>,
10
+ );
11
+ }