miqro 6.0.14 → 6.1.1

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 (322) hide show
  1. package/README.md +12 -0
  2. package/build/editor.bundle.js +37 -50409
  3. package/build/esm/src/cluster.js +0 -1
  4. package/build/esm/src/common/arguments.d.ts +12 -0
  5. package/build/esm/src/common/arguments.js +111 -10
  6. package/build/esm/src/common/assets.js +2 -3
  7. package/build/esm/src/common/checksum.js +0 -1
  8. package/build/esm/src/common/constants.js +0 -1
  9. package/build/esm/src/common/content-type.js +0 -1
  10. package/build/esm/src/common/esbuild.js +0 -1
  11. package/build/esm/src/common/exit.js +0 -1
  12. package/build/esm/src/common/fs.js +0 -1
  13. package/build/esm/src/common/help.d.ts +1 -1
  14. package/build/esm/src/common/help.js +4 -1
  15. package/build/esm/src/common/jsx.d.ts +8 -1
  16. package/build/esm/src/common/jsx.js +84 -2
  17. package/build/esm/src/common/paths.d.ts +4 -0
  18. package/build/esm/src/common/paths.js +41 -2
  19. package/build/esm/src/common/watch.js +0 -1
  20. package/build/esm/src/inflate/inflate-sea.js +27 -16
  21. package/build/esm/src/inflate/inflate.js +2 -1
  22. package/build/esm/src/inflate/md.d.ts +1 -0
  23. package/build/esm/src/inflate/md.js +9 -6
  24. package/build/esm/src/inflate/setup-auth.js +0 -1
  25. package/build/esm/src/inflate/setup-cors.js +0 -1
  26. package/build/esm/src/inflate/setup-db.js +0 -1
  27. package/build/esm/src/inflate/setup-error.d.ts +3 -0
  28. package/build/esm/src/inflate/setup-error.js +40 -0
  29. package/build/esm/src/inflate/setup-http.js +13 -4
  30. package/build/esm/src/inflate/setup-log.js +0 -1
  31. package/build/esm/src/inflate/setup-middleware.d.ts +4 -0
  32. package/build/esm/src/inflate/setup-middleware.js +42 -0
  33. package/build/esm/src/inflate/setup-server-config.js +0 -1
  34. package/build/esm/src/inflate/setup-test.js +0 -1
  35. package/build/esm/src/inflate/setup-ws.js +0 -1
  36. package/build/esm/src/inflate/setup.doc.d.ts +4 -0
  37. package/build/esm/src/inflate/setup.doc.js +62 -0
  38. package/build/esm/src/inflate/utils/sea-utils.js +0 -1
  39. package/build/esm/src/lib.js +0 -1
  40. package/build/esm/src/main.js +3 -4
  41. package/build/esm/src/services/app.d.ts +1 -0
  42. package/build/esm/src/services/app.js +18 -2
  43. package/build/esm/src/services/editor.js +0 -1
  44. package/build/esm/src/services/globals.js +0 -1
  45. package/build/esm/src/services/hot-reload.js +0 -1
  46. package/build/esm/src/services/migrations.js +0 -1
  47. package/build/esm/src/services/utils/admin-interface.js +0 -1
  48. package/build/esm/src/services/utils/cache.js +0 -1
  49. package/build/esm/src/services/utils/cluster-cache.js +0 -1
  50. package/build/esm/src/services/utils/cluster-ws.js +0 -1
  51. package/build/esm/src/services/utils/db-manager.js +0 -1
  52. package/build/esm/src/services/utils/get-route.js +0 -1
  53. package/build/esm/src/services/utils/log-transport.js +0 -1
  54. package/build/esm/src/services/utils/log.js +2 -2
  55. package/build/esm/src/services/utils/server-interface.js +0 -1
  56. package/build/esm/src/services/utils/websocketmanager.js +0 -1
  57. package/build/esm/src/types.d.ts +16 -1
  58. package/build/esm/src/types.js +0 -1
  59. package/build/lib.cjs +890 -322
  60. package/package.json +4 -2
  61. package/sea/types.json +1 -1
  62. package/tsconfig.json +1 -1
  63. package/bin/miqro +0 -34
  64. package/build/esm/editor/auth.d.ts +0 -6
  65. package/build/esm/editor/auth.js +0 -42
  66. package/build/esm/editor/auth.js.map +0 -1
  67. package/build/esm/editor/common/admin-interface.d.ts +0 -36
  68. package/build/esm/editor/common/admin-interface.js +0 -45
  69. package/build/esm/editor/common/admin-interface.js.map +0 -1
  70. package/build/esm/editor/common/constants.d.ts +0 -4
  71. package/build/esm/editor/common/constants.js +0 -21
  72. package/build/esm/editor/common/constants.js.map +0 -1
  73. package/build/esm/editor/common/constants.server.d.ts +0 -2
  74. package/build/esm/editor/common/constants.server.js +0 -5
  75. package/build/esm/editor/common/constants.server.js.map +0 -1
  76. package/build/esm/editor/common/editor-index.d.ts +0 -2
  77. package/build/esm/editor/common/editor-index.js +0 -15
  78. package/build/esm/editor/common/editor-index.js.map +0 -1
  79. package/build/esm/editor/common/html-encode.d.ts +0 -1
  80. package/build/esm/editor/common/html-encode.js +0 -15
  81. package/build/esm/editor/common/html-encode.js.map +0 -1
  82. package/build/esm/editor/common/log-socket.d.ts +0 -15
  83. package/build/esm/editor/common/log-socket.js +0 -71
  84. package/build/esm/editor/common/log-socket.js.map +0 -1
  85. package/build/esm/editor/common/templates.d.ts +0 -11
  86. package/build/esm/editor/common/templates.js +0 -444
  87. package/build/esm/editor/common/templates.js.map +0 -1
  88. package/build/esm/editor/components/api-preview.d.ts +0 -11
  89. package/build/esm/editor/components/api-preview.js +0 -91
  90. package/build/esm/editor/components/api-preview.js.map +0 -1
  91. package/build/esm/editor/components/editor.d.ts +0 -16
  92. package/build/esm/editor/components/editor.js +0 -358
  93. package/build/esm/editor/components/editor.js.map +0 -1
  94. package/build/esm/editor/components/file-browser.d.ts +0 -37
  95. package/build/esm/editor/components/file-browser.js +0 -127
  96. package/build/esm/editor/components/file-browser.js.map +0 -1
  97. package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
  98. package/build/esm/editor/components/file-editor-toolbar.js +0 -94
  99. package/build/esm/editor/components/file-editor-toolbar.js.map +0 -1
  100. package/build/esm/editor/components/file-editor.d.ts +0 -32
  101. package/build/esm/editor/components/file-editor.js +0 -60
  102. package/build/esm/editor/components/file-editor.js.map +0 -1
  103. package/build/esm/editor/components/filter-query.d.ts +0 -1
  104. package/build/esm/editor/components/filter-query.js +0 -23
  105. package/build/esm/editor/components/filter-query.js.map +0 -1
  106. package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
  107. package/build/esm/editor/components/highlight-text-area.js +0 -139
  108. package/build/esm/editor/components/highlight-text-area.js.map +0 -1
  109. package/build/esm/editor/components/log-viewer.d.ts +0 -6
  110. package/build/esm/editor/components/log-viewer.js +0 -70
  111. package/build/esm/editor/components/log-viewer.js.map +0 -1
  112. package/build/esm/editor/components/new-file.d.ts +0 -10
  113. package/build/esm/editor/components/new-file.js +0 -118
  114. package/build/esm/editor/components/new-file.js.map +0 -1
  115. package/build/esm/editor/components/scroll-query.d.ts +0 -7
  116. package/build/esm/editor/components/scroll-query.js +0 -22
  117. package/build/esm/editor/components/scroll-query.js.map +0 -1
  118. package/build/esm/editor/components/start-page.d.ts +0 -13
  119. package/build/esm/editor/components/start-page.js +0 -31
  120. package/build/esm/editor/components/start-page.js.map +0 -1
  121. package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -3
  122. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -30
  123. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js.map +0 -1
  124. package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -5
  125. package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -50
  126. package/build/esm/editor/http/admin/editor/api/fs/read.api.js.map +0 -1
  127. package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -4
  128. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -40
  129. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js.map +0 -1
  130. package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
  131. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -150
  132. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js.map +0 -1
  133. package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
  134. package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -39
  135. package/build/esm/editor/http/admin/editor/api/fs/write.api.js.map +0 -1
  136. package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
  137. package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -47
  138. package/build/esm/editor/http/admin/editor/api/server/reload.api.js.map +0 -1
  139. package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
  140. package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -46
  141. package/build/esm/editor/http/admin/editor/api/server/restart.api.js.map +0 -1
  142. package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
  143. package/build/esm/editor/http/admin/editor/editor.js +0 -8
  144. package/build/esm/editor/http/admin/editor/editor.js.map +0 -1
  145. package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
  146. package/build/esm/editor/http/admin/editor/index.api.js +0 -22
  147. package/build/esm/editor/http/admin/editor/index.api.js.map +0 -1
  148. package/build/esm/editor/server.d.ts +0 -3
  149. package/build/esm/editor/server.js +0 -50
  150. package/build/esm/editor/server.js.map +0 -1
  151. package/build/esm/editor/ws.d.ts +0 -3
  152. package/build/esm/editor/ws.js +0 -12
  153. package/build/esm/editor/ws.js.map +0 -1
  154. package/build/esm/src/bin/compile.d.ts +0 -3
  155. package/build/esm/src/bin/compile.js +0 -31
  156. package/build/esm/src/bin/compile.js.map +0 -1
  157. package/build/esm/src/bin/doc-md.d.ts +0 -17
  158. package/build/esm/src/bin/doc-md.js +0 -187
  159. package/build/esm/src/bin/doc-md.js.map +0 -1
  160. package/build/esm/src/bin/generate-doc.d.ts +0 -4
  161. package/build/esm/src/bin/generate-doc.js +0 -49
  162. package/build/esm/src/bin/generate-doc.js.map +0 -1
  163. package/build/esm/src/bin/test.d.ts +0 -3
  164. package/build/esm/src/bin/test.js +0 -68
  165. package/build/esm/src/bin/test.js.map +0 -1
  166. package/build/esm/src/bin/types.d.ts +0 -3
  167. package/build/esm/src/bin/types.js +0 -21
  168. package/build/esm/src/bin/types.js.map +0 -1
  169. package/build/esm/src/cluster.js.map +0 -1
  170. package/build/esm/src/common/arguments.js.map +0 -1
  171. package/build/esm/src/common/assets.js.map +0 -1
  172. package/build/esm/src/common/checksum.js.map +0 -1
  173. package/build/esm/src/common/constants.js.map +0 -1
  174. package/build/esm/src/common/content-type.js.map +0 -1
  175. package/build/esm/src/common/esbuild.js.map +0 -1
  176. package/build/esm/src/common/exit.js.map +0 -1
  177. package/build/esm/src/common/fs.js.map +0 -1
  178. package/build/esm/src/common/help.js.map +0 -1
  179. package/build/esm/src/common/jsx.js.map +0 -1
  180. package/build/esm/src/common/paths.js.map +0 -1
  181. package/build/esm/src/common/watch.js.map +0 -1
  182. package/build/esm/src/inflate/inflate-sea.js.map +0 -1
  183. package/build/esm/src/inflate/inflate.js.map +0 -1
  184. package/build/esm/src/inflate/md.js.map +0 -1
  185. package/build/esm/src/inflate/setup-auth.js.map +0 -1
  186. package/build/esm/src/inflate/setup-cors.js.map +0 -1
  187. package/build/esm/src/inflate/setup-db.js.map +0 -1
  188. package/build/esm/src/inflate/setup-http.js.map +0 -1
  189. package/build/esm/src/inflate/setup-log.js.map +0 -1
  190. package/build/esm/src/inflate/setup-server-config.js.map +0 -1
  191. package/build/esm/src/inflate/setup-test.js.map +0 -1
  192. package/build/esm/src/inflate/setup-ws.js.map +0 -1
  193. package/build/esm/src/inflate/utils/sea-utils.js.map +0 -1
  194. package/build/esm/src/lib.js.map +0 -1
  195. package/build/esm/src/main.js.map +0 -1
  196. package/build/esm/src/services/app.js.map +0 -1
  197. package/build/esm/src/services/editor.js.map +0 -1
  198. package/build/esm/src/services/globals.js.map +0 -1
  199. package/build/esm/src/services/hot-reload.js.map +0 -1
  200. package/build/esm/src/services/migrations.js.map +0 -1
  201. package/build/esm/src/services/utils/admin-interface.js.map +0 -1
  202. package/build/esm/src/services/utils/cache.js.map +0 -1
  203. package/build/esm/src/services/utils/cluster-cache.js.map +0 -1
  204. package/build/esm/src/services/utils/cluster-ws.js.map +0 -1
  205. package/build/esm/src/services/utils/db-manager.js.map +0 -1
  206. package/build/esm/src/services/utils/get-route.js.map +0 -1
  207. package/build/esm/src/services/utils/log-transport.js.map +0 -1
  208. package/build/esm/src/services/utils/log.js.map +0 -1
  209. package/build/esm/src/services/utils/server-interface.js.map +0 -1
  210. package/build/esm/src/services/utils/websocketmanager.js.map +0 -1
  211. package/build/esm/src/types.js.map +0 -1
  212. package/editor/auth.ts +0 -51
  213. package/editor/common/admin-interface.ts +0 -84
  214. package/editor/common/constants.server.ts +0 -5
  215. package/editor/common/constants.ts +0 -21
  216. package/editor/common/editor-index.tsx +0 -17
  217. package/editor/common/html-encode.ts +0 -14
  218. package/editor/common/log-socket.tsx +0 -85
  219. package/editor/common/templates.ts +0 -448
  220. package/editor/components/api-preview.tsx +0 -116
  221. package/editor/components/editor.tsx +0 -486
  222. package/editor/components/file-browser.tsx +0 -308
  223. package/editor/components/file-editor-toolbar.tsx +0 -191
  224. package/editor/components/file-editor.tsx +0 -122
  225. package/editor/components/filter-query.tsx +0 -22
  226. package/editor/components/highlight-text-area.tsx +0 -159
  227. package/editor/components/log-viewer.tsx +0 -110
  228. package/editor/components/new-file.tsx +0 -169
  229. package/editor/components/scroll-query.tsx +0 -22
  230. package/editor/components/start-page.tsx +0 -49
  231. package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
  232. package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
  233. package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
  234. package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
  235. package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
  236. package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
  237. package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
  238. package/editor/http/admin/editor/editor.tsx +0 -8
  239. package/editor/http/admin/editor/index.api.tsx +0 -39
  240. package/editor/server.ts +0 -57
  241. package/editor/static/android-chrome-192x192.png +0 -0
  242. package/editor/static/android-chrome-512x512.png +0 -0
  243. package/editor/static/apple-touch-icon.png +0 -0
  244. package/editor/static/editor.bundle.in.mjs +0 -20
  245. package/editor/static/favicon-16x16.png +0 -0
  246. package/editor/static/favicon-32x32.png +0 -0
  247. package/editor/static/favicon.ico +0 -0
  248. package/editor/static/site.webmanifest +0 -19
  249. package/editor/ws.ts +0 -15
  250. package/sea/base64.js +0 -3
  251. package/sea/compile.sh +0 -127
  252. package/sea/copy-types.sh +0 -46
  253. package/sea/editor-assets/editor.bundle.in.mjs +0 -19
  254. package/sea/generate-global-types-asset-json.js +0 -34
  255. package/sea/release-tar.sh +0 -5
  256. package/sea/tsc.sh +0 -1
  257. package/sea/version.tag.js +0 -11
  258. package/src/bin/compile.ts +0 -35
  259. package/src/bin/doc-md.ts +0 -210
  260. package/src/bin/generate-doc.ts +0 -58
  261. package/src/bin/test.ts +0 -92
  262. package/src/bin/types.ts +0 -22
  263. package/src/cluster.ts +0 -27
  264. package/src/common/arguments.ts +0 -382
  265. package/src/common/assets.ts +0 -128
  266. package/src/common/checksum.ts +0 -58
  267. package/src/common/constants.ts +0 -18
  268. package/src/common/content-type.ts +0 -84
  269. package/src/common/esbuild.ts +0 -94
  270. package/src/common/exit.ts +0 -91
  271. package/src/common/fs.ts +0 -17
  272. package/src/common/help.ts +0 -47
  273. package/src/common/jsx.ts +0 -426
  274. package/src/common/paths.ts +0 -117
  275. package/src/common/watch.ts +0 -85
  276. package/src/inflate/inflate-sea.ts +0 -194
  277. package/src/inflate/inflate.ts +0 -96
  278. package/src/inflate/md.ts +0 -20
  279. package/src/inflate/setup-auth.ts +0 -40
  280. package/src/inflate/setup-cors.ts +0 -40
  281. package/src/inflate/setup-db.ts +0 -113
  282. package/src/inflate/setup-http.ts +0 -643
  283. package/src/inflate/setup-log.ts +0 -44
  284. package/src/inflate/setup-server-config.ts +0 -47
  285. package/src/inflate/setup-test.ts +0 -23
  286. package/src/inflate/setup-ws.ts +0 -48
  287. package/src/inflate/utils/sea-utils.ts +0 -14
  288. package/src/lib.ts +0 -19
  289. package/src/main.ts +0 -87
  290. package/src/services/app.ts +0 -640
  291. package/src/services/editor.tsx +0 -101
  292. package/src/services/globals.ts +0 -143
  293. package/src/services/hot-reload.ts +0 -48
  294. package/src/services/migrations.ts +0 -66
  295. package/src/services/utils/admin-interface.ts +0 -37
  296. package/src/services/utils/cache.ts +0 -88
  297. package/src/services/utils/cluster-cache.ts +0 -230
  298. package/src/services/utils/cluster-ws.ts +0 -197
  299. package/src/services/utils/db-manager.ts +0 -92
  300. package/src/services/utils/get-route.ts +0 -70
  301. package/src/services/utils/log-transport.ts +0 -75
  302. package/src/services/utils/log.ts +0 -91
  303. package/src/services/utils/server-interface.ts +0 -172
  304. package/src/services/utils/websocketmanager.ts +0 -149
  305. package/src/types/@esbuild.d.ts +0 -1
  306. package/src/types/@miqro/core.d.ts +0 -2
  307. package/src/types/@miqro/jsx.d.ts +0 -2
  308. package/src/types/@miqro/parser.d.ts +0 -2
  309. package/src/types/@miqro/query.d.ts +0 -2
  310. package/src/types/@miqro/request.d.ts +0 -2
  311. package/src/types/@miqro/test.d.ts +0 -2
  312. package/src/types/@miqro.d.ts +0 -1
  313. package/src/types/@types.d.ts +0 -1
  314. package/src/types/browser.globals.d.ts +0 -9
  315. package/src/types/globals.d.ts +0 -2
  316. package/src/types/jsx.globals.d.ts +0 -37
  317. package/src/types/miqro.d.ts +0 -111
  318. package/src/types/postject.d.ts +0 -1
  319. package/src/types/server.globals.d.ts +0 -72
  320. package/src/types.ts +0 -204
  321. /package/{editor/http/admin/editor → build}/font.ttf +0 -0
  322. /package/{editor/http/admin/editor → build}/style.css +0 -0
