@vandenberghinc/volt 1.1.4 → 1.1.6

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 (290) hide show
  1. package/backend/dist/cjs/database.d.ts +41 -68
  2. package/backend/dist/cjs/database.js +136 -78
  3. package/backend/dist/cjs/endpoint.d.ts +23 -9
  4. package/backend/dist/cjs/endpoint.js +98 -21
  5. package/backend/dist/cjs/file_watcher.js +2 -2
  6. package/backend/dist/cjs/frontend.d.ts +0 -2
  7. package/backend/dist/cjs/frontend.js +9 -9
  8. package/backend/dist/cjs/image_endpoint.d.ts +3 -1
  9. package/backend/dist/cjs/image_endpoint.js +2 -1
  10. package/backend/dist/cjs/payments/paddle.js +10 -2
  11. package/backend/dist/cjs/plugins/css.d.ts +6 -5
  12. package/backend/dist/cjs/plugins/css.js +32 -7
  13. package/backend/dist/cjs/plugins/ts/compiler.d.ts +6 -1
  14. package/backend/dist/cjs/plugins/ts/compiler.js +26 -2
  15. package/backend/dist/cjs/plugins/ts/preprocessing.js +5 -3
  16. package/backend/dist/cjs/server.d.ts +7 -13
  17. package/backend/dist/cjs/server.js +184 -303
  18. package/backend/dist/cjs/status.d.ts +1 -0
  19. package/backend/dist/cjs/status.js +2 -1
  20. package/backend/dist/cjs/stream.d.ts +5 -3
  21. package/backend/dist/cjs/stream.js +13 -4
  22. package/backend/dist/cjs/users.d.ts +1 -1
  23. package/backend/dist/cjs/users.js +87 -72
  24. package/backend/dist/cjs/utils.d.ts +17 -9
  25. package/backend/dist/cjs/utils.js +22 -64
  26. package/backend/dist/cjs/view.d.ts +2 -2
  27. package/backend/dist/cjs/view.js +38 -40
  28. package/backend/dist/cjs/volt.d.ts +3 -2
  29. package/backend/dist/cjs/volt.js +2 -2
  30. package/backend/dist/css/volt.css +5 -0
  31. package/backend/dist/esm/database.d.ts +41 -68
  32. package/backend/dist/esm/database.js +137 -79
  33. package/backend/dist/esm/endpoint.d.ts +23 -9
  34. package/backend/dist/esm/endpoint.js +99 -22
  35. package/backend/dist/esm/file_watcher.js +2 -2
  36. package/backend/dist/esm/frontend.d.ts +0 -2
  37. package/backend/dist/esm/frontend.js +9 -9
  38. package/backend/dist/esm/image_endpoint.d.ts +3 -1
  39. package/backend/dist/esm/image_endpoint.js +2 -1
  40. package/backend/dist/esm/payments/paddle.js +11 -3
  41. package/backend/dist/esm/plugins/css.d.ts +6 -5
  42. package/backend/dist/esm/plugins/css.js +32 -6
  43. package/backend/dist/esm/plugins/ts/compiler.d.ts +6 -1
  44. package/backend/dist/esm/plugins/ts/compiler.js +26 -2
  45. package/backend/dist/esm/plugins/ts/preprocessing.js +5 -3
  46. package/backend/dist/esm/server.d.ts +7 -13
  47. package/backend/dist/esm/server.js +182 -301
  48. package/backend/dist/esm/status.d.ts +1 -0
  49. package/backend/dist/esm/status.js +1 -0
  50. package/backend/dist/esm/stream.d.ts +5 -3
  51. package/backend/dist/esm/stream.js +13 -4
  52. package/backend/dist/esm/users.d.ts +1 -1
  53. package/backend/dist/esm/users.js +87 -72
  54. package/backend/dist/esm/utils.d.ts +17 -9
  55. package/backend/dist/esm/utils.js +21 -62
  56. package/backend/dist/esm/view.d.ts +2 -2
  57. package/backend/dist/esm/view.js +38 -40
  58. package/backend/dist/esm/volt.d.ts +3 -2
  59. package/backend/dist/esm/volt.js +2 -1
  60. package/backend/dist/esm-dev/blacklist.js +1 -1
  61. package/backend/dist/esm-dev/cli.js +2 -2
  62. package/backend/dist/esm-dev/database.d.ts +41 -68
  63. package/backend/dist/esm-dev/database.js +138 -80
  64. package/backend/dist/esm-dev/endpoint.d.ts +23 -9
  65. package/backend/dist/esm-dev/endpoint.js +100 -23
  66. package/backend/dist/esm-dev/file_watcher.js +3 -3
  67. package/backend/dist/esm-dev/frontend.d.ts +0 -2
  68. package/backend/dist/esm-dev/frontend.js +9 -9
  69. package/backend/dist/esm-dev/image_endpoint.d.ts +3 -1
  70. package/backend/dist/esm-dev/image_endpoint.js +2 -1
  71. package/backend/dist/esm-dev/logger.js +1 -1
  72. package/backend/dist/esm-dev/payments/paddle.js +12 -4
  73. package/backend/dist/esm-dev/plugins/css.d.ts +6 -5
  74. package/backend/dist/esm-dev/plugins/css.js +33 -7
  75. package/backend/dist/esm-dev/plugins/ts/compiler.d.ts +6 -1
  76. package/backend/dist/esm-dev/plugins/ts/compiler.js +27 -3
  77. package/backend/dist/esm-dev/plugins/ts/preprocessing.js +7 -5
  78. package/backend/dist/esm-dev/rate_limit.js +1 -1
  79. package/backend/dist/esm-dev/server.d.ts +7 -13
  80. package/backend/dist/esm-dev/server.js +184 -303
  81. package/backend/dist/esm-dev/status.d.ts +1 -0
  82. package/backend/dist/esm-dev/status.js +1 -0
  83. package/backend/dist/esm-dev/stream.d.ts +5 -3
  84. package/backend/dist/esm-dev/stream.js +13 -4
  85. package/backend/dist/esm-dev/users.d.ts +1 -1
  86. package/backend/dist/esm-dev/users.js +88 -73
  87. package/backend/dist/esm-dev/utils.d.ts +17 -9
  88. package/backend/dist/esm-dev/utils.js +22 -63
  89. package/backend/dist/esm-dev/view.d.ts +2 -2
  90. package/backend/dist/esm-dev/view.js +39 -41
  91. package/backend/dist/esm-dev/volt.d.ts +3 -2
  92. package/backend/dist/esm-dev/volt.js +2 -1
  93. package/backend/src/database.ts +173 -155
  94. package/backend/src/endpoint.ts +123 -31
  95. package/backend/src/file_watcher.ts +2 -2
  96. package/backend/src/frontend.ts +9 -8
  97. package/backend/src/image_endpoint.ts +4 -0
  98. package/backend/src/payments/paddle.ts +11 -3
  99. package/backend/src/plugins/css.ts +36 -8
  100. package/backend/src/plugins/ts/compiler.ts +37 -1
  101. package/backend/src/plugins/ts/preprocessing.ts +5 -3
  102. package/backend/src/server.ts +167 -306
  103. package/backend/src/status.ts +1 -0
  104. package/backend/src/stream.ts +28 -8
  105. package/backend/src/users.ts +87 -72
  106. package/backend/src/utils.ts +58 -25
  107. package/backend/src/view.ts +30 -28
  108. package/backend/src/{volt.js → volt.ts} +2 -1
  109. package/backend/tsconfig.cjs.json +3 -3
  110. package/backend/tsconfig.esm.json +3 -3
  111. package/frontend/dist/elements/base.d.ts +414 -432
  112. package/frontend/dist/elements/base.js +566 -329
  113. package/frontend/dist/elements/module.d.ts +26 -12
  114. package/frontend/dist/elements/module.js +69 -32
  115. package/frontend/dist/elements/register_element.d.ts +3 -0
  116. package/frontend/dist/elements/register_element.js +22 -0
  117. package/frontend/dist/modules/auth.d.ts +1 -0
  118. package/frontend/dist/modules/auth.js +6 -5
  119. package/frontend/dist/modules/color.d.ts +159 -0
  120. package/frontend/dist/modules/color.js +315 -0
  121. package/frontend/dist/modules/colors.d.ts +1 -26
  122. package/frontend/dist/modules/colors.js +417 -340
  123. package/frontend/dist/modules/cookies.d.ts +1 -0
  124. package/frontend/dist/modules/cookies.js +1 -0
  125. package/frontend/dist/modules/events.d.ts +1 -0
  126. package/frontend/dist/modules/events.js +1 -0
  127. package/frontend/dist/modules/google.d.ts +1 -0
  128. package/frontend/dist/modules/google.js +1 -0
  129. package/frontend/dist/modules/meta.d.ts +1 -0
  130. package/frontend/dist/modules/meta.js +1 -0
  131. package/frontend/dist/modules/mutex.d.ts +1 -2
  132. package/frontend/dist/modules/mutex.js +3 -4
  133. package/frontend/dist/modules/paddle.d.ts +1 -0
  134. package/frontend/dist/modules/paddle.js +14 -13
  135. package/frontend/dist/modules/scheme.d.ts +1 -0
  136. package/frontend/dist/modules/scheme.js +5 -3
  137. package/frontend/dist/modules/statics.d.ts +1 -0
  138. package/frontend/dist/modules/statics.js +1 -0
  139. package/frontend/dist/modules/support.d.ts +1 -0
  140. package/frontend/dist/modules/support.js +3 -2
  141. package/frontend/dist/modules/theme.d.ts +56 -0
  142. package/frontend/dist/{ui → modules}/theme.js +186 -75
  143. package/frontend/dist/modules/themes.d.ts +1 -1
  144. package/frontend/dist/modules/themes.js +1 -0
  145. package/frontend/dist/modules/user.d.ts +1 -0
  146. package/frontend/dist/modules/user.js +11 -10
  147. package/frontend/dist/modules/utils.d.ts +23 -2
  148. package/frontend/dist/modules/utils.js +93 -1
  149. package/frontend/dist/types/gradient.js +4 -0
  150. package/frontend/dist/ui/border_button.d.ts +0 -25
  151. package/frontend/dist/ui/border_button.js +50 -51
  152. package/frontend/dist/ui/button.d.ts +0 -21
  153. package/frontend/dist/ui/button.js +41 -46
  154. package/frontend/dist/ui/canvas.js +15 -15
  155. package/frontend/dist/ui/checkbox.d.ts +3 -17
  156. package/frontend/dist/ui/checkbox.js +36 -30
  157. package/frontend/dist/ui/code.d.ts +15 -82
  158. package/frontend/dist/ui/code.js +150 -125
  159. package/frontend/dist/ui/color.d.ts +0 -1
  160. package/frontend/dist/ui/color.js +1 -1
  161. package/frontend/dist/ui/context_menu.d.ts +4 -2
  162. package/frontend/dist/ui/context_menu.js +16 -17
  163. package/frontend/dist/ui/css.js +2 -0
  164. package/frontend/dist/ui/divider.d.ts +0 -7
  165. package/frontend/dist/ui/divider.js +21 -25
  166. package/frontend/dist/ui/dropdown.d.ts +13 -7
  167. package/frontend/dist/ui/dropdown.js +65 -30
  168. package/frontend/dist/ui/for_each.d.ts +0 -5
  169. package/frontend/dist/ui/for_each.js +17 -22
  170. package/frontend/dist/ui/form.d.ts +17 -12
  171. package/frontend/dist/ui/form.js +21 -18
  172. package/frontend/dist/ui/frame_modes.d.ts +9 -12
  173. package/frontend/dist/ui/frame_modes.js +8 -10
  174. package/frontend/dist/ui/google_map.d.ts +0 -11
  175. package/frontend/dist/ui/google_map.js +23 -28
  176. package/frontend/dist/ui/gradient.d.ts +0 -5
  177. package/frontend/dist/ui/gradient.js +17 -22
  178. package/frontend/dist/ui/image.d.ts +27 -58
  179. package/frontend/dist/ui/image.js +99 -93
  180. package/frontend/dist/ui/input.d.ts +20 -97
  181. package/frontend/dist/ui/input.js +192 -170
  182. package/frontend/dist/ui/link.d.ts +0 -18
  183. package/frontend/dist/ui/link.js +42 -48
  184. package/frontend/dist/ui/list.js +36 -37
  185. package/frontend/dist/ui/loader_button.d.ts +4 -19
  186. package/frontend/dist/ui/loader_button.js +35 -37
  187. package/frontend/dist/ui/loaders.d.ts +0 -8
  188. package/frontend/dist/ui/loaders.js +20 -25
  189. package/frontend/dist/ui/popup.d.ts +11 -8
  190. package/frontend/dist/ui/popup.js +183 -24
  191. package/frontend/dist/ui/pseudo.d.ts +3 -3
  192. package/frontend/dist/ui/pseudo.js +14 -17
  193. package/frontend/dist/ui/scroller.d.ts +10 -48
  194. package/frontend/dist/ui/scroller.js +306 -300
  195. package/frontend/dist/ui/slider.d.ts +9 -3
  196. package/frontend/dist/ui/slider.js +31 -17
  197. package/frontend/dist/ui/spacer.d.ts +0 -9
  198. package/frontend/dist/ui/spacer.js +21 -26
  199. package/frontend/dist/ui/span.js +13 -15
  200. package/frontend/dist/ui/stack.d.ts +14 -75
  201. package/frontend/dist/ui/stack.js +166 -169
  202. package/frontend/dist/ui/steps.d.ts +10 -23
  203. package/frontend/dist/ui/steps.js +47 -34
  204. package/frontend/dist/ui/style.d.ts +4 -3
  205. package/frontend/dist/ui/style.js +13 -18
  206. package/frontend/dist/ui/switch.d.ts +10 -4
  207. package/frontend/dist/ui/switch.js +24 -16
  208. package/frontend/dist/ui/table.d.ts +0 -23
  209. package/frontend/dist/ui/table.js +113 -119
  210. package/frontend/dist/ui/tabs.d.ts +3 -19
  211. package/frontend/dist/ui/tabs.js +35 -29
  212. package/frontend/dist/ui/text.d.ts +0 -8
  213. package/frontend/dist/ui/text.js +20 -25
  214. package/frontend/dist/ui/title.d.ts +0 -15
  215. package/frontend/dist/ui/title.js +39 -45
  216. package/frontend/dist/ui/ui.d.ts +0 -2
  217. package/frontend/dist/ui/ui.js +0 -2
  218. package/frontend/dist/ui/view.d.ts +3 -17
  219. package/frontend/dist/ui/view.js +27 -32
  220. package/frontend/dist/volt.d.ts +2 -1
  221. package/frontend/dist/volt.js +3 -1
  222. package/frontend/examples/dashboard/dashboard.ts +774 -0
  223. package/frontend/examples/theme/theme.ts +58 -0
  224. package/frontend/src/css/volt.css +5 -0
  225. package/frontend/src/elements/base.ts +767 -545
  226. package/frontend/src/elements/module.ts +90 -29
  227. package/frontend/src/elements/register_element.ts +24 -0
  228. package/frontend/src/modules/auth.ts +7 -6
  229. package/frontend/src/modules/color.ts +348 -0
  230. package/frontend/src/modules/colors.ts +468 -449
  231. package/frontend/src/modules/cookies.ts +1 -0
  232. package/frontend/src/modules/events.ts +1 -0
  233. package/frontend/src/modules/google.ts +1 -0
  234. package/frontend/src/modules/meta.ts +2 -1
  235. package/frontend/src/modules/mutex.ts +2 -4
  236. package/frontend/src/modules/paddle.ts +21 -20
  237. package/frontend/src/modules/scheme.ts +5 -4
  238. package/frontend/src/modules/statics.ts +2 -1
  239. package/frontend/src/modules/support.ts +3 -2
  240. package/frontend/src/modules/theme.ts +413 -0
  241. package/frontend/src/modules/themes.ts +2 -1
  242. package/frontend/src/modules/user.ts +12 -11
  243. package/frontend/src/modules/utils.ts +125 -2
  244. package/frontend/src/ui/border_button.ts +41 -37
  245. package/frontend/src/ui/button.ts +33 -32
  246. package/frontend/src/ui/canvas.ts +5 -2
  247. package/frontend/src/ui/checkbox.ts +21 -22
  248. package/frontend/src/ui/code.ts +92 -86
  249. package/frontend/src/ui/context_menu.ts +7 -5
  250. package/frontend/src/ui/css.ts +1 -1
  251. package/frontend/src/ui/divider.ts +15 -10
  252. package/frontend/src/ui/dropdown.ts +38 -21
  253. package/frontend/src/ui/for_each.ts +9 -8
  254. package/frontend/src/ui/form.ts +26 -21
  255. package/frontend/src/ui/frame_modes.ts +13 -17
  256. package/frontend/src/ui/google_map.ts +15 -13
  257. package/frontend/src/ui/gradient.ts +9 -8
  258. package/frontend/src/ui/image.ts +108 -86
  259. package/frontend/src/ui/input.ts +145 -144
  260. package/frontend/src/ui/link.ts +25 -23
  261. package/frontend/src/ui/list.ts +12 -6
  262. package/frontend/src/ui/loader_button.ts +26 -25
  263. package/frontend/src/ui/loaders.ts +12 -11
  264. package/frontend/src/ui/popup.ts +168 -14
  265. package/frontend/src/ui/pseudo.ts +5 -3
  266. package/frontend/src/ui/scroller.ts +303 -294
  267. package/frontend/src/ui/slider.ts +15 -10
  268. package/frontend/src/ui/spacer.ts +14 -11
  269. package/frontend/src/ui/span.ts +6 -2
  270. package/frontend/src/ui/stack.ts +196 -183
  271. package/frontend/src/ui/steps.ts +38 -22
  272. package/frontend/src/ui/style.ts +7 -4
  273. package/frontend/src/ui/switch.ts +16 -11
  274. package/frontend/src/ui/table.ts +42 -34
  275. package/frontend/src/ui/tabs.ts +20 -19
  276. package/frontend/src/ui/text.ts +12 -11
  277. package/frontend/src/ui/title.ts +22 -20
  278. package/frontend/src/ui/ui.ts +0 -2
  279. package/frontend/src/ui/view.ts +20 -19
  280. package/frontend/src/volt.ts +3 -1
  281. package/frontend/{compile.js → tools/compile.old.js} +2 -2
  282. package/frontend/tools/embed_scripts.js +69 -0
  283. package/frontend/tsconfig.json +26 -0
  284. package/package.json +7 -6
  285. package/frontend/dist/ui/theme.d.ts +0 -25
  286. package/frontend/exports.json +0 -1340
  287. package/frontend/src/modules/date.js +0 -535
  288. package/frontend/src/ui/color.ts +0 -117
  289. package/frontend/src/ui/theme.ts +0 -279
  290. /package/backend/src/{vinc.dev.js → vinc.dev.ts} +0 -0
