@vandenberghinc/volt 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vrepo +28 -0
- package/.vscode/tasks.json +87 -0
- package/README.md +67 -0
- package/backend/dist/cjs/blacklist.d.ts +10 -0
- package/backend/dist/cjs/blacklist.js +53 -0
- package/backend/dist/cjs/cli.d.ts +2 -0
- package/backend/dist/cjs/cli.js +263 -0
- package/backend/dist/cjs/database.d.ts +364 -0
- package/backend/dist/cjs/database.js +1962 -0
- package/backend/dist/cjs/endpoint.d.ts +57 -0
- package/backend/dist/cjs/endpoint.js +425 -0
- package/backend/dist/cjs/file_watcher.d.ts +44 -0
- package/backend/dist/cjs/file_watcher.js +348 -0
- package/backend/dist/cjs/frontend.d.ts +13 -0
- package/backend/dist/cjs/frontend.js +30 -0
- package/backend/dist/cjs/image_endpoint.d.ts +24 -0
- package/backend/dist/cjs/image_endpoint.js +210 -0
- package/backend/dist/cjs/logger.d.ts +5 -0
- package/backend/dist/cjs/logger.js +16 -0
- package/backend/dist/cjs/meta.d.ts +50 -0
- package/backend/dist/cjs/meta.js +153 -0
- package/backend/dist/cjs/mutex.d.ts +24 -0
- package/backend/dist/cjs/mutex.js +52 -0
- package/backend/dist/cjs/package.json +1 -0
- package/backend/dist/cjs/payments/paddle.d.ts +161 -0
- package/backend/dist/cjs/payments/paddle.js +2301 -0
- package/backend/dist/cjs/plugins/browser.d.ts +36 -0
- package/backend/dist/cjs/plugins/browser.js +183 -0
- package/backend/dist/cjs/plugins/communication.d.ts +70 -0
- package/backend/dist/cjs/plugins/communication.js +177 -0
- package/backend/dist/cjs/plugins/css.d.ts +10 -0
- package/backend/dist/cjs/plugins/css.js +71 -0
- package/backend/dist/cjs/plugins/mail.d.ts +277 -0
- package/backend/dist/cjs/plugins/mail.js +1419 -0
- package/backend/dist/cjs/plugins/pdf.d.ts +757 -0
- package/backend/dist/cjs/plugins/pdf.js +1694 -0
- package/backend/dist/cjs/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/cjs/plugins/thread_monitor.js +127 -0
- package/backend/dist/cjs/plugins/ts/compiler.d.ts +132 -0
- package/backend/dist/cjs/plugins/ts/compiler.js +944 -0
- package/backend/dist/cjs/plugins/ts/preprocessing.d.ts +14 -0
- package/backend/dist/cjs/plugins/ts/preprocessing.js +762 -0
- package/backend/dist/cjs/rate_limit.d.ts +65 -0
- package/backend/dist/cjs/rate_limit.js +463 -0
- package/backend/dist/cjs/request.deprc.d.ts +48 -0
- package/backend/dist/cjs/request.deprc.js +572 -0
- package/backend/dist/cjs/response.deprc.d.ts +55 -0
- package/backend/dist/cjs/response.deprc.js +275 -0
- package/backend/dist/cjs/server.d.ts +311 -0
- package/backend/dist/cjs/server.js +3475 -0
- package/backend/dist/cjs/splash_screen.d.ts +35 -0
- package/backend/dist/cjs/splash_screen.js +152 -0
- package/backend/dist/cjs/status.d.ts +60 -0
- package/backend/dist/cjs/status.js +199 -0
- package/backend/dist/cjs/stream.d.ts +75 -0
- package/backend/dist/cjs/stream.js +954 -0
- package/backend/dist/cjs/users.d.ts +111 -0
- package/backend/dist/cjs/users.js +1945 -0
- package/backend/dist/cjs/utils.d.ts +27 -0
- package/backend/dist/cjs/utils.js +329 -0
- package/backend/dist/cjs/view.d.ts +52 -0
- package/backend/dist/cjs/view.js +568 -0
- package/backend/dist/cjs/vinc.d.ts +2 -0
- package/backend/dist/cjs/vinc.dev.d.ts +2 -0
- package/backend/dist/cjs/vinc.dev.js +42 -0
- package/backend/dist/cjs/vinc.js +42 -0
- package/backend/dist/cjs/volt.d.ts +15 -0
- package/backend/dist/cjs/volt.js +64 -0
- package/backend/dist/css/adyen.css +92 -0
- package/backend/dist/css/volt.css +65 -0
- package/backend/dist/esm/blacklist.d.ts +10 -0
- package/backend/dist/esm/blacklist.js +49 -0
- package/backend/dist/esm/cli.d.ts +2 -0
- package/backend/dist/esm/cli.js +228 -0
- package/backend/dist/esm/database.d.ts +364 -0
- package/backend/dist/esm/database.js +1957 -0
- package/backend/dist/esm/endpoint.d.ts +57 -0
- package/backend/dist/esm/endpoint.js +421 -0
- package/backend/dist/esm/file_watcher.d.ts +44 -0
- package/backend/dist/esm/file_watcher.js +313 -0
- package/backend/dist/esm/frontend.d.ts +13 -0
- package/backend/dist/esm/frontend.js +27 -0
- package/backend/dist/esm/image_endpoint.d.ts +24 -0
- package/backend/dist/esm/image_endpoint.js +206 -0
- package/backend/dist/esm/logger.d.ts +5 -0
- package/backend/dist/esm/logger.js +13 -0
- package/backend/dist/esm/meta.d.ts +50 -0
- package/backend/dist/esm/meta.js +149 -0
- package/backend/dist/esm/mutex.d.ts +24 -0
- package/backend/dist/esm/mutex.js +48 -0
- package/backend/dist/esm/payments/paddle.d.ts +161 -0
- package/backend/dist/esm/payments/paddle.js +2261 -0
- package/backend/dist/esm/plugins/browser.d.ts +36 -0
- package/backend/dist/esm/plugins/browser.js +176 -0
- package/backend/dist/esm/plugins/communication.d.ts +70 -0
- package/backend/dist/esm/plugins/communication.js +169 -0
- package/backend/dist/esm/plugins/css.d.ts +10 -0
- package/backend/dist/esm/plugins/css.js +64 -0
- package/backend/dist/esm/plugins/mail.d.ts +277 -0
- package/backend/dist/esm/plugins/mail.js +1403 -0
- package/backend/dist/esm/plugins/pdf.d.ts +757 -0
- package/backend/dist/esm/plugins/pdf.js +1694 -0
- package/backend/dist/esm/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/esm/plugins/thread_monitor.js +120 -0
- package/backend/dist/esm/plugins/ts/compiler.d.ts +132 -0
- package/backend/dist/esm/plugins/ts/compiler.js +907 -0
- package/backend/dist/esm/plugins/ts/preprocessing.d.ts +14 -0
- package/backend/dist/esm/plugins/ts/preprocessing.js +724 -0
- package/backend/dist/esm/rate_limit.d.ts +65 -0
- package/backend/dist/esm/rate_limit.js +425 -0
- package/backend/dist/esm/request.deprc.d.ts +48 -0
- package/backend/dist/esm/request.deprc.js +572 -0
- package/backend/dist/esm/response.deprc.d.ts +55 -0
- package/backend/dist/esm/response.deprc.js +275 -0
- package/backend/dist/esm/server.d.ts +311 -0
- package/backend/dist/esm/server.js +3435 -0
- package/backend/dist/esm/splash_screen.d.ts +35 -0
- package/backend/dist/esm/splash_screen.js +148 -0
- package/backend/dist/esm/status.d.ts +60 -0
- package/backend/dist/esm/status.js +196 -0
- package/backend/dist/esm/stream.d.ts +75 -0
- package/backend/dist/esm/stream.js +947 -0
- package/backend/dist/esm/users.d.ts +111 -0
- package/backend/dist/esm/users.js +1908 -0
- package/backend/dist/esm/utils.d.ts +27 -0
- package/backend/dist/esm/utils.js +324 -0
- package/backend/dist/esm/view.d.ts +52 -0
- package/backend/dist/esm/view.js +561 -0
- package/backend/dist/esm/vinc.d.ts +2 -0
- package/backend/dist/esm/vinc.dev.d.ts +2 -0
- package/backend/dist/esm/vinc.dev.js +6 -0
- package/backend/dist/esm/vinc.js +6 -0
- package/backend/dist/esm/volt.d.ts +15 -0
- package/backend/dist/esm/volt.js +23 -0
- package/backend/dist/esm-dev/blacklist.d.ts +10 -0
- package/backend/dist/esm-dev/blacklist.js +49 -0
- package/backend/dist/esm-dev/cli.d.ts +2 -0
- package/backend/dist/esm-dev/cli.js +228 -0
- package/backend/dist/esm-dev/database.d.ts +364 -0
- package/backend/dist/esm-dev/database.js +1957 -0
- package/backend/dist/esm-dev/endpoint.d.ts +57 -0
- package/backend/dist/esm-dev/endpoint.js +421 -0
- package/backend/dist/esm-dev/file_watcher.d.ts +44 -0
- package/backend/dist/esm-dev/file_watcher.js +313 -0
- package/backend/dist/esm-dev/frontend.d.ts +13 -0
- package/backend/dist/esm-dev/frontend.js +27 -0
- package/backend/dist/esm-dev/image_endpoint.d.ts +24 -0
- package/backend/dist/esm-dev/image_endpoint.js +206 -0
- package/backend/dist/esm-dev/logger.d.ts +5 -0
- package/backend/dist/esm-dev/logger.js +13 -0
- package/backend/dist/esm-dev/meta.d.ts +50 -0
- package/backend/dist/esm-dev/meta.js +149 -0
- package/backend/dist/esm-dev/mutex.d.ts +24 -0
- package/backend/dist/esm-dev/mutex.js +48 -0
- package/backend/dist/esm-dev/payments/paddle.d.ts +161 -0
- package/backend/dist/esm-dev/payments/paddle.js +2261 -0
- package/backend/dist/esm-dev/plugins/browser.d.ts +36 -0
- package/backend/dist/esm-dev/plugins/browser.js +176 -0
- package/backend/dist/esm-dev/plugins/communication.d.ts +70 -0
- package/backend/dist/esm-dev/plugins/communication.js +169 -0
- package/backend/dist/esm-dev/plugins/css.d.ts +10 -0
- package/backend/dist/esm-dev/plugins/css.js +64 -0
- package/backend/dist/esm-dev/plugins/mail.d.ts +277 -0
- package/backend/dist/esm-dev/plugins/mail.js +1403 -0
- package/backend/dist/esm-dev/plugins/pdf.d.ts +757 -0
- package/backend/dist/esm-dev/plugins/pdf.js +1694 -0
- package/backend/dist/esm-dev/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/esm-dev/plugins/thread_monitor.js +120 -0
- package/backend/dist/esm-dev/plugins/ts/compiler.d.ts +132 -0
- package/backend/dist/esm-dev/plugins/ts/compiler.js +907 -0
- package/backend/dist/esm-dev/plugins/ts/preprocessing.d.ts +14 -0
- package/backend/dist/esm-dev/plugins/ts/preprocessing.js +724 -0
- package/backend/dist/esm-dev/rate_limit.d.ts +65 -0
- package/backend/dist/esm-dev/rate_limit.js +425 -0
- package/backend/dist/esm-dev/request.deprc.d.ts +48 -0
- package/backend/dist/esm-dev/request.deprc.js +572 -0
- package/backend/dist/esm-dev/response.deprc.d.ts +55 -0
- package/backend/dist/esm-dev/response.deprc.js +275 -0
- package/backend/dist/esm-dev/server.d.ts +311 -0
- package/backend/dist/esm-dev/server.js +3435 -0
- package/backend/dist/esm-dev/splash_screen.d.ts +35 -0
- package/backend/dist/esm-dev/splash_screen.js +148 -0
- package/backend/dist/esm-dev/status.d.ts +60 -0
- package/backend/dist/esm-dev/status.js +196 -0
- package/backend/dist/esm-dev/stream.d.ts +75 -0
- package/backend/dist/esm-dev/stream.js +947 -0
- package/backend/dist/esm-dev/users.d.ts +111 -0
- package/backend/dist/esm-dev/users.js +1908 -0
- package/backend/dist/esm-dev/utils.d.ts +27 -0
- package/backend/dist/esm-dev/utils.js +324 -0
- package/backend/dist/esm-dev/view.d.ts +52 -0
- package/backend/dist/esm-dev/view.js +561 -0
- package/backend/dist/esm-dev/vinc.d.ts +2 -0
- package/backend/dist/esm-dev/vinc.dev.d.ts +2 -0
- package/backend/dist/esm-dev/vinc.dev.js +6 -0
- package/backend/dist/esm-dev/vinc.js +6 -0
- package/backend/dist/esm-dev/volt.d.ts +15 -0
- package/backend/dist/esm-dev/volt.js +23 -0
- package/backend/src/blacklist.ts +69 -0
- package/backend/src/cli.js +245 -0
- package/backend/src/database.ts +2241 -0
- package/backend/src/endpoint.ts +494 -0
- package/backend/src/file_watcher.ts +359 -0
- package/backend/src/frontend.ts +35 -0
- package/backend/src/globals.d.ts +8 -0
- package/backend/src/image_endpoint.ts +258 -0
- package/backend/src/logger.ts +18 -0
- package/backend/src/meta.ts +202 -0
- package/backend/src/mutex.ts +51 -0
- package/backend/src/payments/paddle.ts +2659 -0
- package/backend/src/plugins/browser.ts +188 -0
- package/backend/src/plugins/communication.ts +204 -0
- package/backend/src/plugins/css.ts +84 -0
- package/backend/src/plugins/fonts/Menlo-Bold.ttf +0 -0
- package/backend/src/plugins/fonts/Menlo-Regular.ttf +0 -0
- package/backend/src/plugins/mail.ts +1720 -0
- package/backend/src/plugins/pdf.js +1932 -0
- package/backend/src/plugins/thread_monitor.ts +164 -0
- package/backend/src/plugins/ts/compiler.ts +1242 -0
- package/backend/src/plugins/ts/preprocessing.ts +812 -0
- package/backend/src/rate_limit.ts +503 -0
- package/backend/src/request.deprc.js +626 -0
- package/backend/src/response.deprc.js +354 -0
- package/backend/src/server.ts +4149 -0
- package/backend/src/splash_screen.ts +192 -0
- package/backend/src/status.ts +199 -0
- package/backend/src/stream.ts +1070 -0
- package/backend/src/users.ts +2077 -0
- package/backend/src/utils.ts +359 -0
- package/backend/src/view.ts +655 -0
- package/backend/src/vinc.dev.js +6 -0
- package/backend/src/vinc.ts +6 -0
- package/backend/src/volt.js +25 -0
- package/backend/tsconfig.cjs.json +29 -0
- package/backend/tsconfig.esm.dev.json +34 -0
- package/backend/tsconfig.esm.json +30 -0
- package/backend/tsconfig.json +2 -0
- package/frontend/compile.js +436 -0
- package/frontend/dist/elements/base.d.ts +9891 -0
- package/frontend/dist/elements/base.js +8818 -0
- package/frontend/dist/elements/module.d.ts +16 -0
- package/frontend/dist/elements/module.js +178 -0
- package/frontend/dist/modules/array.d.ts +37 -0
- package/frontend/dist/modules/array.js +284 -0
- package/frontend/dist/modules/auth.d.ts +45 -0
- package/frontend/dist/modules/auth.js +138 -0
- package/frontend/dist/modules/colors.d.ts +26 -0
- package/frontend/dist/modules/colors.js +340 -0
- package/frontend/dist/modules/compression.d.ts +6 -0
- package/frontend/dist/modules/compression.js +999 -0
- package/frontend/dist/modules/cookies.d.ts +17 -0
- package/frontend/dist/modules/cookies.js +166 -0
- package/frontend/dist/modules/date.d.ts +142 -0
- package/frontend/dist/modules/date.js +493 -0
- package/frontend/dist/modules/events.d.ts +7 -0
- package/frontend/dist/modules/events.js +90 -0
- package/frontend/dist/modules/google.d.ts +10 -0
- package/frontend/dist/modules/google.js +53 -0
- package/frontend/dist/modules/meta.d.ts +9 -0
- package/frontend/dist/modules/meta.js +45 -0
- package/frontend/dist/modules/mutex.d.ts +8 -0
- package/frontend/dist/modules/mutex.js +52 -0
- package/frontend/dist/modules/number.d.ts +12 -0
- package/frontend/dist/modules/number.js +8 -0
- package/frontend/dist/modules/object.d.ts +50 -0
- package/frontend/dist/modules/object.js +147 -0
- package/frontend/dist/modules/paddle.d.ts +1403 -0
- package/frontend/dist/modules/paddle.js +2641 -0
- package/frontend/dist/modules/scheme.d.ts +207 -0
- package/frontend/dist/modules/scheme.js +649 -0
- package/frontend/dist/modules/settings.d.ts +3 -0
- package/frontend/dist/modules/settings.js +4 -0
- package/frontend/dist/modules/statics.d.ts +4 -0
- package/frontend/dist/modules/statics.js +45 -0
- package/frontend/dist/modules/string.d.ts +163 -0
- package/frontend/dist/modules/string.js +291 -0
- package/frontend/dist/modules/support.d.ts +18 -0
- package/frontend/dist/modules/support.js +102 -0
- package/frontend/dist/modules/themes.d.ts +8 -0
- package/frontend/dist/modules/themes.js +17 -0
- package/frontend/dist/modules/user.d.ts +58 -0
- package/frontend/dist/modules/user.js +279 -0
- package/frontend/dist/modules/utils.d.ts +58 -0
- package/frontend/dist/modules/utils.js +1159 -0
- package/frontend/dist/types/gradient.d.ts +12 -0
- package/frontend/dist/types/gradient.js +79 -0
- package/frontend/dist/ui/border_button.d.ts +177 -0
- package/frontend/dist/ui/border_button.js +235 -0
- package/frontend/dist/ui/button.d.ts +42 -0
- package/frontend/dist/ui/button.js +114 -0
- package/frontend/dist/ui/canvas.d.ts +56 -0
- package/frontend/dist/ui/canvas.js +411 -0
- package/frontend/dist/ui/checkbox.d.ts +72 -0
- package/frontend/dist/ui/checkbox.js +277 -0
- package/frontend/dist/ui/code.d.ts +232 -0
- package/frontend/dist/ui/code.js +977 -0
- package/frontend/dist/ui/color.d.ts +1 -0
- package/frontend/dist/ui/color.js +110 -0
- package/frontend/dist/ui/context_menu.d.ts +30 -0
- package/frontend/dist/ui/context_menu.js +211 -0
- package/frontend/dist/ui/css.d.ts +10 -0
- package/frontend/dist/ui/css.js +44 -0
- package/frontend/dist/ui/divider.d.ts +18 -0
- package/frontend/dist/ui/divider.js +82 -0
- package/frontend/dist/ui/dropdown.d.ts +115 -0
- package/frontend/dist/ui/dropdown.js +446 -0
- package/frontend/dist/ui/for_each.d.ts +38 -0
- package/frontend/dist/ui/for_each.js +97 -0
- package/frontend/dist/ui/form.d.ts +25 -0
- package/frontend/dist/ui/form.js +227 -0
- package/frontend/dist/ui/frame_modes.d.ts +28 -0
- package/frontend/dist/ui/frame_modes.js +116 -0
- package/frontend/dist/ui/google_map.d.ts +31 -0
- package/frontend/dist/ui/google_map.js +111 -0
- package/frontend/dist/ui/gradient.d.ts +24 -0
- package/frontend/dist/ui/gradient.js +115 -0
- package/frontend/dist/ui/image.d.ts +138 -0
- package/frontend/dist/ui/image.js +570 -0
- package/frontend/dist/ui/input.d.ts +316 -0
- package/frontend/dist/ui/input.js +1187 -0
- package/frontend/dist/ui/link.d.ts +39 -0
- package/frontend/dist/ui/link.js +146 -0
- package/frontend/dist/ui/list.d.ts +33 -0
- package/frontend/dist/ui/list.js +161 -0
- package/frontend/dist/ui/loader_button.d.ts +108 -0
- package/frontend/dist/ui/loader_button.js +207 -0
- package/frontend/dist/ui/loaders.d.ts +60 -0
- package/frontend/dist/ui/loaders.js +150 -0
- package/frontend/dist/ui/popup.d.ts +84 -0
- package/frontend/dist/ui/popup.js +331 -0
- package/frontend/dist/ui/pseudo.d.ts +16 -0
- package/frontend/dist/ui/pseudo.js +81 -0
- package/frontend/dist/ui/scroller.d.ts +131 -0
- package/frontend/dist/ui/scroller.js +1251 -0
- package/frontend/dist/ui/slider.d.ts +35 -0
- package/frontend/dist/ui/slider.js +203 -0
- package/frontend/dist/ui/spacer.d.ts +20 -0
- package/frontend/dist/ui/spacer.js +83 -0
- package/frontend/dist/ui/span.d.ts +11 -0
- package/frontend/dist/ui/span.js +75 -0
- package/frontend/dist/ui/stack.d.ts +123 -0
- package/frontend/dist/ui/stack.js +344 -0
- package/frontend/dist/ui/steps.d.ts +72 -0
- package/frontend/dist/ui/steps.js +306 -0
- package/frontend/dist/ui/style.d.ts +12 -0
- package/frontend/dist/ui/style.js +78 -0
- package/frontend/dist/ui/switch.d.ts +44 -0
- package/frontend/dist/ui/switch.js +280 -0
- package/frontend/dist/ui/table.d.ts +118 -0
- package/frontend/dist/ui/table.js +411 -0
- package/frontend/dist/ui/tabs.d.ts +85 -0
- package/frontend/dist/ui/tabs.js +392 -0
- package/frontend/dist/ui/text.d.ts +19 -0
- package/frontend/dist/ui/text.js +88 -0
- package/frontend/dist/ui/theme.d.ts +25 -0
- package/frontend/dist/ui/theme.js +237 -0
- package/frontend/dist/ui/title.d.ts +36 -0
- package/frontend/dist/ui/title.js +127 -0
- package/frontend/dist/ui/ui.d.ts +38 -0
- package/frontend/dist/ui/ui.js +41 -0
- package/frontend/dist/ui/view.d.ts +25 -0
- package/frontend/dist/ui/view.js +93 -0
- package/frontend/dist/volt.d.ts +22 -0
- package/frontend/dist/volt.js +27 -0
- package/frontend/exports.json +1340 -0
- package/frontend/src/css/adyen.css +92 -0
- package/frontend/src/css/volt.css +65 -0
- package/frontend/src/elements/base.ts +16790 -0
- package/frontend/src/elements/module.ts +184 -0
- package/frontend/src/elements/types.d.ts +155 -0
- package/frontend/src/modules/array.ts +366 -0
- package/frontend/src/modules/auth.ts +188 -0
- package/frontend/src/modules/colors.ts +449 -0
- package/frontend/src/modules/compression.ts +67 -0
- package/frontend/src/modules/cookies.ts +182 -0
- package/frontend/src/modules/date.js +535 -0
- package/frontend/src/modules/date.ts +583 -0
- package/frontend/src/modules/events.ts +96 -0
- package/frontend/src/modules/google.ts +60 -0
- package/frontend/src/modules/meta.ts +59 -0
- package/frontend/src/modules/mutex.ts +59 -0
- package/frontend/src/modules/number.ts +20 -0
- package/frontend/src/modules/object.ts +212 -0
- package/frontend/src/modules/paddle.ts +2990 -0
- package/frontend/src/modules/scheme.ts +740 -0
- package/frontend/src/modules/settings.ts +5 -0
- package/frontend/src/modules/statics.ts +47 -0
- package/frontend/src/modules/string.ts +500 -0
- package/frontend/src/modules/support.ts +118 -0
- package/frontend/src/modules/themes.ts +24 -0
- package/frontend/src/modules/user.ts +321 -0
- package/frontend/src/modules/utils.ts +1260 -0
- package/frontend/src/static/admin/admin.png +0 -0
- package/frontend/src/static/admin/password.webp +0 -0
- package/frontend/src/static/icons/copy.webp +0 -0
- package/frontend/src/static/payments/arrow.long.webp +0 -0
- package/frontend/src/static/payments/arrow.long2.webp +0 -0
- package/frontend/src/static/payments/cancelled.webp +0 -0
- package/frontend/src/static/payments/check.sign.webp +0 -0
- package/frontend/src/static/payments/check.webp +0 -0
- package/frontend/src/static/payments/close.webp +0 -0
- package/frontend/src/static/payments/error.webp +0 -0
- package/frontend/src/static/payments/exclamation.webp +0 -0
- package/frontend/src/static/payments/minus.webp +0 -0
- package/frontend/src/static/payments/party.webp +0 -0
- package/frontend/src/static/payments/plus.webp +0 -0
- package/frontend/src/static/payments/shopping_cart.webp +0 -0
- package/frontend/src/static/payments/trash.webp +0 -0
- package/frontend/src/types/global.d.ts +4 -0
- package/frontend/src/types/gradient.ts +87 -0
- package/frontend/src/ui/any_element.d.ts +5 -0
- package/frontend/src/ui/border_button.ts +320 -0
- package/frontend/src/ui/button.ts +62 -0
- package/frontend/src/ui/canvas.ts +431 -0
- package/frontend/src/ui/checkbox.ts +284 -0
- package/frontend/src/ui/code.ts +1049 -0
- package/frontend/src/ui/color.ts +117 -0
- package/frontend/src/ui/context_menu.ts +194 -0
- package/frontend/src/ui/css.ts +57 -0
- package/frontend/src/ui/divider.ts +28 -0
- package/frontend/src/ui/dropdown.ts +503 -0
- package/frontend/src/ui/for_each.ts +71 -0
- package/frontend/src/ui/form.ts +208 -0
- package/frontend/src/ui/frame_modes.ts +140 -0
- package/frontend/src/ui/google_map.ts +70 -0
- package/frontend/src/ui/gradient.ts +73 -0
- package/frontend/src/ui/image.ts +587 -0
- package/frontend/src/ui/input.ts +1284 -0
- package/frontend/src/ui/link.ts +77 -0
- package/frontend/src/ui/list.ts +88 -0
- package/frontend/src/ui/loader_button.ts +192 -0
- package/frontend/src/ui/loaders.ts +126 -0
- package/frontend/src/ui/popup.ts +370 -0
- package/frontend/src/ui/pseudo.ts +33 -0
- package/frontend/src/ui/scroller.ts +1324 -0
- package/frontend/src/ui/slider.ts +215 -0
- package/frontend/src/ui/spacer.ts +29 -0
- package/frontend/src/ui/span.ts +23 -0
- package/frontend/src/ui/stack.ts +238 -0
- package/frontend/src/ui/steps.ts +334 -0
- package/frontend/src/ui/style.ts +26 -0
- package/frontend/src/ui/switch.ts +286 -0
- package/frontend/src/ui/table.ts +323 -0
- package/frontend/src/ui/tabs.ts +441 -0
- package/frontend/src/ui/text.ts +38 -0
- package/frontend/src/ui/theme.ts +279 -0
- package/frontend/src/ui/title.ts +64 -0
- package/frontend/src/ui/ui.ts +47 -0
- package/frontend/src/ui/view.ts +44 -0
- package/frontend/src/volt.ts +31 -0
- package/package.json +58 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { View } from './view.js';
|
|
2
|
+
import { RateLimitGroup } from "./rate_limit.js";
|
|
3
|
+
import { Stream, AuthStream, Params } from "./stream.js";
|
|
4
|
+
type EndpointCallback = ((stream: Stream, params: Params) => any) | ((stream: AuthStream, params: Params) => any);
|
|
5
|
+
export interface EndpointOptions {
|
|
6
|
+
method?: string;
|
|
7
|
+
endpoint: string | RegExp;
|
|
8
|
+
authenticated?: boolean;
|
|
9
|
+
rate_limit?: string | RateLimitGroup | RateLimitGroup[] | null;
|
|
10
|
+
params?: Record<string, any> | null;
|
|
11
|
+
callback?: EndpointCallback;
|
|
12
|
+
view?: View | Record<string, any> | null;
|
|
13
|
+
data?: any;
|
|
14
|
+
content_type?: string;
|
|
15
|
+
compress?: boolean;
|
|
16
|
+
cache?: boolean | number;
|
|
17
|
+
ip_whitelist?: string[] | null;
|
|
18
|
+
sitemap?: boolean | null;
|
|
19
|
+
robots?: boolean | null;
|
|
20
|
+
_templates?: Record<string, any>;
|
|
21
|
+
_path?: string | null;
|
|
22
|
+
_is_static?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare class Endpoint {
|
|
25
|
+
static rate_limits: Map<string, any>;
|
|
26
|
+
method: string;
|
|
27
|
+
endpoint: string | RegExp;
|
|
28
|
+
authenticated: boolean;
|
|
29
|
+
params: Record<string, any> | null;
|
|
30
|
+
callback?: EndpointCallback;
|
|
31
|
+
data: any;
|
|
32
|
+
content_type: string;
|
|
33
|
+
compress: boolean;
|
|
34
|
+
cache: boolean | number;
|
|
35
|
+
sitemap: boolean | null;
|
|
36
|
+
robots: boolean | null;
|
|
37
|
+
_templates: Record<string, any>;
|
|
38
|
+
_path: string | null;
|
|
39
|
+
ip_whitelist: string[] | null;
|
|
40
|
+
is_static: boolean;
|
|
41
|
+
headers: Array<[string, string]>;
|
|
42
|
+
view: View | null;
|
|
43
|
+
rate_limits: any[];
|
|
44
|
+
_verify_params_parent: string;
|
|
45
|
+
_is_compressed?: boolean;
|
|
46
|
+
raw_data?: any;
|
|
47
|
+
content_length?: number;
|
|
48
|
+
is_image_endpoint?: boolean;
|
|
49
|
+
constructor({ method, endpoint, authenticated, rate_limit, params, callback, view, data, content_type, compress, cache, ip_whitelist, sitemap, robots, _templates, // only used in loading static files.
|
|
50
|
+
_path, _is_static, }: EndpointOptions);
|
|
51
|
+
_load_data_by_path(server: any): this;
|
|
52
|
+
_set_headers(stream: any): void;
|
|
53
|
+
_refresh(server: any): Promise<void>;
|
|
54
|
+
_initialize(server: any): Promise<void>;
|
|
55
|
+
_serve(stream: any, status_code?: number): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
export { Endpoint };
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Author: Daan van den Bergh
|
|
3
|
+
* Copyright: © 2022 - 2024 Daan van den Bergh.
|
|
4
|
+
*/
|
|
5
|
+
// ---------------------------------------------------------
|
|
6
|
+
// Imports.
|
|
7
|
+
import CleanCSS from 'clean-css';
|
|
8
|
+
import zlib from 'zlib';
|
|
9
|
+
import { View } from './view.js';
|
|
10
|
+
import { vlib } from "/Users/administrator/persistance/private/dev/vinc/volt/backend/./src/vinc.dev.js";
|
|
11
|
+
import { Utils, FrontendError } from "./utils.js";
|
|
12
|
+
import { Status } from "./status.js";
|
|
13
|
+
import { logger, LogSource } from "./logger.js";
|
|
14
|
+
import { RateLimits } from "./rate_limit.js";
|
|
15
|
+
const log_source = new LogSource("Endpoint");
|
|
16
|
+
/* @docs:
|
|
17
|
+
* @nav: Backend
|
|
18
|
+
@chapter: Endpoints
|
|
19
|
+
@title: Endpoint
|
|
20
|
+
@description:
|
|
21
|
+
The endpoint class.
|
|
22
|
+
@parameter:
|
|
23
|
+
@name: method
|
|
24
|
+
@description: The method type.
|
|
25
|
+
@type: string
|
|
26
|
+
@parameter:
|
|
27
|
+
@name: endpoint
|
|
28
|
+
@description: The endpoint sub url.
|
|
29
|
+
@type: string
|
|
30
|
+
@parameter:
|
|
31
|
+
@name: authenticated
|
|
32
|
+
@description: Only allow authenticated requests.
|
|
33
|
+
@type: string
|
|
34
|
+
@parameter:
|
|
35
|
+
@name: rate_limit
|
|
36
|
+
@description:
|
|
37
|
+
The rate limit settings.
|
|
38
|
+
|
|
39
|
+
Rate limiting works by creating a rate limit per group of endpoints. Multiple rate limiting groups can be applied by defining an array with rate limit objects. A group's interval and limit only need to be defined once on a single endpoint. When defined again these values will override the innitial group settings.
|
|
40
|
+
|
|
41
|
+
The rate limit parameter may be defined as three types.
|
|
42
|
+
- `string`: The assign the rate limit group without any group parameters. This can be useful when the group is already defined.
|
|
43
|
+
- `RateLimitGroup`: As a rate limit object.
|
|
44
|
+
- `RateLimitGroup[]`: As an array with multiple rate limit objects.
|
|
45
|
+
|
|
46
|
+
When left undefined no rate limiting will be applied.
|
|
47
|
+
@type: null, string, RateLimitGroup, RateLimitGroup[]
|
|
48
|
+
@attributes_type: RateLimitGroup
|
|
49
|
+
@attribute:
|
|
50
|
+
@name: group
|
|
51
|
+
@description: The rate limit group.
|
|
52
|
+
@type: string
|
|
53
|
+
@default: "global"
|
|
54
|
+
@attribute:
|
|
55
|
+
@name: limit
|
|
56
|
+
@description: The maximum requests per rate limit interval. These settings will be cached per group and only have to be assigned once. The assigned attributes will be overridden when these attributes are reassigned for the same group.
|
|
57
|
+
@type: number
|
|
58
|
+
@default: 50
|
|
59
|
+
@attr:
|
|
60
|
+
@name: interval
|
|
61
|
+
@description: The rate limit interval in seconds. These settings will be cached per group and only have to be assigned once. The assigned attributes will be overridden when these attributes are reassigned for the same group.
|
|
62
|
+
@type: number
|
|
63
|
+
@default: 60
|
|
64
|
+
@parameter:
|
|
65
|
+
@name: callback
|
|
66
|
+
@description:
|
|
67
|
+
The callback that will be executed when a client requests this endpoint.
|
|
68
|
+
Parameter `callback` precedes over parameter `data` and parameter `view`.
|
|
69
|
+
The callback can take parameter `stream` assigned with the `volt.Stream` object of the request.
|
|
70
|
+
@type: function
|
|
71
|
+
@parameter:
|
|
72
|
+
@name: view
|
|
73
|
+
@description:
|
|
74
|
+
The javascript view that will be executed on the client side.
|
|
75
|
+
Parameter `view` precedes over parameter `data`.
|
|
76
|
+
@type: View, object
|
|
77
|
+
@parameter:
|
|
78
|
+
@name: data
|
|
79
|
+
@description:
|
|
80
|
+
The data that will be returned as the response body.
|
|
81
|
+
@type: number, string, array, object
|
|
82
|
+
@parameter:
|
|
83
|
+
@name: content_type
|
|
84
|
+
@description: The content type for parameter `data` or `callback`.
|
|
85
|
+
@type: string
|
|
86
|
+
@parameter:
|
|
87
|
+
@name: compress
|
|
88
|
+
@description: Compress data, only available when initialized with one of the following parameters `view` or `data`.
|
|
89
|
+
@type: boolean
|
|
90
|
+
@parameter:
|
|
91
|
+
@name: cache
|
|
92
|
+
@description:
|
|
93
|
+
Parameter cache can define the max age of the cached response in seconds or as a boolean `true`. Anything higher than zero enables caching. When server production mode is enabled caching is done automatically unless `cache` is `false`. When production mode is disabled responses are never cached, even though the parameter is assigned. The response of an endpoint that uses parameter `callback` is never cached.
|
|
94
|
+
@type: boolean, number
|
|
95
|
+
@parameter:
|
|
96
|
+
@name: sitemap
|
|
97
|
+
@description:
|
|
98
|
+
A boolean indicating if the endpoint should show up in the sitemap. By default only when the attribute `view` is defined and the endpoint is unauthenticated, the endpoint will show up in sitemap.
|
|
99
|
+
@type: boolean
|
|
100
|
+
@parameter:
|
|
101
|
+
@name: robots
|
|
102
|
+
@description:
|
|
103
|
+
A boolean indicating if the endpoint should be crawled by search engines. By default only endpoints with `view` enabled will be crawled, unless specified otherwise.
|
|
104
|
+
@type: boolean
|
|
105
|
+
@parameter:
|
|
106
|
+
@name: ip_whitelist
|
|
107
|
+
@description:
|
|
108
|
+
An IP whitelist for the endpoint. When the parameter is defined with an `Array` type, the whitelist will become active.
|
|
109
|
+
@type: boolean
|
|
110
|
+
@parameter:
|
|
111
|
+
@name: _path
|
|
112
|
+
@ignore: true
|
|
113
|
+
@parameter:
|
|
114
|
+
@name: _is_static
|
|
115
|
+
@ignore: true
|
|
116
|
+
*/
|
|
117
|
+
class Endpoint {
|
|
118
|
+
// Static attributes.
|
|
119
|
+
static rate_limits = new Map();
|
|
120
|
+
// Instance attributes
|
|
121
|
+
method;
|
|
122
|
+
endpoint;
|
|
123
|
+
authenticated;
|
|
124
|
+
params;
|
|
125
|
+
callback = undefined;
|
|
126
|
+
data;
|
|
127
|
+
content_type;
|
|
128
|
+
compress;
|
|
129
|
+
cache;
|
|
130
|
+
sitemap;
|
|
131
|
+
robots;
|
|
132
|
+
_templates;
|
|
133
|
+
_path;
|
|
134
|
+
ip_whitelist;
|
|
135
|
+
is_static;
|
|
136
|
+
headers;
|
|
137
|
+
view;
|
|
138
|
+
rate_limits;
|
|
139
|
+
_verify_params_parent;
|
|
140
|
+
_is_compressed;
|
|
141
|
+
raw_data;
|
|
142
|
+
content_length;
|
|
143
|
+
is_image_endpoint;
|
|
144
|
+
constructor({ method = "GET", endpoint = "/", authenticated = false, rate_limit = null, params = null, callback = undefined, view = null, data = null, content_type = "text/plain", compress = true, cache = true, ip_whitelist = null, sitemap = null, robots = null, _templates = {}, // only used in loading static files.
|
|
145
|
+
_path = null, _is_static = false, }) {
|
|
146
|
+
// Attributes.
|
|
147
|
+
this.method = method;
|
|
148
|
+
this.endpoint = endpoint;
|
|
149
|
+
this.authenticated = authenticated;
|
|
150
|
+
this.params = params;
|
|
151
|
+
if (this.callback === undefined) { // only assign when undefined, so derived classes can also define the callback function.
|
|
152
|
+
this.callback = callback;
|
|
153
|
+
}
|
|
154
|
+
this.data = data;
|
|
155
|
+
this.content_type = content_type;
|
|
156
|
+
this.compress = compress !== false;
|
|
157
|
+
this.cache = cache;
|
|
158
|
+
this.sitemap = sitemap;
|
|
159
|
+
this.robots = robots;
|
|
160
|
+
this._templates = _templates;
|
|
161
|
+
this._path = _path == null ? _path : new vlib.Path(_path).abs().str(); // use abs, is automatically assigned for static files.
|
|
162
|
+
this.ip_whitelist = Array.isArray(ip_whitelist) ? ip_whitelist : null;
|
|
163
|
+
this.is_static = _is_static;
|
|
164
|
+
this.headers = [];
|
|
165
|
+
// Excluded endpoint chars
|
|
166
|
+
if (typeof endpoint === "string") {
|
|
167
|
+
["\n", "\,"].forEach((c) => {
|
|
168
|
+
if (endpoint.indexOf(c) !== -1) {
|
|
169
|
+
throw Error("The \",\" character is not allowed inside an endpoint url.");
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// Clean endpoint url.
|
|
174
|
+
if (typeof this.endpoint === "string") {
|
|
175
|
+
this.endpoint = Utils.clean_endpoint(this.endpoint);
|
|
176
|
+
}
|
|
177
|
+
// Argument `view` may also be passed as an object instead of class View.
|
|
178
|
+
if (view == null) {
|
|
179
|
+
this.view = null;
|
|
180
|
+
}
|
|
181
|
+
else if (view instanceof View) {
|
|
182
|
+
this.view = view;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this.view = new View(view);
|
|
186
|
+
}
|
|
187
|
+
// Set default visible in sitemap.
|
|
188
|
+
if (this.sitemap == null) {
|
|
189
|
+
if (this.view != null &&
|
|
190
|
+
this.endpoint != "robots.txt" &&
|
|
191
|
+
this.endpoint != "sitemap.xml" &&
|
|
192
|
+
!this.authenticated) {
|
|
193
|
+
this.sitemap = true;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
this.sitemap = false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Set crawling by robots.
|
|
200
|
+
if (this.robots == null) {
|
|
201
|
+
this.robots = !this.authenticated && (this.view != null || this.endpoint == "robots.txt" || this.endpoint == "sitemap.xml");
|
|
202
|
+
}
|
|
203
|
+
// Assign rate limits.
|
|
204
|
+
this.rate_limits = [];
|
|
205
|
+
if (Array.isArray(rate_limit)) {
|
|
206
|
+
rate_limit.forEach((item) => {
|
|
207
|
+
this.rate_limits.push(RateLimits.add(item));
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
else if (typeof rate_limit === "string") {
|
|
211
|
+
this.rate_limits.push(RateLimits.add({ group: rate_limit }));
|
|
212
|
+
}
|
|
213
|
+
else if (typeof rate_limit === "object" && rate_limit != null) {
|
|
214
|
+
this.rate_limits.push(RateLimits.add(rate_limit));
|
|
215
|
+
}
|
|
216
|
+
// The endpoint parent for params verification.
|
|
217
|
+
this._verify_params_parent = this.method + ":" + this.endpoint + ":";
|
|
218
|
+
}
|
|
219
|
+
// Load data by path.
|
|
220
|
+
_load_data_by_path(server) {
|
|
221
|
+
// Load data.
|
|
222
|
+
const path = new vlib.Path(this._path);
|
|
223
|
+
let data;
|
|
224
|
+
if (path.extension() === ".js") {
|
|
225
|
+
data = path.load_sync();
|
|
226
|
+
// @deprecated compile using vhighlight, now esbuild is used for bundling, callback is not supported yet.
|
|
227
|
+
// const hash = server.hash(data);
|
|
228
|
+
// // Check cache for restarts by file watcher.
|
|
229
|
+
// const {cache_path, cache_hash, cache_data} = Utils.get_compiled_cache(server.domain, "GET", path.str());
|
|
230
|
+
// if (cache_data && hash === cache_hash) {
|
|
231
|
+
// data = cache_data;
|
|
232
|
+
// }
|
|
233
|
+
// // Compile.
|
|
234
|
+
// else {
|
|
235
|
+
// const compiler = new vhighlight.JSCompiler({
|
|
236
|
+
// line_breaks: true,
|
|
237
|
+
// double_line_breaks: false,
|
|
238
|
+
// comments: false,
|
|
239
|
+
// white_space: false,
|
|
240
|
+
// })
|
|
241
|
+
// data = compiler.compile_code(data, path.str());
|
|
242
|
+
// // Cache for restarts.
|
|
243
|
+
// Utils.set_compiled_cache(cache_path, data, hash);
|
|
244
|
+
// }
|
|
245
|
+
}
|
|
246
|
+
else if (path.extension() === ".css") {
|
|
247
|
+
const minifier = new CleanCSS();
|
|
248
|
+
data = minifier.minify(path.load_sync()).styles;
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
data = path.load_sync({ type: "buffer" });
|
|
252
|
+
}
|
|
253
|
+
// Fill templates.
|
|
254
|
+
if (this._templates) {
|
|
255
|
+
data = Utils.fill_templates(data, this._templates);
|
|
256
|
+
}
|
|
257
|
+
if (this.endpoint === "/static/examples/libris.search.dark.webp") {
|
|
258
|
+
console.log(this.endpoint, "DATA:", data.length);
|
|
259
|
+
}
|
|
260
|
+
// Assign.
|
|
261
|
+
this.data = data;
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
// Set default headers.
|
|
265
|
+
_set_headers(stream) {
|
|
266
|
+
this.headers.forEach((item) => {
|
|
267
|
+
stream.set_header(item[0], item[1]);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
// Refresh for file watcher.
|
|
271
|
+
async _refresh(server) {
|
|
272
|
+
// Not in production.
|
|
273
|
+
if (server.production) {
|
|
274
|
+
throw new Error("This function is not designed for production mode.");
|
|
275
|
+
}
|
|
276
|
+
// Build html code of view.
|
|
277
|
+
if (this.view != null) {
|
|
278
|
+
await this.view._build_html();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Initialize.
|
|
282
|
+
async _initialize(server) {
|
|
283
|
+
// Build html code of view.
|
|
284
|
+
if (this.view != null) {
|
|
285
|
+
this.view._initialize(server, this);
|
|
286
|
+
await this.view._build_html();
|
|
287
|
+
}
|
|
288
|
+
// Compression enabled.
|
|
289
|
+
if (server.production && this.callback == null && this.compress) {
|
|
290
|
+
this._is_compressed = true;
|
|
291
|
+
if (this.data != null) {
|
|
292
|
+
this.raw_data = this.data;
|
|
293
|
+
this.data = zlib.gzipSync(this.data, { level: zlib.constants.Z_BEST_COMPRESSION });
|
|
294
|
+
}
|
|
295
|
+
else if (this.view != null) {
|
|
296
|
+
this.view.raw_html = this.view.html;
|
|
297
|
+
this.view.html = zlib.gzipSync(this.view.html, { level: zlib.constants.Z_BEST_COMPRESSION });
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Set cache headers.
|
|
301
|
+
if (!server.production) {
|
|
302
|
+
this.cache = false;
|
|
303
|
+
}
|
|
304
|
+
if ((this.callback == null || this.is_image_endpoint) && (typeof this.cache === "number" || this.cache === true)) {
|
|
305
|
+
if (this.cache === 1 || this.cache === true) {
|
|
306
|
+
this.headers.push(["Cache-Control", "max-age=86400"]);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
this.headers.push(["Cache-Control", `max-age=${this.cache}`]);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// Set compression headers.
|
|
313
|
+
if (this._is_compressed) {
|
|
314
|
+
this.headers.push(["Content-Encoding", "gzip"]);
|
|
315
|
+
this.headers.push(["Vary", "Accept-Encoding"]);
|
|
316
|
+
}
|
|
317
|
+
// Set content length.
|
|
318
|
+
if (this.content_length != null) {
|
|
319
|
+
this.headers.push(["Content-Length", this.content_length.toString()]);
|
|
320
|
+
}
|
|
321
|
+
// Set content type.
|
|
322
|
+
if (this.content_type != null) {
|
|
323
|
+
this.headers.push(["Content-Type", this.content_type]);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
// Serve a client.
|
|
327
|
+
async _serve(stream, status_code = 200) {
|
|
328
|
+
try {
|
|
329
|
+
// Check IP whitelist.
|
|
330
|
+
if (this.ip_whitelist && !this.ip_whitelist.includes(stream.ip)) {
|
|
331
|
+
stream.send({
|
|
332
|
+
status: Status.unauthorized,
|
|
333
|
+
data: "Unauthorized.",
|
|
334
|
+
});
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
// Set headers.
|
|
338
|
+
this._set_headers(stream);
|
|
339
|
+
// Callback.
|
|
340
|
+
if (this.callback != null) {
|
|
341
|
+
if (this.params != null) {
|
|
342
|
+
const { error, invalid_fields } = vlib.Scheme.verify({
|
|
343
|
+
object: stream.params,
|
|
344
|
+
scheme: this.params,
|
|
345
|
+
check_unknown: true,
|
|
346
|
+
parent: this._verify_params_parent,
|
|
347
|
+
throw_err: false,
|
|
348
|
+
});
|
|
349
|
+
if (error) {
|
|
350
|
+
stream.send({
|
|
351
|
+
status: Status.bad_request,
|
|
352
|
+
headers: { "Content-Type": "application/json" },
|
|
353
|
+
data: {
|
|
354
|
+
error,
|
|
355
|
+
invalid_fields,
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
try {
|
|
362
|
+
let promise;
|
|
363
|
+
if (this.params != null) {
|
|
364
|
+
promise = this.callback(stream, stream.params ?? {});
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
promise = this.callback(stream, {});
|
|
368
|
+
}
|
|
369
|
+
if (promise instanceof Promise) {
|
|
370
|
+
await promise;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
catch (err) {
|
|
374
|
+
if (err instanceof FrontendError) {
|
|
375
|
+
let data = { error: err.message != null ? err.message : "Internal Server Error" };
|
|
376
|
+
if (err.data != null && typeof err.data === "object") {
|
|
377
|
+
Object.assign(data, err.data);
|
|
378
|
+
}
|
|
379
|
+
stream.send({
|
|
380
|
+
status: err.status != null ? err.status : Status.internal_server_error,
|
|
381
|
+
headers: { "Content-Type": "application/json" },
|
|
382
|
+
data,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
stream.send({
|
|
387
|
+
status: Status.internal_server_error,
|
|
388
|
+
headers: { "Content-Type": "application/json" },
|
|
389
|
+
data: { error: "Internal Server Error" },
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
logger.error(log_source, `${this.method}:${this.endpoint}: `, err); // after sending the response since this edits the error.
|
|
393
|
+
}
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
// View.
|
|
397
|
+
else if (this.view != null) {
|
|
398
|
+
this.view._serve(stream, status_code);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
// Data.
|
|
402
|
+
else if (this.data != null) {
|
|
403
|
+
stream.send({
|
|
404
|
+
status: status_code,
|
|
405
|
+
data: this.data,
|
|
406
|
+
});
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
// Undefined.
|
|
410
|
+
else {
|
|
411
|
+
throw new Error(`${this.method} ${this.endpoint}: Undefined behaviour, define one of the following endpoint attributes [callback, view, data].`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
catch (err) {
|
|
415
|
+
throw err; // must have another catch block here otherwise when an error occurs in here it is somehow not catched by the try and catch block from Server._serve which will cause the program to crash.
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
// ---------------------------------------------------------
|
|
420
|
+
// Exports.
|
|
421
|
+
export { Endpoint };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { vlib } from "@vinc";
|
|
2
|
+
declare class StaticFileWatcher {
|
|
3
|
+
private server;
|
|
4
|
+
private mtimes;
|
|
5
|
+
private endpoints;
|
|
6
|
+
private log_source;
|
|
7
|
+
private interval;
|
|
8
|
+
constructor(server: any);
|
|
9
|
+
start(): Promise<void>;
|
|
10
|
+
add(endpoint: any): void;
|
|
11
|
+
has(endpoint: string): boolean;
|
|
12
|
+
stop(): void;
|
|
13
|
+
}
|
|
14
|
+
declare class FileWatcher {
|
|
15
|
+
private source;
|
|
16
|
+
private config?;
|
|
17
|
+
private interval;
|
|
18
|
+
private excluded;
|
|
19
|
+
private additional_paths;
|
|
20
|
+
private start_file?;
|
|
21
|
+
private log_source;
|
|
22
|
+
private args;
|
|
23
|
+
private mtimes;
|
|
24
|
+
promise: Promise<any>;
|
|
25
|
+
private proc;
|
|
26
|
+
private has_changed;
|
|
27
|
+
private _com_file?;
|
|
28
|
+
constructor({ source, config, interval, excluded, additional_paths, start_file, }: {
|
|
29
|
+
source: vlib.Path | string;
|
|
30
|
+
config?: string;
|
|
31
|
+
interval?: number;
|
|
32
|
+
excluded?: string[];
|
|
33
|
+
additional_paths?: string[];
|
|
34
|
+
start_file?: string;
|
|
35
|
+
});
|
|
36
|
+
add_path(path: string | vlib.Path): void;
|
|
37
|
+
add_exclude(path: string | vlib.Path): void;
|
|
38
|
+
start(): Promise<void>;
|
|
39
|
+
scan(): Promise<void>;
|
|
40
|
+
scan_files(): void;
|
|
41
|
+
spawn_process(): void;
|
|
42
|
+
restart_process(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export { StaticFileWatcher, FileWatcher };
|