@@ -18,4 +18,3 @@ else {
18
18
  console.log(CMD);
19
19
  execSync(CMD, { stdio: 'inherit' });
20
20
  }
21
- //# sourceMappingURL=cluster.js.map
@@ -1,11 +1,22 @@
1
+ interface MiqroJSON {
2
+ services?: string[];
3
+ port?: string | number;
4
+ inflateDir?: string;
5
+ name?: string;
6
+ }
7
+ export declare function importMiqroJSON(inFile: string): MiqroJSON;
1
8
  export declare function getPORT(): string;
2
9
  export interface Arguments {
10
+ name: string;
3
11
  installTypes: boolean;
4
12
  installTSConfig: boolean;
5
13
  test: boolean;
14
+ port: string;
6
15
  inflate: boolean;
7
16
  generateDoc: boolean;
8
17
  generateDocOut: string;
18
+ miqroJSONPath: string | false;
19
+ disableMiqroJSON: boolean;
9
20
  generateDocAll: boolean;
10
21
  generateDocType: "JSON" | "MD";
11
22
  migrateUp: boolean;
@@ -21,3 +32,4 @@ export interface Arguments {
21
32
  * parse process.argv arguments
22
33
  */
23
34
  export declare function parseArguments(): Arguments;
35
+ export {};
@@ -1,15 +1,36 @@
1
1
  import { checkEnvVariable } from "@miqro/core";
2
2
  import { existsSync, readFileSync, statSync } from "node:fs";
3
- import { resolve } from "node:path";
3
+ import { basename, dirname, join, relative, resolve } from "node:path";
4
4
  import { cwd, env, platform, arch } from "node:process";
5
5
  import { EXIT_CODES } from "./constants.js";
6
6
  import { tmpdir } from "node:os";
7
7
  import { randomUUID } from "node:crypto";
8
8
  import { BIN_NAME, help, usage } from "./help.js";
9
- import { TEST_SOCKET } from "./paths.js";
9
+ import { getMiqroJSONPath, TEST_SOCKET } from "./paths.js";
10
10
  import { isSea } from "node:sea";
11
11
  import cluster from "node:cluster";
12
12
  import { __package_dirname, getVersion } from "./assets.js";
13
+ import { Parser } from "@miqro/parser";
14
+ const parser = new Parser();
15
+ const MiqroJSONSchema = {
16
+ type: "object",
17
+ properties: {
18
+ name: "string?",
19
+ services: "string[]?",
20
+ port: "number?|string?",
21
+ inflateDir: "string?"
22
+ }
23
+ };
24
+ export function importMiqroJSON(inFile) {
25
+ const mod = JSON.parse(readFileSync(inFile).toString());
26
+ const module = parser.parse(mod, MiqroJSONSchema, basename(inFile));
27
+ if (module !== undefined) {
28
+ return module;
29
+ }
30
+ else {
31
+ throw new Error(`error loading [${inFile}] undefined`);
32
+ }
33
+ }
13
34
  export function getPORT() {
14
35
  return checkEnvVariable("PORT", "8080");
15
36
  }
@@ -20,8 +41,12 @@ export function parseArguments() {
20
41
  //env["LOG_FILE"] = env["LOG_FILE"] ? env["LOG_FILE"] : "./server.log";
21
42
  const args = cluster.isPrimary ? process.argv.slice(2, process.argv.length) : process.argv.slice(3, process.argv.length);
22
43
  const flags = {
44
+ name: null,
23
45
  hotreload: null,
46
+ miqroJSONPath: null,
47
+ disableMiqroJSON: null,
24
48
  installTypes: null,
49
+ port: null,
25
50
  installTSConfig: null,
26
51
  migrateUp: null,
27
52
  migrateDown: null,
@@ -60,6 +85,29 @@ export function parseArguments() {
60
85
  console.log(usage);
61
86
  console.log(help);
62
87
  process.exit(EXIT_CODES.NORMAL_EXIT);
88
+ case "--disable-miqrojson":
89
+ if (flags.disableMiqroJSON !== null || flags.miqroJSONPath !== null) {
90
+ console.error("bad arguments.");
91
+ console.error(usage);
92
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
93
+ }
94
+ flags.disableMiqroJSON = true;
95
+ continue;
96
+ case "--config":
97
+ if (flags.miqroJSONPath !== null || flags.disableMiqroJSON !== null) {
98
+ console.error("bad arguments.");
99
+ console.error(usage);
100
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
101
+ }
102
+ const cPath = String(args[i + 1]).toUpperCase();
103
+ if (typeof cPath !== "string") {
104
+ console.error("bad arguments. --config must be a string.");
105
+ console.error(usage);
106
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
107
+ }
108
+ flags.miqroJSONPath = cPath;
109
+ i++;
110
+ continue;
63
111
  case "--install-tsconfig":
64
112
  if (flags.inflate !== null || flags.installTSConfig !== null) {
65
113
  console.error("bad arguments.");
@@ -76,6 +124,36 @@ export function parseArguments() {
76
124
  }
77
125
  flags.hotreload = true;
78
126
  continue;
127
+ case "--port":
128
+ if (flags.port !== null) {
129
+ console.error("bad arguments.");
130
+ console.error(usage);
131
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
132
+ }
133
+ const cPort = String(args[i + 1]).toUpperCase();
134
+ if (typeof cPort !== "string") {
135
+ console.error("bad arguments. --port must be a string.");
136
+ console.error(usage);
137
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
138
+ }
139
+ flags.port = cPort;
140
+ i++;
141
+ continue;
142
+ case "--name":
143
+ if (flags.name !== null) {
144
+ console.error("bad arguments.");
145
+ console.error(usage);
146
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
147
+ }
148
+ const cName = String(args[i + 1]).toUpperCase();
149
+ if (typeof cName !== "string") {
150
+ console.error("bad arguments. --port must be a string.");
151
+ console.error(usage);
152
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
153
+ }
154
+ flags.name = cName;
155
+ i++;
156
+ continue;
79
157
  case "--generate-doc":
80
158
  if (flags.generateDoc !== null) {
81
159
  console.error("bad arguments.");
@@ -164,7 +242,6 @@ export function parseArguments() {
164
242
  console.error(usage);
165
243
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
166
244
  }
167
- env["HOT_RELOAD"] = env["HOT_RELOAD"] ? env["HOT_RELOAD"] : "0";
168
245
  flags.migrateUp = true;
169
246
  continue;
170
247
  case "--migrate-down":
@@ -173,7 +250,6 @@ export function parseArguments() {
173
250
  console.error(usage);
174
251
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
175
252
  }
176
- env["HOT_RELOAD"] = env["HOT_RELOAD"] ? env["HOT_RELOAD"] : "0";
177
253
  flags.migrateDown = true;
178
254
  continue;
179
255
  case "--inflate":
@@ -182,7 +258,6 @@ export function parseArguments() {
182
258
  console.error(usage);
183
259
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
184
260
  }
185
- env["HOT_RELOAD"] = env["HOT_RELOAD"] ? env["HOT_RELOAD"] : "0";
186
261
  flags.inflate = true;
187
262
  continue;
188
263
  case "--test":
@@ -191,7 +266,6 @@ export function parseArguments() {
191
266
  console.error(usage);
192
267
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
193
268
  }
194
- env["HOT_RELOAD"] = env["HOT_RELOAD"] ? env["HOT_RELOAD"] : "0";
195
269
  env["BROWSER"] = env["BROWSER"] ? env["BROWSER"] : "none";
196
270
  env["PORT"] = TEST_SOCKET;
197
271
  flags.test = true;
@@ -233,13 +307,37 @@ export function parseArguments() {
233
307
  continue;*/
234
308
  }
235
309
  }
236
- if (process.env["CLUSTER_NODE_NUMBER"]) {
237
- env["HOT_RELOAD"] = env["HOT_RELOAD"] ? env["HOT_RELOAD"] : "0";
238
- }
239
310
  flags.inflate = flags.inflate ? flags.inflate : false;
240
311
  flags.editor = flags.editor ? flags.editor : false;
241
312
  flags.test = flags.test ? flags.test : false;
242
313
  flags.inflateDir = flags.inflateDir ? flags.inflateDir : undefined;
314
+ const miqroJSONPath = !flags.disableMiqroJSON ? flags.miqroJSONPath ? resolve(flags.miqroJSONPath) : getMiqroJSONPath() : false;
315
+ const miqroRC = miqroJSONPath ? importMiqroJSON(miqroJSONPath) : {};
316
+ // try to load .miqrorc
317
+ if (!flags.disableMiqroJSON && miqroJSONPath) {
318
+ if (services.length === 0) {
319
+ if (miqroRC.services) {
320
+ for (const service of miqroRC.services) {
321
+ services.push(join(relative(cwd(), dirname(miqroJSONPath)), service));
322
+ }
323
+ }
324
+ }
325
+ if (!flags.port) {
326
+ if (miqroRC.port) {
327
+ flags.port = String(miqroRC.port);
328
+ }
329
+ }
330
+ if (!flags.inflateDir && flags.inflate) {
331
+ if (miqroRC.inflateDir) {
332
+ flags.inflateDir = miqroRC.inflateDir;
333
+ }
334
+ }
335
+ if (!flags.name) {
336
+ if (miqroRC.name) {
337
+ flags.name = miqroRC.name;
338
+ }
339
+ }
340
+ }
243
341
  if (services.length === 0 && (!flags.installTSConfig && !flags.installTypes)) {
244
342
  flags.inflateDir = flags.inflateDir ? flags.inflateDir : undefined;
245
343
  console.error(`bad arguments. missing --service argument`);
@@ -304,11 +402,15 @@ export function parseArguments() {
304
402
  }
305
403
  const generateDocType = flags.generateDocType ? flags.generateDocType : "MD";
306
404
  return {
405
+ name: flags.name ? flags.name : undefined,
307
406
  generateDocAll: flags.generateDocAll ? true : false,
308
407
  hotreload: flags.hotreload ? true : false,
408
+ disableMiqroJSON: flags.disableMiqroJSON !== null ? flags.disableMiqroJSON : false,
409
+ miqroJSONPath: miqroJSONPath ? miqroJSONPath : false,
309
410
  installTypes: flags.installTypes ? true : false,
310
411
  installTSConfig: flags.installTSConfig ? true : false,
311
412
  inflate: flags.inflate,
413
+ port: flags.port ? flags.port : getPORT(),
312
414
  migrateUp: flags.migrateUp ? true : false,
313
415
  migrateDown: flags.migrateDown ? true : false,
314
416
  test: flags.test ? true : false,
@@ -322,4 +424,3 @@ export function parseArguments() {
322
424
  editor: flags.editor ? true : false
323
425
  };
324
426
  }
325
- //# sourceMappingURL=arguments.js.map
@@ -24,8 +24,8 @@ const ASSETS_ROUTER = {
24
24
  "jsx.dom.js": "build/jsx.dom.js",
25
25
  "types.json": "sea/types.json",
26
26
  "editor-assets/editor.bundle.js": "build/editor.bundle.js",
27
- "editor-assets/style.css": "editor/http/admin/editor/style.css",
28
- "editor-assets/font.ttf": "editor/http/admin/editor/font.ttf"
27
+ "editor-assets/style.css": "build/style.css",
28
+ "editor-assets/font.ttf": "build/font.ttf"
29
29
  };
30
30
  export function getAsset(key) {
31
31
  if (isSea()) {
@@ -121,4 +121,3 @@ export async function initAsset(logger, path, buffer, executable, checksum, logI
121
121
  }
122
122
  }
123
123
  }
124
- //# sourceMappingURL=assets.js.map
@@ -54,4 +54,3 @@ export async function calculateChecksumFromBuffer(buffer) {
54
54
  }
55
55
  });
56
56
  }
57
- //# sourceMappingURL=checksum.js.map
@@ -11,4 +11,3 @@ export const EDITOR_CONFIG_KEY = "$$editor$$";
11
11
  export const HOT_RELOAD_PATH = "/hot-reload";
12
12
  //export const SERVER_IDENTIFIER = cluster.isPrimary ? "SERVER" : process.env["CLUSTER_NODE_NUMBER"] ? `WORKER_${process.env["CLUSTER_NODE_NUMBER"]}` : "WORKER";
13
13
  //export const DB_IDENTIFIER = cluster.isPrimary ? "DATABASE" : process.env["CLUSTER_NODE_NUMBER"] ? `WORKER_${process.env["CLUSTER_NODE_NUMBER"]}_DATABASE` : "WORKER_DATABASE";
14
- //# sourceMappingURL=constants.js.map
@@ -79,4 +79,3 @@ export const CONTENT_TYPE_MAP = {
79
79
  ".3g2": "video/3gpp2; audio/3gpp2",
80
80
  ".7z": "application/x-7z-compressed"
81
81
  };
82
- //# sourceMappingURL=content-type.js.map
@@ -76,4 +76,3 @@ export async function esBuild(options, logger) {
76
76
  }
77
77
  });
78
78
  }
79
- //# sourceMappingURL=esbuild.js.map
@@ -81,4 +81,3 @@ export function setupExitHandlers(app) {
81
81
  process.exit(EXIT_CODES.ABNORMAL_UNCONTROLLED);
82
82
  });