@@ -67,9 +67,7 @@ const users_js_1 = require("./users.js");
67
67
  const paddle_js_1 = require("./payments/paddle.js");
68
68
  const rate_limit_js_1 = require("./rate_limit.js");
69
69
  const logger_js_1 = __importStar(require("./logger.js"));
70
- const TSCompiler = __importStar(require("./plugins/ts/compiler.js"));
71
- const TSPreprocessing = __importStar(require("./plugins/ts/preprocessing.js"));
72
- const browser_js_1 = require("./plugins/browser.js");
70
+ // import { BrowserPreview } from "./plugins/browser.js";
73
71
  const log_source = new logger_js_1.LogSource("Server");
74
72
  const url_1 = require("url");
75
73
  const path_1 = require("path");
@@ -96,6 +94,10 @@ thread_monitor.start();
96
94
  @description: Whether the server is in production more, or in development mode.
97
95
  @type: boolean
98
96
  @required: true
97
+ @parameter:
98
+ @name: localhost
99
+ @description: Wether to run on localhost. This overrides the given `ip` parameter, and makes the `ip` parameter optional.
100
+ @type: boolean
99
101
  @parameter:
100
102
  @name: ip
101
103
  @description: The ip where the server will run on.
@@ -551,6 +553,7 @@ class Server {
551
553
  [".jpeg", "image/jpeg"],
552
554
  [".jpg", "image/jpeg"],
553
555
  [".js", "application/javascript"],
556
+ [".ts", "application/javascript"],
554
557
  [".atom", "application/atom+xml"],
555
558
  [".rss", "application/rss+xml"],
556
559
  [".mml", "text/mathml"],
@@ -633,7 +636,7 @@ class Server {
633
636
  [".ra", "audio/x-realaudio"],
634
637
  [".3gpp", "video/3gpp"],
635
638
  [".3gp", "video/3gpp"],
636
- [".ts", "video/mp2t"],
639
+ // [".ts", "video/mp2t"],
637
640
  [".mp4", "video/mp4"],
638
641
  [".mpeg", "video/mpeg"],
639
642
  [".mpg", "video/mpeg"],
@@ -703,6 +706,7 @@ class Server {
703
706
  token_expiration;
704
707
  google_tag;
705
708
  production;
709
+ localhost;
706
710
  multiprocessing;
707
711
  processes;
708
712
  company;
@@ -716,8 +720,9 @@ class Server {
716
720
  log_level;
717
721
  tls;
718
722
  file_watcher;
719
- admin;
720
- ts;
723
+ // public admin: AdminConfig;
724
+ // public ts: TypeScriptConfig;
725
+ lightweight;
721
726
  performance;
722
727
  csp;
723
728
  default_headers;
@@ -736,8 +741,8 @@ class Server {
736
741
  keys;
737
742
  _on_start;
738
743
  _on_stop;
739
- browser_preview;
740
- static_file_watcher;
744
+ // public browser_preview?: BrowserPreview;
745
+ // public static_file_watcher: StaticFileWatcher;
741
746
  is_file_watcher;
742
747
  daemon;
743
748
  _stop_tscompiler_watcher;
@@ -771,13 +776,17 @@ class Server {
771
776
  },
772
777
  }, keys = [], payments = null, default_headers = null, google_tag = undefined, token_expiration = 86400, enable_2fa = false, enable_account_activation = true,
773
778
  // honey_pot_key = null,
774
- production = false, multiprocessing = true, processes = null, file_watcher = {}, offline = false, additional_sitemap_endpoints = [], log_level = 0, daemon = {}, admin = {
775
- password: null,
776
- ips: [],
777
- }, ts = {
778
- compiler_opts: {},
779
- output: undefined,
780
- }, browser_preview = undefined, }) {
779
+ production = false, localhost = true, multiprocessing = true, processes = null, file_watcher = false, offline = false, additional_sitemap_endpoints = [], log_level = 0, daemon = {},
780
+ // admin = {
781
+ // password: null,
782
+ // ips: [],
783
+ // },
784
+ // ts = {
785
+ // compiler_opts: {},
786
+ // output: undefined,
787
+ // },
788
+ // browser_preview = undefined,
789
+ lightweight = false, }) {
781
790
  // @debug
782
791
  // Async hook for tracking active processes during stop().
783
792
  // const async_resource_map = new Map();
@@ -811,8 +820,8 @@ class Server {
811
820
  // this.async_hook.enable();
812
821
  // Verify args.
813
822
  _vinc_1.vlib.Scheme.verify({ object: arguments[0], err_prefix: "Server: ", check_unknown: true, scheme: {
814
- ip: "string",
815
- port: "number",
823
+ ip: { type: "string", required: false },
824
+ port: { type: "number", required: false },
816
825
  domain: "string",
817
826
  statics: { type: "array", default: [] },
818
827
  is_primary: { type: "boolean", default: true },
@@ -856,11 +865,8 @@ class Server {
856
865
  }
857
866
  },
858
867
  rate_limit: {
859
- type: "object",
860
- default: {
861
- ip: null,
862
- port: rate_limit_js_1.RateLimitServer.default_port,
863
- },
868
+ type: ["boolean", "object"],
869
+ default: false,
864
870
  scheme: {
865
871
  server: { type: "object", default: {}, scheme: {
866
872
  ip: { type: "string", default: null },
@@ -900,6 +906,7 @@ class Server {
900
906
  enable_2fa: { type: "boolean", required: false },
901
907
  enable_account_activation: { type: "boolean", required: false },
902
908
  production: { type: "boolean", required: false },
909
+ localhost: { type: "boolean", required: false },
903
910
  multiprocessing: { type: "boolean", required: false, default: true },
904
911
  processes: { type: "number", required: false, default: null },
905
912
  file_watcher: { type: ["null", "boolean", "object", file_watcher_js_1.FileWatcher], required: false },
@@ -907,22 +914,23 @@ class Server {
907
914
  additional_sitemap_endpoints: { type: "array", default: [] },
908
915
  log_level: { type: "number", default: 0 },
909
916
  daemon: { type: ["object", "boolean"], default: {} },
910
- admin: { type: "object", default: {}, attributes: {
911
- ips: { type: "array", default: [] },
912
- password: {
913
- type: "string",
914
- verify: (param, attrs) => (param.length < 10 ? `Parameter "Server.admin.password" must have a length of at least 10 characters.` : undefined),
915
- },
916
- } },
917
- ts: {
918
- type: "object",
919
- required: false,
920
- scheme: {
921
- compiler_opts: { type: "object", default: {} },
922
- output: "string",
923
- },
924
- },
925
- browser_preview: { type: "string", required: false, default: undefined },
917
+ // admin: {type: "object", default: {}, attributes: {
918
+ // ips: {type: "array", default: []},
919
+ // password: {
920
+ // type: "string",
921
+ // verify: (param: string, attrs) => (param.length < 10 ? `Parameter "Server.admin.password" must have a length of at least 10 characters.` : undefined),
922
+ // },
923
+ // }},
924
+ // ts: {
925
+ // type: "object",
926
+ // required: false,
927
+ // scheme: {
928
+ // compiler_opts: {type: "object", default: {}},
929
+ // output: "string",
930
+ // },
931
+ // },
932
+ // browser_preview: {type: ["string", "undefined"], required: false, default: undefined},
933
+ lightweight: { type: "boolean", required: false },
926
934
  } });
927
935
  // Assign attributes directly.
928
936
  this.port = port;
@@ -935,6 +943,8 @@ class Server {
935
943
  this.token_expiration = token_expiration;
936
944
  this.google_tag = google_tag;
937
945
  this.production = production;
946
+ this.localhost = localhost;
947
+ this.lightweight = lightweight;
938
948
  this.multiprocessing = multiprocessing;
939
949
  this.processes = processes == null ? os.cpus().length : processes;
940
950
  this.company = company;
@@ -947,10 +957,15 @@ class Server {
947
957
  this.log_level = log_level;
948
958
  this.tls = tls;
949
959
  // this.file_watcher = file_watcher;
950
- this.admin = admin;
951
- this.ts = ts;
960
+ // this.admin = admin as AdminConfig;
961
+ // this.ts = ts as TypeScriptConfig;
952
962
  this.endpoints = new Map();
953
963
  this.err_endpoints = new Map();
964
+ // Assign based on localhost.
965
+ if (localhost) {
966
+ this.ip = "127.0.0.1";
967
+ this.domain = this.ip + ":" + (port + (this.tls ? 1 : 0));
968
+ }
954
969
  /* @performance */ this.performance = new _vinc_1.vlib.Performance("Server performance");
955
970
  // Assign objects to server so it is easy to access.
956
971
  this.status = status_js_1.Status;
@@ -1053,13 +1068,14 @@ class Server {
1053
1068
  this.endpoints = new Map();
1054
1069
  this.err_endpoints = new Map();
1055
1070
  // Browser preview.
1056
- if (browser_preview) {
1057
- this.browser_preview = new browser_js_1.BrowserPreview(browser_preview);
1058
- }
1071
+ // if (browser_preview) {
1072
+ // this.browser_preview = new BrowserPreview(browser_preview);
1073
+ // }
1059
1074
  // Static file watcher.
1060
- this.static_file_watcher = new file_watcher_js_1.StaticFileWatcher(this);
1075
+ // this.static_file_watcher = new StaticFileWatcher(this);
1061
1076
  // Initialize file watcher.
1062
1077
  if (file_watcher !== false) {
1078
+ console.warn("[Volt] Argument file_watcher is deprecated. This may be removed in future versions.");
1063
1079
  if (file_watcher == null) {
1064
1080
  // Null.
1065
1081
  file_watcher = {};
@@ -1132,14 +1148,16 @@ class Server {
1132
1148
  this.smtp = nodemailer.createTransport(smtp);
1133
1149
  }
1134
1150
  // The rate limit server/client.
1135
- if (this.is_primary) {
1136
- this.rate_limit = new rate_limit_js_1.RateLimitServer({ ...(rate_limit.server ?? {}), _server: this });
1137
- }
1138
- else {
1139
- if (rate_limit.server?.https) {
1140
- rate_limit.client.https = true;
1151
+ if (rate_limit) {
1152
+ if (this.is_primary) {
1153
+ this.rate_limit = new rate_limit_js_1.RateLimitServer({ ...(rate_limit.server ?? {}), _server: this });
1154
+ }
1155
+ else {
1156
+ if (rate_limit.server?.https) {
1157
+ rate_limit.client.https = true;
1158
+ }
1159
+ this.rate_limit = new rate_limit_js_1.RateLimitClient({ ...(rate_limit.client ?? {}), _server: this });
1141
1160
  }
1142
- this.rate_limit = new rate_limit_js_1.RateLimitClient({ ...(rate_limit.client ?? {}), _server: this });
1143
1161
  }
1144
1162
  // Blacklist class.
1145
1163
  // if (this.honey_pot_key) {
@@ -1243,13 +1261,14 @@ class Server {
1243
1261
  if (favicon.exists() === false) {
1244
1262
  throw Error(`Specified favicon path "${favicon}" does not exist.`);
1245
1263
  }
1246
- this.endpoint(new endpoint_js_1.Endpoint({
1264
+ this.endpoint({
1247
1265
  method: "GET",
1248
1266
  endpoint: "/favicon.ico",
1249
1267
  data: favicon.load_sync({ type: "buffer" }),
1250
1268
  content_type: this.get_content_type(favicon.extension()),
1251
1269
  _is_static: true,
1252
- }));
1270
+ _server: this,
1271
+ });
1253
1272
  // additional_file_watcher_paths.push(favicon.str());
1254
1273
  }
1255
1274
  // Create status endpoint.
@@ -1266,13 +1285,14 @@ class Server {
1266
1285
  else {
1267
1286
  status_key = status_key_path.load_sync();
1268
1287
  }
1269
- this.endpoint(new endpoint_js_1.Endpoint({
1288
+ this.endpoint({
1270
1289
  method: "GET",
1271
1290
  endpoint: "/.status",
1272
1291
  content_type: "application/json",
1273
1292
  params: {
1274
1293
  key: "string",
1275
1294
  },
1295
+ _server: this,
1276
1296
  callback: async (stream, params) => {
1277
1297
  // Check key.
1278
1298
  if (params.key !== status_key) {
@@ -1307,7 +1327,7 @@ class Server {
1307
1327
  data: status,
1308
1328
  });
1309
1329
  },
1310
- }));
1330
+ });
1311
1331
  // Default static endpoints.
1312
1332
  const defaults = [
1313
1333
  {
@@ -1337,6 +1357,7 @@ class Server {
1337
1357
  compress: item.compress,
1338
1358
  _path: item.path.str(),
1339
1359
  _templates: item.templates,
1360
+ _server: this,
1340
1361
  })
1341
1362
  ._load_data_by_path(this));
1342
1363
  });
@@ -1345,6 +1366,11 @@ class Server {
1345
1366
  }
1346
1367
  // Create the sitemap endpoint.
1347
1368
  _create_sitemap() {
1369
+ // Logs.
1370
+ if (this.lightweight) {
1371
+ return;
1372
+ }
1373
+ logger_js_1.default.log(2, log_source, "Creating sitemap.");
1348
1374
  let sitemap = "";
1349
1375
  sitemap += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
1350
1376
  sitemap += "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
@@ -1360,16 +1386,22 @@ class Server {
1360
1386
  sitemap += `<url>\n <loc>${this.full_domain}/${endpoint}</loc>\n</url>\n`;
1361
1387
  });
1362
1388
  sitemap += "</urlset>\n";
1363
- this.endpoint(new endpoint_js_1.Endpoint({
1389
+ this.endpoint({
1364
1390
  method: "GET",
1365
1391
  endpoint: "/sitemap.xml",
1366
1392
  data: sitemap,
1367
1393
  content_type: "application/xml",
1368
1394
  compress: false,
1369
- }));
1395
+ });
1370
1396
  }
1371
1397
  // Create the robots.txt endpoint.
1372
1398
  _create_robots_txt() {
1399
+ // Logs.
1400
+ if (this.lightweight) {
1401
+ return;
1402
+ }
1403
+ logger_js_1.default.log(2, log_source, "Creating robots.txt.");
1404
+ // Proceed.
1373
1405
  let robots = "User-agent: *\n";
1374
1406
  let disallowed = 0;
1375
1407
  for (const endpoint of this.endpoints.values()) {
@@ -1382,36 +1414,44 @@ class Server {
1382
1414
  robots += `Disallow: \n`;
1383
1415
  }
1384
1416
  robots += `\nSitemap: ${this.full_domain}/sitemap.xml`;
1385
- this.endpoint(new endpoint_js_1.Endpoint({
1417
+ this.endpoint({
1386
1418
  method: "GET",
1387
1419
  endpoint: "/robots.txt",
1388
1420
  content_type: "text/plain",
1389
1421
  data: robots,
1390
1422
  compress: false,
1391
- }));
1423
+ });
1392
1424
  }
1393
1425
  // Create admin endpoint.
1394
- _create_admin_endpoint() {
1426
+ // @deprecated use MongoDB Atlas instead!
1427
+ /* private _create_admin_endpoint(): void {
1428
+
1429
+ // Logs.
1430
+ if (this.lightweight) { return; }
1431
+ logger.log(2, log_source, "Creating admin endpoint.");
1432
+
1395
1433
  // Add admin tokens.
1396
1434
  this.admin.tokens = [];
1435
+
1397
1436
  // Verify token.
1398
- const verify_token = (token) => {
1437
+ const verify_token = (token: string): boolean => {
1399
1438
  const now = Date.now();
1400
- let new_tokens = [];
1439
+ let new_tokens: Array<{token: string, expiration: number}> = [];
1401
1440
  let verified = false;
1402
- this.admin.tokens.forEach((i) => {
1441
+ this.admin.tokens!.forEach((i) => {
1403
1442
  if (now < i.expiration) {
1404
1443
  if (i.token === token) {
1405
1444
  verified = true;
1406
1445
  }
1407
1446
  new_tokens.push(i);
1408
1447
  }
1409
- });
1448
+ })
1410
1449
  this.admin.tokens = new_tokens;
1411
1450
  return verified;
1412
- };
1451
+ }
1452
+
1413
1453
  // Admin data.
1414
- this.endpoint(new endpoint_js_1.Endpoint({
1454
+ this.endpoint({
1415
1455
  method: "POST",
1416
1456
  endpoint: "/admin/auth",
1417
1457
  content_type: "application/json",
@@ -1424,31 +1464,34 @@ class Server {
1424
1464
  password: "string",
1425
1465
  },
1426
1466
  ip_whitelist: this.admin.ips,
1427
- callback: async (stream, params) => {
1467
+ callback: async (stream: any, params: {password: string}) => {
1428
1468
  // Check key.
1429
1469
  if (params.password !== this.admin.password) {
1430
1470
  return stream.send({
1431
1471
  status: 403,
1432
- headers: { "Content-Type": "text/plain" },
1472
+ headers: {"Content-Type": "text/plain"},
1433
1473
  data: "Access Denied",
1434
- });
1474
+ })
1435
1475
  }
1476
+
1436
1477
  // Generate token.
1437
1478
  const token = {
1438
1479
  token: String.random(32),
1439
1480
  expiration: Date.now() + 3600 * 1000,
1440
1481
  };
1441
- this.admin.tokens.push(token);
1482
+ this.admin.tokens!.push(token)
1483
+
1442
1484
  // Response.
1443
1485
  return stream.send({
1444
1486
  status: 200,
1445
- headers: { "Content-Type": "application/json" },
1487
+ headers: {"Content-Type": "application/json"},
1446
1488
  data: token,
1447
- });
1489
+ })
1448
1490
  },
1449
- }));
1491
+ })
1492
+
1450
1493
  // Admin data.
1451
- this.endpoint(new endpoint_js_1.Endpoint({
1494
+ this.endpoint({
1452
1495
  method: "GET",
1453
1496
  endpoint: "/admin/data",
1454
1497
  content_type: "application/json",
@@ -1457,20 +1500,23 @@ class Server {
1457
1500
  token: "string",
1458
1501
  },
1459
1502
  ip_whitelist: this.admin.ips,
1460
- callback: async (stream, params) => {
1503
+ callback: async (stream: any, params: {token: string}) => {
1461
1504
  // Verify token.
1462
1505
  if (!verify_token(params.token)) {
1463
1506
  return stream.send({
1464
1507
  status: 403,
1465
- headers: { "Content-Type": "text/plain" },
1508
+ headers: {"Content-Type": "text/plain"},
1466
1509
  data: "Access Denied",
1467
- });
1510
+ })
1468
1511
  }
1512
+
1469
1513
  // Data.
1470
- const data = {};
1514
+ const data: Record<string, any> = {};
1515
+
1471
1516
  // Parse subscriptions.
1472
1517
  const subscriptions = await this.payments._get_all_active_subscriptions();
1473
1518
  data.subscriptions = subscriptions.length;
1519
+
1474
1520
  // Load data.
1475
1521
  const status = await this._sys_db.load("status", {
1476
1522
  default: {
@@ -1480,22 +1526,26 @@ class Server {
1480
1526
  }
1481
1527
  });
1482
1528
  Object.assign(data, status);
1529
+
1483
1530
  // System data.
1484
- data.cpu_usage = _vinc_1.vlib.System.cpu_usage();
1485
- data.memory_usage = _vinc_1.vlib.System.memory_usage();
1486
- data.network_usage = await _vinc_1.vlib.System.network_usage();
1531
+ data.cpu_usage = vlib.System.cpu_usage();
1532
+ data.memory_usage = vlib.System.memory_usage();
1533
+ data.network_usage = await vlib.System.network_usage();
1534
+
1487
1535
  // Users.
1488
1536
  data.users = (await this.users.list()).length;
1537
+
1489
1538
  // Response.
1490
1539
  return stream.send({
1491
1540
  status: 200,
1492
- headers: { "Content-Type": "application/json" },
1541
+ headers: {"Content-Type": "application/json"},
1493
1542
  data: data,
1494
- });
1543
+ })
1495
1544
  },
1496
- }));
1545
+ })
1546
+
1497
1547
  // Admin view.
1498
- this.endpoint(new endpoint_js_1.Endpoint({
1548
+ this.endpoint({
1499
1549
  method: "GET",
1500
1550
  endpoint: "/admin",
1501
1551
  content_type: "application/json",
@@ -1519,14 +1569,17 @@ class Server {
1519
1569
  sub_fg: "#9099B4",
1520
1570
  border: "#D6D6D6",
1521
1571
  tint: "#64B878", //"#8EB8EB", //"#4E9CF7",
1522
- };
1572
+ }
1573
+
1523
1574
  // ... rest of the admin view implementation remains the same as it's client-side JavaScript ...
1524
1575
  },
1525
1576
  },
1526
- }));
1527
- }
1577
+ })
1578
+ } */
1528
1579
  // Initialize statics.
1529
1580
  async _initialize_statics() {
1581
+ // Logs.
1582
+ logger_js_1.default.log(2, log_source, "Initializing static directories.");
1530
1583
  // Static paths for the file watcher.
1531
1584
  const static_paths = [];
1532
1585
  // Add static file.
@@ -1546,6 +1599,7 @@ class Server {
1546
1599
  cache,
1547
1600
  rate_limit: "global",
1548
1601
  _is_static: true,
1602
+ _server: this,
1549
1603
  });
1550
1604
  const aspect_ratio = await e.get_aspect_ratio();
1551
1605
  if (aspect_ratio != null) {
@@ -1565,6 +1619,7 @@ class Server {
1565
1619
  rate_limit: "global",
1566
1620
  _path: path.str(),
1567
1621
  _is_static: true,
1622
+ _server: this,
1568
1623
  })
1569
1624
  ._load_data_by_path(this));
1570
1625
  }
@@ -1668,177 +1723,13 @@ class Server {
1668
1723
  // Response.
1669
1724
  return static_paths;
1670
1725
  }
1671
- // @todo this one is not TS
1672
- // Initialize, compile & bundle js & ts.
1673
- async _init_ts() {
1674
- // Create dir.
1675
- // Use ts.output instead of a /tmp/ dir since the node_modules for example is not present here.
1676
- const tmp_volt_ts = new _vinc_1.vlib.Path(this.ts.output ?? "/tmp/ts-dummy/").abs();
1677
- if (this.ts.output && !tmp_volt_ts.exists()) {
1678
- tmp_volt_ts.mkdir_sync();
1679
- }
1680
- // Gather all entry paths.
1681
- const server = this;
1682
- let has_ts = false;
1683
- const volt_frontend = new _vinc_1.vlib.Path(`${__dirname}/../../../frontend/dist/`).abs().str();
1684
- const input_paths = [
1685
- volt_frontend + "/volt.js",
1686
- ];
1687
- const entries = {};
1688
- for (const endpoint of this.endpoints.values()) {
1689
- if (endpoint.view?.is_js_ts_view) {
1690
- input_paths.push(endpoint.view.source_path.str());
1691
- let output_path = tmp_volt_ts.join(endpoint.view.source_path).abs();
1692
- const extension = output_path.extension();
1693
- if (!has_ts && /.tsx?/.test(extension)) {
1694
- has_ts = true;
1695
- }
1696
- const output = output_path.str().slice(0, -extension.length) + ".js";
1697
- if (entries[output] === undefined) {
1698
- entries[output] = {
1699
- endpoints: [endpoint],
1700
- path: output,
1701
- extension,
1702
- async bundle() {
1703
- server.rate_limit?.reset_all(); // reset api limits.
1704
- let bundle = undefined;
1705
- let had_bundle = this.endpoints[0]?.view?.bundle != null;
1706
- for (let e = 0; e < this.endpoints.length; e++) {
1707
- if (bundle === undefined) {
1708
- bundle = await this.endpoints[e]?.view?._bundle_ts(this.path);
1709
- }
1710
- else {
1711
- await this.endpoints[e]?.view?._bundle_ts(this.path, bundle);
1712
- }
1713
- if (had_bundle && server.browser_preview) {
1714
- await server.browser_preview.refresh(this.endpoints[e].endpoint);
1715
- }
1716
- }
1717
- },
1718
- };
1719
- }
1720
- else {
1721
- entries[output].endpoints.push(endpoint);
1722
- }
1723
- }
1724
- }
1725
- const entry_values = Object.values(entries);
1726
- if (has_ts && this.ts.output == null) {
1727
- throw new Error(`Due to detected typescript endpoint source files the output path attribute "Server.ts.output" must be defined.`);
1728
- }
1729
- // For production just compile & bundle.
1730
- if (this.is_file_watcher || this.production) {
1731
- await TSCompiler.compile({
1732
- entry_paths: input_paths,
1733
- output: tmp_volt_ts.str(),
1734
- preprocess: TSPreprocessing.volt_auto_imports,
1735
- compiler_opts: {
1736
- target: "ES2021",
1737
- module: "esnext",
1738
- moduleResolution: "node",
1739
- lib: ["ES2021", "DOM"],
1740
- declaration: false,
1741
- strict: true,
1742
- esModuleInterop: true,
1743
- allowJs: true,
1744
- checkJs: false,
1745
- noImplicitAny: false,
1746
- skipLibCheck: true,
1747
- types: [],
1748
- ...this.ts.compiler_opts,
1749
- rootDir: "/", // @warning is required to reliably match input and output file paths.
1750
- },
1751
- });
1752
- let excluded = new Set();
1753
- for (let i = 0; i < entry_values.length; i++) {
1754
- await entry_values[i].bundle();
1755
- // Add file watcher excludes.
1756
- if (this.is_file_watcher) {
1757
- for (const endpoint of entry_values[i].endpoints) {
1758
- // console.log(entry_values[i].path, endpoint.view.bundle.inputs)
1759
- for (let path of endpoint.view?.bundle?.inputs ?? []) {
1760
- const vpath = new _vinc_1.vlib.Path(path).abs();
1761
- const ext = vpath.extension();
1762
- path = vpath.str();
1763
- if (path.startsWith(tmp_volt_ts.str())) {
1764
- const js_path = path.slice(tmp_volt_ts.str().length);
1765
- const ts_path = path.slice(tmp_volt_ts.str().length, -ext.length) + ".ts";
1766
- if (new _vinc_1.vlib.Path(js_path).exists() && !excluded.has(js_path)) {
1767
- // console.log("Exclude", js_path)
1768
- excluded.add(js_path);
1769
- this.file_watcher.add_exclude(js_path);
1770
- }
1771
- if (new _vinc_1.vlib.Path(ts_path).exists() && !excluded.has(ts_path)) {
1772
- // console.log("Exclude", ts_path)
1773
- excluded.add(ts_path);
1774
- this.file_watcher.add_exclude(ts_path);
1775
- }
1776
- }
1777
- }
1778
- // process.exit(1)
1779
- }
1780
- }
1781
- }
1782
- }
1783
- // Development.
1784
- else {
1785
- // Compile with watcher enabled.
1786
- const res = await TSCompiler.compile({
1787
- entry_paths: input_paths,
1788
- output: tmp_volt_ts.str(),
1789
- preprocess: TSPreprocessing.volt_auto_imports,
1790
- error_limit: 10,
1791
- compiler_opts: {
1792
- target: "ES2021",
1793
- module: "esnext",
1794
- moduleResolution: "node",
1795
- lib: ["ES2021", "DOM"],
1796
- declaration: false,
1797
- strict: true,
1798
- esModuleInterop: true,
1799
- allowJs: true,
1800
- checkJs: false,
1801
- noImplicitAny: false,
1802
- skipLibCheck: true,
1803
- types: [],
1804
- ...this.ts.compiler_opts,
1805
- rootDir: "/", // @warning is required to reliably match input and output file paths.
1806
- },
1807
- watch: {
1808
- enabled: true,
1809
- log_level: 0,
1810
- on_change: async (file_name) => {
1811
- // console.log("File", file_name, "has changed.")
1812
- logger_js_1.default.log(2, log_source, `Typescript output file ${file_name} has changed.`);
1813
- // Check if the file path is part of an endpoint.
1814
- const entry = entries[file_name];
1815
- if (entry != null) {
1816
- await entry.bundle();
1817
- }
1818
- // Check every other entries inputs' to see if that entry should be rebundled as well.
1819
- for (let i = 0; i < entry_values.length; i++) {
1820
- const entry = entry_values[i];
1821
- if (entry.path !== file_name && entry.endpoints.iterate(e => e.view?.bundle?.inputs?.includes(file_name) ? true : undefined)) {
1822
- await entry.bundle();
1823
- }
1824
- }
1825
- },
1826
- },
1827
- });
1828
- if (res.errors.length > 0) {
1829
- res.debug();
1830
- }
1831
- for (let i = 0; i < entry_values.length; i++) {
1832
- await entry_values[i].bundle();
1833
- }
1834
- this._stop_tscompiler_watcher = res.stop;
1835
- }
1836
- }
1837
1726
  // ---------------------------------------------------------
1838
1727
  // Server (private).
1839
1728
  // Initialize.
1840
1729
  // Initialize.
1841
1730
  async initialize() {
1731
+ // Logs.
1732
+ logger_js_1.default.log(1, log_source, "Initializing server.");
1842
1733
  /* @performance */ this.performance.start();
1843
1734
  // File watcher.
1844
1735
  if (this.is_file_watcher) {
@@ -1847,9 +1738,9 @@ class Server {
1847
1738
  // Create default endpoints for excluded static file watch paths.
1848
1739
  this._create_default_endpoints();
1849
1740
  // Exclude the typescript output directory from the file watcher.
1850
- if (this.ts.output) {
1851
- this.file_watcher.add_exclude(this.ts.output);
1852
- }
1741
+ // if (this.ts.output) {
1742
+ // this.file_watcher!.add_exclude(this.ts.output);
1743
+ // }
1853
1744
  // Add the volt backend source files to the additional files.
1854
1745
  this.file_watcher.add_path(__dirname);
1855
1746
  this.file_watcher.add_exclude(`${__dirname}/frontend_globals.js`);
@@ -1866,15 +1757,6 @@ class Server {
1866
1757
  this.file_watcher.add_exclude(item.path);
1867
1758
  }
1868
1759
  });
1869
- // Initialize all endpoints since this is required for _init_ts()
1870
- for (const endpoint of this.endpoints.values()) {
1871
- await endpoint._initialize(this);
1872
- }
1873
- for (const endpoint of this.err_endpoints.values()) {
1874
- await endpoint._initialize(this);
1875
- }
1876
- // Add typescript/js view endpoint excludes.
1877
- await this._init_ts();
1878
1760
  if (!this.production) {
1879
1761
  [
1880
1762
  `${process.env.PERSISTANCE}/private/dev/vinc/vlib/js/vlib.js`,
@@ -1935,9 +1817,9 @@ class Server {
1935
1817
  if (this.db) {
1936
1818
  await this.db.initialize();
1937
1819
  // Database collections.
1938
- this._sys_db = this.db.create_collection("_sys"); // the volt sys collection.
1820
+ this._sys_db = await this.db.create_collection("_sys"); // the volt sys collection.
1939
1821
  // Accessible collections.
1940
- this.storage = this.db.create_collection("_storage"); // the sys backend storage collection for the user's server.
1822
+ this.storage = await this.db.create_collection("_storage"); // the sys backend storage collection for the user's server.
1941
1823
  /* @performance */ this.performance.end("init-db");
1942
1824
  // Load keys.
1943
1825
  const keys_document = await this._sys_db.load("keys");
@@ -2004,30 +1886,21 @@ class Server {
2004
1886
  this._create_default_endpoints();
2005
1887
  /* @performance */ this.performance.end("create-default-endpoints");
2006
1888
  // Create admin endpoints.
2007
- this._create_admin_endpoint();
2008
- /* @performance */ this.performance.end("create-admin-endpoints");
1889
+ // this._create_admin_endpoint();
1890
+ // /* @performance */ this.performance.end("create-admin-endpoints");
2009
1891
  // Create static endpoints.
2010
1892
  await this._initialize_statics();
2011
1893
  /* @performance */ this.performance.end("create-static-endpoints");
2012
- // Initialize all endpoints.
2013
- // Must be done after initializing static and default endpoints to support html embeddings.
2014
- for (const endpoint of this.endpoints.values()) {
2015
- await endpoint._initialize(this);
2016
- }
2017
- for (const endpoint of this.err_endpoints.values()) {
2018
- await endpoint._initialize(this);
2019
- }
2020
- /* @performance */ this.performance.end("init-endpoints");
2021
1894
  // Initialize users.
2022
1895
  if (this.db) {
2023
- this.users._initialize();
1896
+ await this.users._initialize();
2024
1897
  /* @performance */ this.performance.end("init-users");
2025
1898
  }
2026
1899
  // Database preview endpoints (only when production mode is disabled).
2027
- if (this.db) {
2028
- this.db._initialize_db_preview();
2029
- /* @performance */ this.performance.end("init-db-preview");
2030
- }
1900
+ // if (this.db) {
1901
+ // this.db._initialize_db_preview();
1902
+ // /* @performance */ this.performance.end("init-db-preview");
1903
+ // }
2031
1904
  // Payments.
2032
1905
  if (this.payments !== undefined) {
2033
1906
  await this.payments._initialize();
@@ -2281,9 +2154,9 @@ class Server {
2281
2154
  return;
2282
2155
  }
2283
2156
  // Start static file watcher.
2284
- if (!this.production) {
2285
- this.static_file_watcher.start();
2286
- }
2157
+ // if (!this.production && this.file_watcher) {
2158
+ // this.static_file_watcher.start();
2159
+ // }
2287
2160
  // Start the rate limiting client/server, also when forking.
2288
2161
  if (this.db) {
2289
2162
  /* @performance */ this.performance.start();
@@ -2292,11 +2165,10 @@ class Server {
2292
2165
  }
2293
2166
  /* @performance */ this.performance.end("init-rate-limit");
2294
2167
  }
2295
- // Initialize, compile and bundle ts and js.
2296
- await this._init_ts();
2297
2168
  // Production & Master.
2298
2169
  let forked = false;
2299
- if (this.production && this.multiprocessing && cluster_1.default.isPrimary) {
2170
+ if (this.production && this.multiprocessing && cluster_1.default.isPrimary && this.processes > 1) {
2171
+ this.log(0, `Starting ${this.processes} threads.`);
2300
2172
  // Vars.
2301
2173
  let active_threads = 0;
2302
2174
  const thread_ids = {};
@@ -2355,6 +2227,11 @@ class Server {
2355
2227
  }
2356
2228
  else {
2357
2229
  forked = this.production && this.multiprocessing;
2230
+ // Load worker class modules.
2231
+ // if (libcluster.isWorker) {
2232
+ // const worker = new WorkerClass();
2233
+ // worker.start();
2234
+ // }
2358
2235
  // Set default port.
2359
2236
  let http_port, https_port;
2360
2237
  if (this.port == null) {
@@ -2424,11 +2301,14 @@ class Server {
2424
2301
  }
2425
2302
  }
2426
2303
  // Start browser preview on primary node.
2427
- if (this.browser_preview && !forked) {
2428
- await this.browser_preview.start();
2429
- await this.browser_preview.navigate(this.full_domain);
2304
+ // if (this.browser_preview && !forked) {
2305
+ // await this.browser_preview.start();
2306
+ // await this.browser_preview.navigate(this.full_domain);
2307
+ // }
2308
+ /* @performance */
2309
+ if (logger_js_1.default.log_level >= 2) {
2310
+ this.performance.dump();
2430
2311
  }
2431
- // /* @performance */ this.performance.dump();
2432
2312
  }
2433
2313
  /* @docs:
2434
2314
  * @title: On start
@@ -2469,9 +2349,9 @@ class Server {
2469
2349
  logger_js_1.default.log(0, log_source, "Stopping typescript watcher.");
2470
2350
  this._stop_tscompiler_watcher();
2471
2351
  }
2472
- if (this.static_file_watcher) {
2473
- this.static_file_watcher.stop();
2474
- }
2352
+ // if (this.static_file_watcher) {
2353
+ // this.static_file_watcher.stop();
2354
+ // }
2475
2355
  // Stop sockets.
2476
2356
  if (this.https) {
2477
2357
  await this.https.close();
@@ -2698,18 +2578,19 @@ class Server {
2698
2578
  */
2699
2579
  endpoint(...endpoints) {
2700
2580
  for (let i = 0; i < endpoints.length; i++) {
2701
- let init_endpoint = endpoints[i];
2702
2581
  // Skip.
2703
- if (init_endpoint == null) {
2582
+ if (endpoints[i] == null) {
2704
2583
  continue;
2705
2584
  }
2706
2585
  // Is array of endpoints.
2707
- if (Array.isArray(init_endpoint)) {
2708
- this.endpoint(...init_endpoint);
2586
+ if (Array.isArray(endpoints[i])) {
2587
+ this.endpoint(...endpoints[i]);
2709
2588
  continue;
2710
2589
  }
2711
2590
  // Initialize endpoint.
2591
+ let init_endpoint = endpoints[i];
2712
2592
  if (!(init_endpoint instanceof endpoint_js_1.Endpoint)) {
2593
+ init_endpoint._server = this;
2713
2594
  init_endpoint = new endpoint_js_1.Endpoint(init_endpoint);
2714
2595
  }
2715
2596
  const endpoint = init_endpoint;
@@ -2728,7 +2609,7 @@ class Server {
2728
2609
  if (endpoint._path && this.file_watcher?.add_exclude) {
2729
2610
  this.file_watcher.add_exclude(endpoint._path);
2730
2611
  }
2731
- this.static_file_watcher.add(endpoint);
2612
+ // this.static_file_watcher.add(endpoint);
2732
2613
  }
2733
2614
  }
2734
2615
  return this;
@@ -2759,7 +2640,7 @@ class Server {
2759
2640
  @type: Endpoint, object
2760
2641
  */
2761
2642
  error_endpoint(status_code, endpoint) {
2762
- this.err_endpoints.set(status_code, endpoint instanceof endpoint_js_1.Endpoint ? endpoint : new endpoint_js_1.Endpoint(endpoint));
2643
+ this.err_endpoints.set(status_code, endpoint instanceof endpoint_js_1.Endpoint ? endpoint : new endpoint_js_1.Endpoint({ ...endpoint, _server: this }));
2763
2644
  return this;
2764
2645
  }
2765
2646
  // ---------------------------------------------------------