83
83
  }
84
- //# sourceMappingURL=exit.js.map
@@ -14,4 +14,3 @@ export function describeFilePath(filePath) {
14
14
  filePath
15
15
  };
16
16
  }
17
- //# sourceMappingURL=fs.js.map
@@ -1,3 +1,3 @@
1
1
  export declare const BIN_NAME = "miqro";
2
2
  export declare const usage = "usage: miqro [...FLAGS] --service app/\n\n==examples==\n\nmiqro --watch --service front/\nPORT=8181 miqro --service api/ --service front/\nmiqro --test --service front/\nmiqro --inflate --service front/\nmiqro --generate-doc --generate-doc-out API.md --service front/\nCLUSTER_COUNT=10 miqro-cluster --service api/";
3
- export declare const help = "\n==flags==\n\n-v, --version\t\toutputs the version number\n-h, --help\t\toutputs this page.\n--watch\t\t\tuse to enable the hot-reload functionality.\n--test\t\t\trun the tests for a service.\n--migrate-up\t\tmigrations up.\n--migrate-down\t\tmigrations down.\n--inflate\t\tinflates the application.\n--inflate-dir\t\tto set the output directory of the --inflate command. default value is inflated/.\n--editor\t\truns the application with a built-in editor.\n--generate-doc\t\tgenerates a documentation for the api endpoints of the service.\n--generate-doc-out\tthe output file for the generated documentation. default value is API.md.\n--generate-doc-type\tthe format of the generated documentation. it can be JSON or MD. default value is MD.\n--generate-doc-all\toutputs all the server routes in the documentation output.\n--compile\t\tinflates the application and tries to create a NODE SEA binary.\n--inflate-sea\t\tinflates the application with sea compilation scripts.\n--install-tsconfig\tcreates a tsconfig.json configured to use with --install-types.\n--install-types\t\tcreates and updates the .types/ folder use together with --install-tsconfig.\n\n==environment variables==\n\nPORT\t\t\toverride the default 8080 port.\nLOG_FILE\t\toverride the default ./server.log file\nDB\t\t\tenable the server.db features\nDB_STORAGE\t\toverride the default local db location ./db.sqlite3\nDB_DIALECT\t\toverride the default node:sqlite\nDB_CONNECTION\t\toverride the default connection url\nCLEAR_JSX_CACHE\t\tset to 1 or 0 to enable or disable the clearing of the esbuild cache defaults to 1.\nJSX_TMP\t\t\tset custom location of esbuild builds defaults to /tmp/jsx_tmp.\n";
3
+ export declare const help = "\n==flags==\n\n-v, --version\t\toutputs the version number\n-h, --help\t\toutputs this page.\n--watch\t\t\tuse to enable the hot-reload functionality.\n--test\t\t\trun the tests for a service.\n--migrate-up\t\tmigrations up.\n--migrate-down\t\tmigrations down.\n--inflate\t\tinflates the application.\n--inflate-dir\t\tto set the output directory of the --inflate command. default value is inflated/.\n--editor\t\truns the application with a built-in editor.\n--generate-doc\t\tgenerates a documentation for the api endpoints of the service.\n--generate-doc-out\tthe output file for the generated documentation. default value is API.md.\n--generate-doc-type\tthe format of the generated documentation. it can be JSON or MD. default value is MD.\n--generate-doc-all\toutputs all the server routes in the documentation output.\n--compile\t\tinflates the application and tries to create a NODE SEA binary.\n--inflate-sea\t\tinflates the application with sea compilation scripts.\n--install-tsconfig\tcreates a tsconfig.json configured to use with --install-types.\n--install-types\t\tcreates and updates the .types/ folder use together with --install-tsconfig.\n--disable-miqrojson\tdisables the load of miqro.json file.\n--config\toverrides the default miqro.json path with a new one.\n--port\toverrides the default port loading from environment variables.\n--name\toverrides the default name of the server.\n\n==environment variables==\n\nPORT\t\t\toverride the default 8080 port.\nLOG_FILE\t\toverride the default ./server.log file\nDB\t\t\tenable the server.db features\nDB_STORAGE\t\toverride the default local db location ./db.sqlite3\nDB_DIALECT\t\toverride the default node:sqlite\nDB_CONNECTION\t\toverride the default connection url\nCLEAR_JSX_CACHE\t\tset to 1 or 0 to enable or disable the clearing of the esbuild cache defaults to 1.\nJSX_TMP\t\t\tset custom location of esbuild builds defaults to /tmp/jsx_tmp.\n";
@@ -30,6 +30,10 @@ export const help = `
30
30
  --inflate-sea\t\tinflates the application with sea compilation scripts.
31
31
  --install-tsconfig\tcreates a tsconfig.json configured to use with --install-types.
32
32
  --install-types\t\tcreates and updates the .types/ folder use together with --install-tsconfig.
33
+ --disable-miqrojson\tdisables the load of miqro.json file.
34
+ --config\toverrides the default miqro.json path with a new one.
35
+ --port\toverrides the default port loading from environment variables.
36
+ --name\toverrides the default name of the server.
33
37
 
34
38
  ==environment variables==
35
39
 
@@ -42,4 +46,3 @@ DB_CONNECTION\t\toverride the default connection url
42
46
  CLEAR_JSX_CACHE\t\tset to 1 or 0 to enable or disable the clearing of the esbuild cache defaults to 1.
43
47
  JSX_TMP\t\t\tset custom location of esbuild builds defaults to /tmp/jsx_tmp.
44
48
  `;
45
- //# sourceMappingURL=help.js.map
@@ -1,7 +1,7 @@
1
1
  import { Runtime } from "@miqro/jsx";
2
2
  import { Request, Response, CORSOptions, Logger, APIRoute } from "@miqro/core";
3
3
  import { Schema } from "@miqro/parser";
4
- import { APIOptions, ServerConfig, WSConfig, AuthConfig, DBConfig, LogConfig } from "../types.js";
4
+ import { APIOptions, ServerConfig, WSConfig, AuthConfig, DBConfig, LogConfig, MiddlewareConfig, ErrorConfig, DocConfig } from "../types.js";
5
5
  import { Migration } from "@miqro/query";
6
6
  export declare function initJSXJS(logger: Logger): Promise<void>;
7
7
  export declare function validateJSXJS(logger: Logger): Promise<boolean>;
@@ -38,11 +38,18 @@ export declare const DBConfigSchema: Schema<DBConfig>;
38
38
  export declare const ServerConfigSchema: Schema<ServerConfig>;
39
39
  export declare const LogConfigSchema: Schema<LogConfig>;
40
40
  export declare const AuthConfigSchema: Schema<AuthConfig>;
41
+ export declare const MiddlewareConfigSchema: Schema<MiddlewareConfig>;
42
+ export declare const ErrorConfigSchema: Schema<ErrorConfig>;
43
+ export declare const DocConfigSchema: Schema<DocConfig>;
41
44
  export declare function importAPIRoute(inFile: string, logger?: Logger): Promise<APIRoute>;
42
45
  export declare function importMigrationModule(inFile: string, logger?: Logger): Promise<Migration>;
43
46
  export declare function importHTMLModule(inFile: string, logger?: Logger): Promise<any>;
44
47
  export declare function importJSONModule(inFile: string, logger?: Logger): Promise<any>;
45
48
  export declare function importAuthModule(inFile: string, logger?: Logger): Promise<AuthConfig>;
49
+ export declare function importMiddlewareConfigModule(inFile: string, logger?: Logger): Promise<MiddlewareConfig>;
50
+ export declare function importErrorConfigModule(inFile: string, logger?: Logger): Promise<ErrorConfig>;
51
+ export declare function importDocConfigModule(inFile: string, logger?: Logger): Promise<DocConfig>;
52
+ export declare function importConfigConfigModule(inFile: string, logger?: Logger): Promise<MiddlewareConfig>;
46
53
  export declare function importCORSModule(inFile: string, logger?: Logger): Promise<CORSOptions>;
47
54
  export declare function importWSConfigModule(inFile: string, logger?: Logger): Promise<WSConfig>;
48
55
  export declare function importDBConfigModule(inFile: string, logger?: Logger): Promise<DBConfig>;
@@ -11,7 +11,7 @@ import { getJSXJSPath, JSX_TMP_DIR } from "./paths.js";
11
11
  import { CLEAR_JSX_CACHE } from "./constants.js";
12
12
  import { getAsset, initAsset, validateAsset } from "./assets.js";
13
13
  import { calculateChecksumFromBuffer } from "./checksum.js";
14
- import { RouteOptionsSchema } from "@miqro/core/build/types.js";
14
+ import { HandlerWithOptionsSchema, RouteOptionsSchema } from "@miqro/core/build/types.js";
15
15
  let jsxJSBuffer = null; // Buffer.from(getAsset("jsx.dom.js"));
16
16
  let jsxJSBufferChecksumPromise = null; // calculateChecksumFromBuffer(jsxJSBuffer);
17
17
  export async function initJSXJS(logger) {
@@ -214,6 +214,53 @@ export const AuthConfigSchema = {
214
214
  },
215
215
  //mode:"add_extra"
216
216
  };
217
+ export const MiddlewareConfigSchema = {
218
+ type: "object",
219
+ properties: {
220
+ middleware: {
221
+ type: "Array",
222
+ arrayType: "function|object",
223
+ required: false,
224
+ properties: {
225
+ ...HandlerWithOptionsSchema.properties
226
+ }
227
+ },
228
+ post: {
229
+ type: "Array",
230
+ arrayType: "function|object",
231
+ required: false,
232
+ properties: {
233
+ ...HandlerWithOptionsSchema.properties
234
+ }
235
+ }
236
+ },
237
+ };
238
+ export const ErrorConfigSchema = {
239
+ type: "object",
240
+ properties: {
241
+ catch: {
242
+ type: "Array",
243
+ required: false,
244
+ arrayType: "function"
245
+ }
246
+ },
247
+ };
248
+ export const DocConfigSchema = {
249
+ type: "object",
250
+ properties: {
251
+ publish: {
252
+ type: "dict?",
253
+ dictType: "object",
254
+ properties: {
255
+ type: {
256
+ type: "enum?",
257
+ enumValues: ["HTML", "MD", "JSON"]
258
+ },
259
+ all: "boolean?"
260
+ }
261
+ }
262
+ }
263
+ };
217
264
  export async function importAPIRoute(inFile, logger) {
218
265
  const mod = (await importJSXFile(inFile, logger)).default;
219
266
  const module = typeof mod === "function" ? { handler: mod } : parser.parse(mod, APIRouteSchema, basename(inFile));
@@ -264,6 +311,42 @@ export async function importAuthModule(inFile, logger) {
264
311
  throw new Error(`error with module [${inFile}] undefined`);
265
312
  }
266
313
  }
314
+ export async function importMiddlewareConfigModule(inFile, logger) {
315
+ const module = parser.parse((await importJSXFile(inFile, logger)).default, MiddlewareConfigSchema, basename(inFile));
316
+ if (module !== undefined) {
317
+ return module;
318
+ }
319
+ else {
320
+ throw new Error(`error with module [${inFile}] undefined`);
321
+ }
322
+ }
323
+ export async function importErrorConfigModule(inFile, logger) {
324
+ const module = parser.parse((await importJSXFile(inFile, logger)).default, ErrorConfigSchema, basename(inFile));
325
+ if (module !== undefined) {
326
+ return module;
327
+ }
328
+ else {
329
+ throw new Error(`error with module [${inFile}] undefined`);
330
+ }
331
+ }
332
+ export async function importDocConfigModule(inFile, logger) {
333
+ const module = parser.parse((await importJSXFile(inFile, logger)).default, DocConfigSchema, basename(inFile));
334
+ if (module !== undefined) {
335
+ return module;
336
+ }
337
+ else {
338
+ throw new Error(`error with module [${inFile}] undefined`);
339
+ }
340
+ }
341
+ export async function importConfigConfigModule(inFile, logger) {
342
+ const module = parser.parse((await importJSXFile(inFile, logger)).default, MiddlewareConfigSchema, basename(inFile));
343
+ if (module !== undefined) {
344
+ return module;
345
+ }
346
+ else {
347
+ throw new Error(`error with module [${inFile}] undefined`);
348
+ }
349
+ }
267
350
  export async function importCORSModule(inFile, logger) {
268
351
  const module = parser.parse((await importJSXFile(inFile, logger)).default, CORSOptionsSchema, basename(inFile));
269
352
  if (module !== undefined) {
@@ -376,4 +459,3 @@ export function jsx2HTML(out, runtime) {
376
459
  //console.log("jsx2HTML [%s]", HTML);
377
460
  return HTML;
378
461
  }
379
- //# sourceMappingURL=jsx.js.map
@@ -7,6 +7,10 @@ export declare function getServerConfigPath(servicePath: string): string | false
7
7
  export declare function getWSConfigPath(servicePath: string): string | false;
8
8
  export declare function getDBConfigPath(servicePath: string): string | false;
9
9
  export declare function getStaticFilesPath(servicePath: string): string | false;
10
+ export declare function getMiddlewareConfigPath(servicePath: string): string | false;
11
+ export declare function getErrorConfigPath(servicePath: string): string | false;
12
+ export declare function getDocConfigPath(servicePath: string): string | false;
13
+ export declare function getMiqroJSONPath(): string | false;
10
14
  export declare function getAuthConfigPath(servicePath: string): string | false;
11
15
  export declare function getHTTPRouterPath(servicePath: string): string | false;
12
16
  export declare function getMigrationsPath(servicePath: string): string | false;
@@ -71,13 +71,53 @@ export function getStaticFilesPath(servicePath) {
71
71
  }
72
72
  return false;
73
73
  }
74
+ export function getMiddlewareConfigPath(servicePath) {
75
+ const middlewarePath = resolve(servicePath, "middleware.ts");
76
+ const middlewarePathJS = resolve(servicePath, "middleware.js");
77
+ if (existsSync(middlewarePath) && !statSync(middlewarePath).isDirectory()) {
78
+ return middlewarePath;
79
+ }
80
+ else if (existsSync(middlewarePathJS) && !statSync(middlewarePathJS).isDirectory()) {
81
+ return middlewarePathJS;
82
+ }
83
+ return false;
84
+ }
85
+ export function getErrorConfigPath(servicePath) {
86
+ const errorPath = resolve(servicePath, "catch.ts");
87
+ const errorPathJS = resolve(servicePath, "catch.js");
88
+ if (existsSync(errorPath) && !statSync(errorPath).isDirectory()) {
89
+ return errorPath;
90
+ }
91
+ else if (existsSync(errorPathJS) && !statSync(errorPathJS).isDirectory()) {
92
+ return errorPathJS;
93
+ }
94
+ return false;
95
+ }
96
+ export function getDocConfigPath(servicePath) {
97
+ const docPath = resolve(servicePath, "doc.ts");
98
+ const docPathJS = resolve(servicePath, "doc.js");
99
+ if (existsSync(docPath) && !statSync(docPath).isDirectory()) {
100
+ return docPath;
101
+ }
102
+ else if (existsSync(docPathJS) && !statSync(docPathJS).isDirectory()) {
103
+ return docPathJS;
104
+ }
105
+ return false;
106
+ }
107
+ export function getMiqroJSONPath() {
108
+ const miqroRCPath = resolve(cwd(), "miqro.json");
109
+ if (existsSync(miqroRCPath) && !statSync(miqroRCPath).isDirectory()) {
110
+ return miqroRCPath;
111
+ }
112
+ return false;
113
+ }
74
114
  export function getAuthConfigPath(servicePath) {
75
115
  const authPath = resolve(servicePath, "auth.ts");
76
116
  const authPathJS = resolve(servicePath, "auth.js");
77
117
  if (existsSync(authPath) && !statSync(authPath).isDirectory()) {
78
118
  return authPath;
79
119
  }
80
- else if (existsSync(authPath) && !statSync(authPath).isDirectory()) {
120
+ else if (existsSync(authPathJS) && !statSync(authPathJS).isDirectory()) {
81
121
  return authPathJS;
82
122
  }
83
123
  return false;
@@ -107,4 +147,3 @@ export function getESBuildBinaryPath() {
107
147
  export function getJSXJSPath() {
108
148
  return resolve(JSX_TMP_DIR, String(process.pid), "jsx.js");
109
149
  }
110
- //# sourceMappingURL=paths.js.map
@@ -76,4 +76,3 @@ export async function watchAndServer(app) {
76
76
  }
77
77
  };
78
78
  }
79
- //# sourceMappingURL=watch.js.map
@@ -1,7 +1,7 @@
1
1
  import { chmodSync, constants, mkdirSync, writeFileSync } from "node:fs";
2
2
  import { dirname, extname, join, relative, resolve } from "node:path";
3
3
  import { cwd, platform } from "node:process";
4
- import { getAuthConfigPath, getCORSConfigPath, getDBConfigPath, getMigrationsPath, getServerConfigPath, getServicePath, getWSConfigPath } from "../common/paths.js";
4
+ import { getAuthConfigPath, getCORSConfigPath, getDBConfigPath, getErrorConfigPath, getMiddlewareConfigPath, getMigrationsPath, getServerConfigPath, getWSConfigPath } from "../common/paths.js";
5
5
  import { getAsset } from "../common/assets.js";
6
6
  import { migration } from "@miqro/query";
7
7
  //export const libCJSBuffer = Buffer.from(getAsset("lib.cjs"));
@@ -83,20 +83,9 @@ async function main() {
83
83
  ${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.preload).map(config=>config.preload(serverInterface)));\n` : ""}
84
84
  app.use(ServerRequestHandler(serverInterface));
85
85
  app.use(LoggerHandler());
86
- ${services.map(service => {
87
- const servicePath = getServicePath(service);
88
- return `${getCORSConfigPath(servicePath) ? `app.use(server.middleware.cors((await import("../${service}/cors.js")).default));` : ""}`;
89
- })}
90
- ${services.map(service => {
91
- const servicePath = getServicePath(service);
92
- return `${getAuthConfigPath(servicePath) ? `app.use(server.middleware.session((await import("../${service}/auth.js")).default));` : ""}`;
93
- })}
94
- ${services.map(service => `
95
- app.use(await (await import("./${join(service, "api-router.js")}")).setupRouter());
96
- app.use(await (await import("./${join(service, "static-router.js")}")).setupRouter())`).join("\n")}
86
+ ${services.map(service => `app.use(await (await import("./${join(service, "router.js")}")).setupRouter());`).join("\n")}
97
87
  ${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.load).map(config=>config.load(serverInterface)));\n` : ""}
98
88
 
99
-
100
89
  await app.listen(PORT);
101
90
  ${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.start).map(config=>config.start(serverInterface)));` : ""}
102
91
  }
@@ -106,10 +95,25 @@ main().catch(e=>console.error(e));
106
95
  export async function inflateServiceForSea(logger, inflateDir, service, servicePath /*, serviceMigrations: string[]*/, serviceRouteFileMap, serviceStaticFileMap) {
107
96
  const migrationsFolderPath = getMigrationsPath(servicePath);
108
97
  const serviceMigrations = migrationsFolderPath ? migration.getSortedMigrations(migrationsFolderPath) : [];
109
- writeFile(logger, join(inflateDir, "sea", service, "api-router.js"), `import { appendAPIModule, Router } from "./../lib.cjs";\n
98
+ writeFile(logger, join(inflateDir, "sea", service, "router.js"), `import { appendAPIModule, Router } from "./../lib.cjs";\n
110
99
  export async function setupRouter() {
111
100
  const router = new Router();
112
-
101
+ ${getErrorConfigPath(servicePath) ? `
102
+ const errorConfig = (await import("../../${service}/catch.js")).default;
103
+ if(errorConfig && errorConfig.catch) {
104
+ for(const m of errorConfig.catch) {
105
+ router.catch(m);
106
+ }
107
+ }` : ""}
108
+ ${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.js")).default));` : ""}
109
+ ${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.js")).default));` : ""}
110
+ ${getMiddlewareConfigPath(servicePath) ? `
111
+ const middlewareConfig = (await import("../../${service}/middleware.js")).default;
112
+ if(middlewareConfig && middlewareConfig.middleware) {
113
+ for(const m of middlewareConfig.middleware) {
114
+ router.use(m);
115
+ }
116
+ }` : ""}
113
117
  ${Object.keys(serviceRouteFileMap)
114
118
  .map(filePath => serviceRouteFileMap[filePath])
115
119
  .filter(data => data.previewMethod === "api")
@@ -124,7 +128,15 @@ ${Object.keys(serviceRouteFileMap)
124
128
  }
125
129
  }).filter(l => l)[0])
126
130
  .join("\n")}
131
+ router.use(await (await import("./static-router.js")).setupRouter())
127
132
 
133
+ ${getMiddlewareConfigPath(servicePath) ? `
134
+ if(middlewareConfig && middlewareConfig.post) {
135
+ for(const m of middlewareConfig.post) {
136
+ router.use(m);
137
+ }
138
+ }` : ""}
139
+
128
140
  return router;
129
141
  }`);
130
142
  writeFile(logger, join(inflateDir, "sea", service, "migration-up.js"), `import { migration } from "./../lib.cjs";\n
@@ -173,4 +185,3 @@ function writeFile(logger, path, buffer) {
173
185
  });
174
186
  writeFileSync(path, buffer);
175
187
  }
176
- //# sourceMappingURL=inflate-sea.js.map
@@ -7,6 +7,7 @@ import { getServicePath } from "../common/paths.js";
7
7
  import { inflateWSConfig } from "./setup-ws.js";
8
8
  import { inflateAppForSea, inflateServiceForSea } from "./inflate-sea.js";
9
9
  import { setupLogConfig } from "./setup-log.js";
10
+ import { setupDoc } from "./setup.doc.js";
10
11
  export async function inflateApp({ serverInterface, logger, hotreload, services /*, dbManager*/, inflateDir, inflateSea /*, editor, inflateTests*/ }) {
11
12
  logger.trace("inflateApp");
12
13
  const errors = [];
@@ -47,6 +48,7 @@ export async function inflateApp({ serverInterface, logger, hotreload, services
47
48
  ...routeFileMap,
48
49
  ...serviceRouteFileMap
49
50
  };
51
+ await setupDoc(logger, servicePath, service, router, routeFileMap, inflateDir, errors);
50
52
  await inflateWSConfig(logger, servicePath, service, wsConfigList, inflateSea ? inflateDir : undefined, errors);
51
53
  //await setupServerConfig(logger, servicePath, service, serverConfigMap, inflateSea ? inflateDir : undefined, errors);
52
54
  if (inflateDir && inflateSea) {
@@ -62,4 +64,3 @@ export async function inflateApp({ serverInterface, logger, hotreload, services
62
64
  router.use(assertGlobalTampered);
63
65
  return errors.length === 0 ? [router, null, routeFileMap /*, migrations*/, wsConfigList /*, serverConfigMap*/, logConfigMap] : [router, errors, routeFileMap /*, migrations*/, wsConfigList /*, serverConfigMap*/, logConfigMap];
64
66
  }
65
- //# sourceMappingURL=inflate.js.map
@@ -1,2 +1,3 @@
1
1
  import { Logger } from "@miqro/core";
2
2
  export declare function inflateMD2HTML(inFile: string, logger?: Logger): string;
3
+ export declare function inflateMDString2HTML(text: string, logger?: Logger): string;