@vitnode/core 1.2.0-canary.10
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/LICENSE.md +21 -0
- package/dist/emails/my-email.d.ts +2 -0
- package/dist/emails/my-email.d.ts.map +1 -0
- package/dist/scripts/get-config.d.ts +3 -0
- package/dist/scripts/get-config.d.ts.map +1 -0
- package/dist/scripts/plugin.d.ts +4 -0
- package/dist/scripts/plugin.d.ts.map +1 -0
- package/dist/scripts/prepare-database.d.ts +7 -0
- package/dist/scripts/prepare-database.d.ts.map +1 -0
- package/dist/scripts/prepare-plugins-files.d.ts +2 -0
- package/dist/scripts/prepare-plugins-files.d.ts.map +1 -0
- package/dist/scripts/run-interactive-shell-command.d.ts +2 -0
- package/dist/scripts/run-interactive-shell-command.d.ts.map +1 -0
- package/dist/scripts/scripts.d.ts +3 -0
- package/dist/scripts/scripts.d.ts.map +1 -0
- package/dist/scripts/scripts.js +21 -0
- package/dist/scripts/shared/file-utils.d.ts +14 -0
- package/dist/scripts/shared/file-utils.d.ts.map +1 -0
- package/dist/src/api/config.d.ts +24 -0
- package/dist/src/api/config.d.ts.map +1 -0
- package/dist/src/api/config.js +50 -0
- package/dist/src/api/lib/check-plugin-id.d.ts +15 -0
- package/dist/src/api/lib/check-plugin-id.d.ts.map +1 -0
- package/dist/src/api/lib/check-plugin-id.js +15 -0
- package/dist/src/api/lib/get-user-ip.d.ts +3 -0
- package/dist/src/api/lib/get-user-ip.d.ts.map +1 -0
- package/dist/src/api/lib/get-user-ip.js +8 -0
- package/dist/src/api/lib/module.d.ts +23 -0
- package/dist/src/api/lib/module.d.ts.map +1 -0
- package/dist/src/api/lib/module.js +21 -0
- package/dist/src/api/lib/plugin.d.ts +11 -0
- package/dist/src/api/lib/plugin.d.ts.map +1 -0
- package/dist/src/api/lib/plugin.js +14 -0
- package/dist/src/api/lib/route.d.ts +26 -0
- package/dist/src/api/lib/route.d.ts.map +1 -0
- package/dist/src/api/lib/route.js +23 -0
- package/dist/src/api/lib/with-pagination.d.ts +72 -0
- package/dist/src/api/lib/with-pagination.d.ts.map +1 -0
- package/dist/src/api/lib/with-pagination.js +70 -0
- package/dist/src/api/middlewares/global/global.d.ts +66 -0
- package/dist/src/api/middlewares/global/global.d.ts.map +1 -0
- package/dist/src/api/middlewares/global/global.js +47 -0
- package/dist/src/api/models/device.d.ts +10 -0
- package/dist/src/api/models/device.d.ts.map +1 -0
- package/dist/src/api/models/device.js +54 -0
- package/dist/src/api/models/email.d.ts +22 -0
- package/dist/src/api/models/email.d.ts.map +1 -0
- package/dist/src/api/models/email.js +30 -0
- package/dist/src/api/models/password.d.ts +5 -0
- package/dist/src/api/models/password.d.ts.map +1 -0
- package/dist/src/api/models/password.js +21 -0
- package/dist/src/api/models/session-admin.d.ts +24 -0
- package/dist/src/api/models/session-admin.d.ts.map +1 -0
- package/dist/src/api/models/session-admin.js +73 -0
- package/dist/src/api/models/session.d.ts +23 -0
- package/dist/src/api/models/session.d.ts.map +1 -0
- package/dist/src/api/models/session.js +60 -0
- package/dist/src/api/models/sso.d.ts +38 -0
- package/dist/src/api/models/sso.d.ts.map +1 -0
- package/dist/src/api/models/sso.js +120 -0
- package/dist/src/api/models/user/get-user-by-id.d.ts +17 -0
- package/dist/src/api/models/user/get-user-by-id.d.ts.map +1 -0
- package/dist/src/api/models/user/get-user-by-id.js +18 -0
- package/dist/src/api/models/user/sign-in-with-passwords.d.ts +10 -0
- package/dist/src/api/models/user/sign-in-with-passwords.d.ts.map +1 -0
- package/dist/src/api/models/user/sign-in-with-passwords.js +22 -0
- package/dist/src/api/models/user/sign-up.d.ts +21 -0
- package/dist/src/api/models/user/sign-up.d.ts.map +1 -0
- package/dist/src/api/models/user/sign-up.js +75 -0
- package/dist/src/api/models/user.d.ts +45 -0
- package/dist/src/api/models/user.d.ts.map +1 -0
- package/dist/src/api/models/user.js +8 -0
- package/dist/src/api/modules/admin/admin.module.d.ts +294 -0
- package/dist/src/api/modules/admin/admin.module.d.ts.map +1 -0
- package/dist/src/api/modules/admin/admin.module.js +14 -0
- package/dist/src/api/modules/admin/routes/session.route.d.ts +108 -0
- package/dist/src/api/modules/admin/routes/session.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/routes/session.route.js +51 -0
- package/dist/src/api/modules/admin/users/routes/list.route.d.ts +190 -0
- package/dist/src/api/modules/admin/users/routes/list.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/users/routes/list.route.js +79 -0
- package/dist/src/api/modules/admin/users/routes/users.route.d.ts +193 -0
- package/dist/src/api/modules/admin/users/routes/users.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/users/routes/users.route.js +84 -0
- package/dist/src/api/modules/admin/users/users.admin.module.d.ts +189 -0
- package/dist/src/api/modules/admin/users/users.admin.module.d.ts.map +1 -0
- package/dist/src/api/modules/admin/users/users.admin.module.js +10 -0
- package/dist/src/api/modules/middleware/middleware.module.d.ts +52 -0
- package/dist/src/api/modules/middleware/middleware.module.d.ts.map +1 -0
- package/dist/src/api/modules/middleware/middleware.module.js +10 -0
- package/dist/src/api/modules/middleware/route.d.ts +53 -0
- package/dist/src/api/modules/middleware/route.d.ts.map +1 -0
- package/dist/src/api/modules/middleware/route.js +39 -0
- package/dist/src/api/modules/users/avatar-color.d.ts +2 -0
- package/dist/src/api/modules/users/avatar-color.d.ts.map +1 -0
- package/dist/src/api/modules/users/avatar-color.js +43 -0
- package/dist/src/api/modules/users/routes/session.route.d.ts +103 -0
- package/dist/src/api/modules/users/routes/session.route.d.ts.map +1 -0
- package/dist/src/api/modules/users/routes/session.route.js +46 -0
- package/dist/src/api/modules/users/routes/sign-in.route.d.ts +88 -0
- package/dist/src/api/modules/users/routes/sign-in.route.d.ts.map +1 -0
- package/dist/src/api/modules/users/routes/sign-in.route.js +71 -0
- package/dist/src/api/modules/users/routes/sign-out.route.d.ts +47 -0
- package/dist/src/api/modules/users/routes/sign-out.route.d.ts.map +1 -0
- package/dist/src/api/modules/users/routes/sign-out.route.js +43 -0
- package/dist/src/api/modules/users/routes/sign-up.route.d.ts +89 -0
- package/dist/src/api/modules/users/routes/sign-up.route.d.ts.map +1 -0
- package/dist/src/api/modules/users/routes/sign-up.route.js +60 -0
- package/dist/src/api/modules/users/routes/test.route.d.ts +31 -0
- package/dist/src/api/modules/users/routes/test.route.d.ts.map +1 -0
- package/dist/src/api/modules/users/routes/test.route.js +32 -0
- package/dist/src/api/modules/users/sso/routes/callback.route.d.ts +78 -0
- package/dist/src/api/modules/users/sso/routes/callback.route.d.ts.map +1 -0
- package/dist/src/api/modules/users/sso/routes/callback.route.js +49 -0
- package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts +51 -0
- package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts.map +1 -0
- package/dist/src/api/modules/users/sso/routes/create-url.route.js +36 -0
- package/dist/src/api/modules/users/sso/sso.module.d.ts +125 -0
- package/dist/src/api/modules/users/sso/sso.module.d.ts.map +1 -0
- package/dist/src/api/modules/users/sso/sso.module.js +12 -0
- package/dist/src/api/modules/users/users.module.d.ts +439 -0
- package/dist/src/api/modules/users/users.module.d.ts.map +1 -0
- package/dist/src/api/modules/users/users.module.js +22 -0
- package/dist/src/api/plugin.d.ts +2 -0
- package/dist/src/api/plugin.d.ts.map +1 -0
- package/dist/src/api/plugin.js +13 -0
- package/dist/src/api/plugins/email/nodemailer.d.ts +10 -0
- package/dist/src/api/plugins/email/nodemailer.d.ts.map +1 -0
- package/dist/src/api/plugins/email/nodemailer.js +30 -0
- package/dist/src/api/plugins/email/resend.d.ts +6 -0
- package/dist/src/api/plugins/email/resend.d.ts.map +1 -0
- package/dist/src/api/plugins/email/resend.js +21 -0
- package/dist/src/api/plugins/sso/discord.d.ts +6 -0
- package/dist/src/api/plugins/sso/discord.d.ts.map +1 -0
- package/dist/src/api/plugins/sso/discord.js +77 -0
- package/dist/src/api/plugins/sso/facebook.d.ts +6 -0
- package/dist/src/api/plugins/sso/facebook.d.ts.map +1 -0
- package/dist/src/api/plugins/sso/facebook.js +76 -0
- package/dist/src/api/plugins/sso/google.d.ts +6 -0
- package/dist/src/api/plugins/sso/google.d.ts.map +1 -0
- package/dist/src/api/plugins/sso/google.js +87 -0
- package/dist/src/app/login/page.d.ts +6 -0
- package/dist/src/app/login/page.d.ts.map +1 -0
- package/dist/src/app/login/page.js +15 -0
- package/dist/src/app/login/sso/[providerId]/page.d.ts +7 -0
- package/dist/src/app/login/sso/[providerId]/page.d.ts.map +1 -0
- package/dist/src/app/login/sso/[providerId]/page.js +10 -0
- package/dist/src/app/register/page.d.ts +6 -0
- package/dist/src/app/register/page.d.ts.map +1 -0
- package/dist/src/app/register/page.js +15 -0
- package/dist/src/app_admin/core/page.d.ts +2 -0
- package/dist/src/app_admin/core/page.d.ts.map +1 -0
- package/dist/src/app_admin/core/page.js +5 -0
- package/dist/src/app_admin/core/test/page.d.ts +2 -0
- package/dist/src/app_admin/core/test/page.d.ts.map +1 -0
- package/dist/src/app_admin/core/test/page.js +5 -0
- package/dist/src/app_admin/core/users/page.d.ts +6 -0
- package/dist/src/app_admin/core/users/page.d.ts.map +1 -0
- package/dist/src/app_admin/core/users/page.js +35 -0
- package/dist/src/components/avatar.d.ts +10 -0
- package/dist/src/components/avatar.d.ts.map +1 -0
- package/dist/src/components/avatar.js +14 -0
- package/dist/src/components/date-format.d.ts +5 -0
- package/dist/src/components/date-format.d.ts.map +1 -0
- package/dist/src/components/date-format.js +38 -0
- package/dist/src/components/form/auto-form.d.ts +12 -0
- package/dist/src/components/form/auto-form.d.ts.map +1 -0
- package/dist/src/components/form/auto-form.js +57 -0
- package/dist/src/components/form/common/desc.d.ts +2 -0
- package/dist/src/components/form/common/desc.d.ts.map +1 -0
- package/dist/src/components/form/common/desc.js +9 -0
- package/dist/src/components/form/common/label.d.ts +3 -0
- package/dist/src/components/form/common/label.d.ts.map +1 -0
- package/dist/src/components/form/common/label.js +8 -0
- package/dist/src/components/form/fields/checkbox.d.ts +8 -0
- package/dist/src/components/form/fields/checkbox.d.ts.map +1 -0
- package/dist/src/components/form/fields/checkbox.js +35 -0
- package/dist/src/components/form/fields/combobox.d.ts +14 -0
- package/dist/src/components/form/fields/combobox.d.ts.map +1 -0
- package/dist/src/components/form/fields/combobox.js +88 -0
- package/dist/src/components/form/fields/input.d.ts +9 -0
- package/dist/src/components/form/fields/input.d.ts.map +1 -0
- package/dist/src/components/form/fields/input.js +34 -0
- package/dist/src/components/form/fields/item.d.ts +14 -0
- package/dist/src/components/form/fields/item.d.ts.map +1 -0
- package/dist/src/components/form/fields/item.js +22 -0
- package/dist/src/components/form/fields/radio-group.d.ts +13 -0
- package/dist/src/components/form/fields/radio-group.d.ts.map +1 -0
- package/dist/src/components/form/fields/radio-group.js +51 -0
- package/dist/src/components/form/fields/select.d.ts +14 -0
- package/dist/src/components/form/fields/select.d.ts.map +1 -0
- package/dist/src/components/form/fields/select.js +59 -0
- package/dist/src/components/form/fields/switch.d.ts +8 -0
- package/dist/src/components/form/fields/switch.d.ts.map +1 -0
- package/dist/src/components/form/fields/switch.js +35 -0
- package/dist/src/components/form/fields/textarea.d.ts +9 -0
- package/dist/src/components/form/fields/textarea.d.ts.map +1 -0
- package/dist/src/components/form/fields/textarea.js +34 -0
- package/dist/src/components/i18n-provider.d.ts +7 -0
- package/dist/src/components/i18n-provider.d.ts.map +1 -0
- package/dist/src/components/i18n-provider.js +43 -0
- package/dist/src/components/logo-vitnode.d.ts +4 -0
- package/dist/src/components/logo-vitnode.d.ts.map +1 -0
- package/dist/src/components/logo-vitnode.js +113 -0
- package/dist/src/components/switchers/theme-switcher.d.ts +2 -0
- package/dist/src/components/switchers/theme-switcher.d.ts.map +1 -0
- package/dist/src/components/switchers/theme-switcher.js +25 -0
- package/dist/src/components/table/content.d.ts +3 -0
- package/dist/src/components/table/content.d.ts.map +1 -0
- package/dist/src/components/table/content.js +84 -0
- package/dist/src/components/table/data-table.d.ts +37 -0
- package/dist/src/components/table/data-table.d.ts.map +1 -0
- package/dist/src/components/table/data-table.js +69 -0
- package/dist/src/components/table/order-table-head.d.ts +7 -0
- package/dist/src/components/table/order-table-head.d.ts.map +1 -0
- package/dist/src/components/table/order-table-head.js +39 -0
- package/dist/src/components/table/pagination.d.ts +11 -0
- package/dist/src/components/table/pagination.d.ts.map +1 -0
- package/dist/src/components/table/pagination.js +122 -0
- package/dist/src/components/ui/accordion.d.ts +8 -0
- package/dist/src/components/ui/accordion.d.ts.map +1 -0
- package/dist/src/components/ui/accordion.js +47 -0
- package/dist/src/components/ui/alert-dialog.d.ts +15 -0
- package/dist/src/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/src/components/ui/alert-dialog.js +86 -0
- package/dist/src/components/ui/alert.d.ts +10 -0
- package/dist/src/components/ui/alert.d.ts.map +1 -0
- package/dist/src/components/ui/alert.js +40 -0
- package/dist/src/components/ui/badge.d.ts +10 -0
- package/dist/src/components/ui/badge.d.ts.map +1 -0
- package/dist/src/components/ui/badge.js +29 -0
- package/dist/src/components/ui/button.d.ts +13 -0
- package/dist/src/components/ui/button.d.ts.map +1 -0
- package/dist/src/components/ui/button.js +66 -0
- package/dist/src/components/ui/card.d.ts +10 -0
- package/dist/src/components/ui/card.d.ts.map +1 -0
- package/dist/src/components/ui/card.js +53 -0
- package/dist/src/components/ui/checkbox.d.ts +5 -0
- package/dist/src/components/ui/checkbox.d.ts.map +1 -0
- package/dist/src/components/ui/checkbox.js +21 -0
- package/dist/src/components/ui/collapsible.d.ts +6 -0
- package/dist/src/components/ui/collapsible.d.ts.map +1 -0
- package/dist/src/components/ui/collapsible.js +22 -0
- package/dist/src/components/ui/command.d.ts +19 -0
- package/dist/src/components/ui/command.d.ts.map +1 -0
- package/dist/src/components/ui/command.js +99 -0
- package/dist/src/components/ui/context-menu.d.ts +26 -0
- package/dist/src/components/ui/context-menu.d.ts.map +1 -0
- package/dist/src/components/ui/context-menu.js +141 -0
- package/dist/src/components/ui/dialog.d.ts +23 -0
- package/dist/src/components/ui/dialog.d.ts.map +1 -0
- package/dist/src/components/ui/dialog.js +181 -0
- package/dist/src/components/ui/drawer.d.ts +14 -0
- package/dist/src/components/ui/drawer.d.ts.map +1 -0
- package/dist/src/components/ui/drawer.js +84 -0
- package/dist/src/components/ui/dropdown-menu.d.ts +26 -0
- package/dist/src/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/src/components/ui/dropdown-menu.js +142 -0
- package/dist/src/components/ui/form.d.ts +33 -0
- package/dist/src/components/ui/form.d.ts.map +1 -0
- package/dist/src/components/ui/form.js +142 -0
- package/dist/src/components/ui/header-content.d.ts +17 -0
- package/dist/src/components/ui/header-content.d.ts.map +1 -0
- package/dist/src/components/ui/header-content.js +30 -0
- package/dist/src/components/ui/hover-card.d.ts +7 -0
- package/dist/src/components/ui/hover-card.d.ts.map +1 -0
- package/dist/src/components/ui/hover-card.js +30 -0
- package/dist/src/components/ui/input-otp.d.ts +12 -0
- package/dist/src/components/ui/input-otp.d.ts.map +1 -0
- package/dist/src/components/ui/input-otp.js +49 -0
- package/dist/src/components/ui/input.d.ts +4 -0
- package/dist/src/components/ui/input.d.ts.map +1 -0
- package/dist/src/components/ui/input.js +12 -0
- package/dist/src/components/ui/label.d.ts +5 -0
- package/dist/src/components/ui/label.d.ts.map +1 -0
- package/dist/src/components/ui/label.js +13 -0
- package/dist/src/components/ui/loader.d.ts +5 -0
- package/dist/src/components/ui/loader.d.ts.map +1 -0
- package/dist/src/components/ui/loader.js +16 -0
- package/dist/src/components/ui/menubar.d.ts +27 -0
- package/dist/src/components/ui/menubar.d.ts.map +1 -0
- package/dist/src/components/ui/menubar.js +152 -0
- package/dist/src/components/ui/navigation-menu.d.ts +15 -0
- package/dist/src/components/ui/navigation-menu.d.ts.map +1 -0
- package/dist/src/components/ui/navigation-menu.js +83 -0
- package/dist/src/components/ui/popover.d.ts +8 -0
- package/dist/src/components/ui/popover.d.ts.map +1 -0
- package/dist/src/components/ui/popover.js +35 -0
- package/dist/src/components/ui/progress.d.ts +5 -0
- package/dist/src/components/ui/progress.d.ts.map +1 -0
- package/dist/src/components/ui/progress.js +20 -0
- package/dist/src/components/ui/radio-group.d.ts +6 -0
- package/dist/src/components/ui/radio-group.d.ts.map +1 -0
- package/dist/src/components/ui/radio-group.js +28 -0
- package/dist/src/components/ui/select.d.ts +16 -0
- package/dist/src/components/ui/select.d.ts.map +1 -0
- package/dist/src/components/ui/select.js +114 -0
- package/dist/src/components/ui/separator.d.ts +5 -0
- package/dist/src/components/ui/separator.d.ts.map +1 -0
- package/dist/src/components/ui/separator.js +15 -0
- package/dist/src/components/ui/sheet.d.ts +14 -0
- package/dist/src/components/ui/sheet.d.ts.map +1 -0
- package/dist/src/components/ui/sheet.js +93 -0
- package/dist/src/components/ui/sidebar.d.ts +70 -0
- package/dist/src/components/ui/sidebar.d.ts.map +1 -0
- package/dist/src/components/ui/sidebar.js +437 -0
- package/dist/src/components/ui/skeleton.d.ts +3 -0
- package/dist/src/components/ui/skeleton.d.ts.map +1 -0
- package/dist/src/components/ui/skeleton.js +10 -0
- package/dist/src/components/ui/slider.d.ts +5 -0
- package/dist/src/components/ui/slider.d.ts.map +1 -0
- package/dist/src/components/ui/slider.js +42 -0
- package/dist/src/components/ui/sonner.d.ts +4 -0
- package/dist/src/components/ui/sonner.d.ts.map +1 -0
- package/dist/src/components/ui/sonner.js +26 -0
- package/dist/src/components/ui/switch.d.ts +5 -0
- package/dist/src/components/ui/switch.d.ts.map +1 -0
- package/dist/src/components/ui/switch.js +17 -0
- package/dist/src/components/ui/table.d.ts +11 -0
- package/dist/src/components/ui/table.d.ts.map +1 -0
- package/dist/src/components/ui/table.js +64 -0
- package/dist/src/components/ui/tabs.d.ts +8 -0
- package/dist/src/components/ui/tabs.d.ts.map +1 -0
- package/dist/src/components/ui/tabs.js +34 -0
- package/dist/src/components/ui/textarea.d.ts +4 -0
- package/dist/src/components/ui/textarea.d.ts.map +1 -0
- package/dist/src/components/ui/textarea.js +11 -0
- package/dist/src/components/ui/toggle-group.d.ts +8 -0
- package/dist/src/components/ui/toggle-group.d.ts.map +1 -0
- package/dist/src/components/ui/toggle-group.js +41 -0
- package/dist/src/components/ui/toggle.d.ts +10 -0
- package/dist/src/components/ui/toggle.d.ts.map +1 -0
- package/dist/src/components/ui/toggle.js +35 -0
- package/dist/src/components/ui/tooltip.d.ts +8 -0
- package/dist/src/components/ui/tooltip.d.ts.map +1 -0
- package/dist/src/components/ui/tooltip.js +43 -0
- package/dist/src/components/ui/unsaved-changes-dialog.d.ts +1 -0
- package/dist/src/components/ui/unsaved-changes-dialog.d.ts.map +1 -0
- package/dist/src/config.d.ts +5 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +4 -0
- package/dist/src/database/admins.d.ts +246 -0
- package/dist/src/database/admins.d.ts.map +1 -0
- package/dist/src/database/admins.js +74 -0
- package/dist/src/database/languages.d.ts +321 -0
- package/dist/src/database/languages.d.ts.map +1 -0
- package/dist/src/database/languages.js +52 -0
- package/dist/src/database/moderators.d.ts +114 -0
- package/dist/src/database/moderators.d.ts.map +1 -0
- package/dist/src/database/moderators.js +37 -0
- package/dist/src/database/roles.d.ts +146 -0
- package/dist/src/database/roles.d.ts.map +1 -0
- package/dist/src/database/roles.js +13 -0
- package/dist/src/database/sessions.d.ts +196 -0
- package/dist/src/database/sessions.d.ts.map +1 -0
- package/dist/src/database/sessions.js +57 -0
- package/dist/src/database/users.d.ts +562 -0
- package/dist/src/database/users.d.ts.map +1 -0
- package/dist/src/database/users.js +142 -0
- package/dist/src/drizzle.config.d.ts +6 -0
- package/dist/src/drizzle.config.d.ts.map +1 -0
- package/dist/src/drizzle.config.js +37 -0
- package/dist/src/hooks/use-before-unload-with-dialog.d.ts +1 -0
- package/dist/src/hooks/use-before-unload-with-dialog.d.ts.map +1 -0
- package/dist/src/hooks/use-before-unload.d.ts +2 -0
- package/dist/src/hooks/use-before-unload.d.ts.map +1 -0
- package/dist/src/hooks/use-before-unload.js +30 -0
- package/dist/src/hooks/use-mobile.d.ts +2 -0
- package/dist/src/hooks/use-mobile.d.ts.map +1 -0
- package/dist/src/hooks/use-mobile.js +15 -0
- package/dist/src/hooks/use-unsaved-changes.d.ts +1 -0
- package/dist/src/hooks/use-unsaved-changes.d.ts.map +1 -0
- package/dist/src/lib/api/get-middleware-api.d.ts +8 -0
- package/dist/src/lib/api/get-middleware-api.d.ts.map +1 -0
- package/dist/src/lib/api/get-middleware-api.js +13 -0
- package/dist/src/lib/api/get-session-admin-api.d.ts +16 -0
- package/dist/src/lib/api/get-session-admin-api.d.ts.map +1 -0
- package/dist/src/lib/api/get-session-admin-api.js +19 -0
- package/dist/src/lib/api/get-session-api.d.ts +17 -0
- package/dist/src/lib/api/get-session-api.d.ts.map +1 -0
- package/dist/src/lib/api/get-session-api.js +14 -0
- package/dist/src/lib/colors.d.ts +23 -0
- package/dist/src/lib/colors.d.ts.map +1 -0
- package/dist/src/lib/colors.js +131 -0
- package/dist/src/lib/colors.test.d.ts +2 -0
- package/dist/src/lib/colors.test.d.ts.map +1 -0
- package/dist/src/lib/colors.test.js +173 -0
- package/dist/src/lib/config.d.ts +6 -0
- package/dist/src/lib/config.d.ts.map +1 -0
- package/dist/src/lib/config.js +15 -0
- package/dist/src/lib/fetcher/cookie-from-string-to-object.d.ts +10 -0
- package/dist/src/lib/fetcher/cookie-from-string-to-object.d.ts.map +1 -0
- package/dist/src/lib/fetcher/cookie-from-string-to-object.js +12 -0
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.d.ts +2 -0
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.d.ts.map +1 -0
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +78 -0
- package/dist/src/lib/fetcher/fetcher.d.ts +9 -0
- package/dist/src/lib/fetcher/fetcher.d.ts.map +1 -0
- package/dist/src/lib/fetcher/helpers.d.ts +3 -0
- package/dist/src/lib/fetcher/helpers.d.ts.map +1 -0
- package/dist/src/lib/fetcher/helpers.js +33 -0
- package/dist/src/lib/fetcher/helpers.test.d.ts +2 -0
- package/dist/src/lib/fetcher/helpers.test.d.ts.map +1 -0
- package/dist/src/lib/fetcher/helpers.test.js +37 -0
- package/dist/src/lib/fetcher/index.d.ts +34 -0
- package/dist/src/lib/fetcher/index.d.ts.map +1 -0
- package/dist/src/lib/fetcher/types.d.ts +120 -0
- package/dist/src/lib/fetcher/types.d.ts.map +1 -0
- package/dist/src/lib/fetcher/types.js +1 -0
- package/dist/src/lib/fetcher.d.ts +9 -0
- package/dist/src/lib/fetcher.d.ts.map +1 -0
- package/dist/src/lib/fetcher.js +47 -0
- package/dist/src/lib/helpers/auto-form.d.ts +10 -0
- package/dist/src/lib/helpers/auto-form.d.ts.map +1 -0
- package/dist/src/lib/helpers/auto-form.js +82 -0
- package/dist/src/lib/helpers/auto-form.test.d.ts +2 -0
- package/dist/src/lib/helpers/auto-form.test.d.ts.map +1 -0
- package/dist/src/lib/helpers/auto-form.test.js +126 -0
- package/dist/src/lib/navigation.d.ts +339 -0
- package/dist/src/lib/navigation.d.ts.map +1 -0
- package/dist/src/lib/navigation.js +11 -0
- package/dist/src/lib/plugin.d.ts +15 -0
- package/dist/src/lib/plugin.d.ts.map +1 -0
- package/dist/src/lib/plugin.js +3 -0
- package/dist/src/lib/special-characters.d.ts +3 -0
- package/dist/src/lib/special-characters.d.ts.map +1 -0
- package/dist/src/lib/special-characters.js +4 -0
- package/dist/src/lib/special-characters.test.d.ts +2 -0
- package/dist/src/lib/special-characters.test.d.ts.map +1 -0
- package/dist/src/lib/special-characters.test.js +56 -0
- package/dist/src/lib/utils.d.ts +3 -0
- package/dist/src/lib/utils.d.ts.map +1 -0
- package/dist/src/lib/utils.js +5 -0
- package/dist/src/tests/setup.d.ts +2 -0
- package/dist/src/tests/setup.d.ts.map +1 -0
- package/dist/src/tests/setup.js +6 -0
- package/dist/src/views/admin/layouts/admin-layout.d.ts +8 -0
- package/dist/src/views/admin/layouts/admin-layout.d.ts.map +1 -0
- package/dist/src/views/admin/layouts/admin-layout.js +70 -0
- package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts +11 -0
- package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts.map +1 -0
- package/dist/src/views/admin/layouts/sidebar/nav/item.js +70 -0
- package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts +10 -0
- package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts.map +1 -0
- package/dist/src/views/admin/layouts/sidebar/nav/nav.js +49 -0
- package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts +3 -0
- package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts.map +1 -0
- package/dist/src/views/admin/layouts/sidebar/sidebar.js +30 -0
- package/dist/src/views/admin/layouts/sidebar/sign-out.d.ts +4 -0
- package/dist/src/views/admin/layouts/sidebar/sign-out.d.ts.map +1 -0
- package/dist/src/views/admin/layouts/sidebar/sign-out.js +14 -0
- package/dist/src/views/admin/layouts/user-bar/client.d.ts +7 -0
- package/dist/src/views/admin/layouts/user-bar/client.d.ts.map +1 -0
- package/dist/src/views/admin/layouts/user-bar/client.js +61 -0
- package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts +3 -0
- package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts.map +1 -0
- package/dist/src/views/admin/layouts/user-bar/user-bar.js +31 -0
- package/dist/src/views/admin/sign-in/sign-in-admin-view.d.ts +2 -0
- package/dist/src/views/admin/sign-in/sign-in-admin-view.d.ts.map +1 -0
- package/dist/src/views/admin/sign-in/sign-in-admin-view.js +26 -0
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.d.ts +2 -0
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.d.ts.map +1 -0
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +44 -0
- package/dist/src/views/admin/views/core/test.d.ts +2 -0
- package/dist/src/views/admin/views/core/test.d.ts.map +1 -0
- package/dist/src/views/admin/views/core/test.js +146 -0
- package/dist/src/views/admin/views/core/users/users-admin-view.d.ts +4 -0
- package/dist/src/views/admin/views/core/users/users-admin-view.d.ts.map +1 -0
- package/dist/src/views/admin/views/core/users/users-admin-view.js +90 -0
- package/dist/src/views/auth/components/password-input.d.ts +4 -0
- package/dist/src/views/auth/components/password-input.d.ts.map +1 -0
- package/dist/src/views/auth/components/password-input.js +89 -0
- package/dist/src/views/auth/sign-in/form/form.d.ts +4 -0
- package/dist/src/views/auth/sign-in/form/form.d.ts.map +1 -0
- package/dist/src/views/auth/sign-in/form/form.js +59 -0
- package/dist/src/views/auth/sign-in/form/hooks/mutation-api.d.ts +10 -0
- package/dist/src/views/auth/sign-in/form/hooks/mutation-api.d.ts.map +1 -0
- package/dist/src/views/auth/sign-in/form/hooks/mutation-api.js +33 -0
- package/dist/src/views/auth/sign-in/form/hooks/use-form.d.ts +27 -0
- package/dist/src/views/auth/sign-in/form/hooks/use-form.d.ts.map +1 -0
- package/dist/src/views/auth/sign-in/form/hooks/use-form.js +38 -0
- package/dist/src/views/auth/sign-in/sign-in-view.d.ts +2 -0
- package/dist/src/views/auth/sign-in/sign-in-view.d.ts.map +1 -0
- package/dist/src/views/auth/sign-in/sign-in-view.js +55 -0
- package/dist/src/views/auth/sign-up/form/form.d.ts +4 -0
- package/dist/src/views/auth/sign-up/form/form.d.ts.map +1 -0
- package/dist/src/views/auth/sign-up/form/form.js +88 -0
- package/dist/src/views/auth/sign-up/form/hooks/mutation-api.d.ts +6 -0
- package/dist/src/views/auth/sign-up/form/hooks/mutation-api.d.ts.map +1 -0
- package/dist/src/views/auth/sign-up/form/hooks/mutation-api.js +18 -0
- package/dist/src/views/auth/sign-up/form/hooks/use-form.d.ts +61 -0
- package/dist/src/views/auth/sign-up/form/hooks/use-form.d.ts.map +1 -0
- package/dist/src/views/auth/sign-up/form/hooks/use-form.js +57 -0
- package/dist/src/views/auth/sign-up/sign-up-view.d.ts +2 -0
- package/dist/src/views/auth/sign-up/sign-up-view.d.ts.map +1 -0
- package/dist/src/views/auth/sign-up/sign-up-view.js +61 -0
- package/dist/src/views/auth/sso/buttons/client.d.ts +5 -0
- package/dist/src/views/auth/sso/buttons/client.d.ts.map +1 -0
- package/dist/src/views/auth/sso/buttons/client.js +22 -0
- package/dist/src/views/auth/sso/buttons/mutation-api.d.ts +4 -0
- package/dist/src/views/auth/sso/buttons/mutation-api.d.ts.map +1 -0
- package/dist/src/views/auth/sso/buttons/mutation-api.js +24 -0
- package/dist/src/views/auth/sso/buttons/sso-buttons.d.ts +3 -0
- package/dist/src/views/auth/sso/buttons/sso-buttons.d.ts.map +1 -0
- package/dist/src/views/auth/sso/buttons/sso-buttons.js +51 -0
- package/dist/src/views/auth/sso/callback/callback-sso-view.d.ts +5 -0
- package/dist/src/views/auth/sso/callback/callback-sso-view.d.ts.map +1 -0
- package/dist/src/views/auth/sso/callback/callback-sso-view.js +18 -0
- package/dist/src/views/auth/sso/callback/client/client.d.ts +6 -0
- package/dist/src/views/auth/sso/callback/client/client.d.ts.map +1 -0
- package/dist/src/views/auth/sso/callback/client/client.js +39 -0
- package/dist/src/views/auth/sso/callback/client/mutation-api.d.ts +8 -0
- package/dist/src/views/auth/sso/callback/client/mutation-api.d.ts.map +1 -0
- package/dist/src/views/auth/sso/callback/client/mutation-api.js +27 -0
- package/dist/src/views/error/back-button.d.ts +5 -0
- package/dist/src/views/error/back-button.d.ts.map +1 -0
- package/dist/src/views/error/back-button.js +14 -0
- package/dist/src/views/error/error-view.d.ts +5 -0
- package/dist/src/views/error/error-view.d.ts.map +1 -0
- package/dist/src/views/error/error-view.js +56 -0
- package/dist/src/views/error/global-error-view.d.ts +6 -0
- package/dist/src/views/error/global-error-view.d.ts.map +1 -0
- package/dist/src/views/error/global-error-view.js +57 -0
- package/dist/src/views/layouts/provider.d.ts +11 -0
- package/dist/src/views/layouts/provider.d.ts.map +1 -0
- package/dist/src/views/layouts/provider.js +43 -0
- package/dist/src/views/layouts/root-layout.d.ts +16 -0
- package/dist/src/views/layouts/root-layout.d.ts.map +1 -0
- package/dist/src/views/layouts/root-layout.js +38 -0
- package/dist/src/views/layouts/theme/header/header.d.ts +4 -0
- package/dist/src/views/layouts/theme/header/header.d.ts.map +1 -0
- package/dist/src/views/layouts/theme/header/header.js +32 -0
- package/dist/src/views/layouts/theme/header/user/auth/auth.d.ts +2 -0
- package/dist/src/views/layouts/theme/header/user/auth/auth.d.ts.map +1 -0
- package/dist/src/views/layouts/theme/header/user/auth/auth.js +33 -0
- package/dist/src/views/layouts/theme/header/user/auth/client.d.ts +5 -0
- package/dist/src/views/layouts/theme/header/user/auth/client.d.ts.map +1 -0
- package/dist/src/views/layouts/theme/header/user/auth/client.js +47 -0
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.d.ts +4 -0
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.d.ts.map +1 -0
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +27 -0
- package/dist/src/views/layouts/theme/header/user/user.d.ts +2 -0
- package/dist/src/views/layouts/theme/header/user/user.d.ts.map +1 -0
- package/dist/src/views/layouts/theme/header/user/user.js +34 -0
- package/dist/src/views/layouts/theme/layout.d.ts +5 -0
- package/dist/src/views/layouts/theme/layout.d.ts.map +1 -0
- package/dist/src/views/layouts/theme/layout.js +15 -0
- package/dist/src/vitnode.config.d.ts +50 -0
- package/dist/src/vitnode.config.d.ts.map +1 -0
- package/dist/src/vitnode.config.js +39 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/tsup.config.d.ts +3 -0
- package/dist/tsup.config.d.ts.map +1 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/package.json +94 -0
- package/src/app/login/page.tsx +21 -0
- package/src/app/login/sso/[providerId]/page.tsx +19 -0
- package/src/app/register/page.tsx +21 -0
- package/src/app_admin/core/page.tsx +5 -0
- package/src/app_admin/core/test/page.tsx +5 -0
- package/src/app_admin/core/users/page.tsx +35 -0
- package/src/database/admins.ts +87 -0
- package/src/database/languages.ts +54 -0
- package/src/database/moderators.ts +42 -0
- package/src/database/roles.ts +15 -0
- package/src/database/sessions.ts +59 -0
- package/src/database/users.ts +142 -0
- package/src/locales/en.json +156 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
+
import type { Route } from './route';
|
|
3
|
+
export interface BuildModuleType<T extends Route, Plugin extends string> {
|
|
4
|
+
plugin: Plugin;
|
|
5
|
+
routes: T;
|
|
6
|
+
}
|
|
7
|
+
export interface BaseBuildModuleReturn<P extends string = string, M extends string = string, Routes extends Route<P>[] = Route<P>[]> {
|
|
8
|
+
hono: OpenAPIHono;
|
|
9
|
+
modules?: BaseBuildModuleReturn<P>[];
|
|
10
|
+
name: M;
|
|
11
|
+
pluginId: P;
|
|
12
|
+
routes: Routes;
|
|
13
|
+
}
|
|
14
|
+
export interface BuildModuleReturn<P extends string, M extends string, Routes extends Route<P>[] = Route<P>[], Modules extends BaseBuildModuleReturn<P>[] = BaseBuildModuleReturn<P>[]> extends BaseBuildModuleReturn<P, M, Routes> {
|
|
15
|
+
modules?: Modules;
|
|
16
|
+
}
|
|
17
|
+
export declare function buildModule<const P extends string, const M extends string, const Routes extends Route<P>[], Modules extends BaseBuildModuleReturn<P>[]>({ routes, pluginId, name, modules, }: {
|
|
18
|
+
modules?: Modules;
|
|
19
|
+
name: M;
|
|
20
|
+
pluginId: P;
|
|
21
|
+
routes: Routes;
|
|
22
|
+
}): BuildModuleReturn<P, M, Routes, Modules>;
|
|
23
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../src/api/lib/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,KAAK,EAAE,MAAM,SAAS,MAAM;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,CAAC,CAAC;CACX;AAED,MAAM,WAAW,qBAAqB,CACpC,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,MAAM,SAAS,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE;IAEtC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC;IACR,QAAQ,EAAE,CAAC,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB,CAChC,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,MAAM,EAChB,MAAM,SAAS,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,EACtC,OAAO,SAAS,qBAAqB,CAAC,CAAC,CAAC,EAAE,GAAG,qBAAqB,CAAC,CAAC,CAAC,EAAE,CACvE,SAAQ,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,WAAW,CACzB,KAAK,CAAC,CAAC,SAAS,MAAM,EACtB,KAAK,CAAC,CAAC,SAAS,MAAM,EACtB,KAAK,CAAC,MAAM,SAAS,KAAK,CAAC,CAAC,CAAC,EAAE,EAC/B,OAAO,SAAS,qBAAqB,CAAC,CAAC,CAAC,EAAE,EAC1C,EACA,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,OAAO,GACR,EAAE;IACD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,CAAC,CAAC;IACR,QAAQ,EAAE,CAAC,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAgB3C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
+
export function buildModule({ routes, pluginId, name, modules }) {
|
|
3
|
+
const hono = new OpenAPIHono();
|
|
4
|
+
if (routes) {
|
|
5
|
+
routes.forEach(({ handler, route })=>{
|
|
6
|
+
hono.openapi(route, handler);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
if (modules) {
|
|
10
|
+
modules.forEach((module)=>{
|
|
11
|
+
hono.route(`/${module.name}`, module.hono);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
routes,
|
|
16
|
+
pluginId,
|
|
17
|
+
hono,
|
|
18
|
+
name,
|
|
19
|
+
modules
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
+
import type { BuildModuleReturn } from './module';
|
|
3
|
+
export interface BuildPluginApiReturn {
|
|
4
|
+
hono: OpenAPIHono;
|
|
5
|
+
pluginId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function buildApiPlugin<P extends string>({ pluginId, modules, }: {
|
|
8
|
+
modules?: BuildModuleReturn<P, string>[];
|
|
9
|
+
pluginId: P;
|
|
10
|
+
}): BuildPluginApiReturn;
|
|
11
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/api/lib/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIlD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,EAC/C,QAAQ,EACR,OAAY,GACb,EAAE;IACD,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC;IACzC,QAAQ,EAAE,CAAC,CAAC;CACb,GAAG,oBAAoB,CAavB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
+
import { checkPluginId } from "./check-plugin-id";
|
|
3
|
+
export function buildApiPlugin({ pluginId, modules = [] }) {
|
|
4
|
+
// Run for checking if the plugin is valid
|
|
5
|
+
checkPluginId(pluginId);
|
|
6
|
+
const hono = new OpenAPIHono();
|
|
7
|
+
modules.forEach((handler)=>{
|
|
8
|
+
hono.route(`/${handler.name}`, handler.hono);
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
pluginId,
|
|
12
|
+
hono
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RouteConfig, RouteHandler } from '@hono/zod-openapi';
|
|
2
|
+
import { type EnvVitNode } from '../middlewares/global/global';
|
|
3
|
+
type RoutingPath<P extends string> = P extends `${infer Head}/{${infer Param}}${infer Tail}` ? `${Head}/:${Param}${RoutingPath<Tail>}` : P;
|
|
4
|
+
type ValidHandler<R extends RouteConfig> = (c: Parameters<RouteHandler<R, EnvVitNode>>[0]) => ReturnType<RouteHandler<R>>;
|
|
5
|
+
export declare const buildRoute: <Plugin extends string, P extends string, R extends Omit<RouteConfig, "path"> & {
|
|
6
|
+
path: P;
|
|
7
|
+
}, H extends ValidHandler<R & {
|
|
8
|
+
path: P;
|
|
9
|
+
}>>({ route, handler, pluginId, }: {
|
|
10
|
+
handler: H;
|
|
11
|
+
pluginId: Plugin;
|
|
12
|
+
route: R;
|
|
13
|
+
}) => {
|
|
14
|
+
handler: H;
|
|
15
|
+
pluginId: Plugin;
|
|
16
|
+
route: R & {
|
|
17
|
+
getRoutingPath: () => RoutingPath<R["path"]>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export interface Route<Plugin extends string = string, R extends RouteConfig = RouteConfig, H extends RouteHandler<R> = RouteHandler<R>> {
|
|
21
|
+
handler: H;
|
|
22
|
+
pluginId: Plugin;
|
|
23
|
+
route: R;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/api/lib/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAInE,OAAO,EACL,KAAK,UAAU,EAEhB,MAAM,8BAA8B,CAAC;AAEtC,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,IAC/B,CAAC,SAAS,GAAG,MAAM,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI,EAAE,GACnD,GAAG,IAAI,KAAK,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,GACvC,CAAC,CAAC;AAER,KAAK,YAAY,CAAC,CAAC,SAAS,WAAW,IAAI,CACzC,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,KAC1C,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjC,eAAO,MAAM,UAAU,GACrB,MAAM,SAAS,MAAM,EACrB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG;IACpC,IAAI,EAAE,CAAC,CAAC;CACT,EACD,CAAC,SAAS,YAAY,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,EACvC,+BAIC;IACD,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;CACV,KAAG;IACF,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,GAAG;QACT,cAAc,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;KAC9C,CAAC;CA2BH,CAAC;AAEF,MAAM,WAAW,KAAK,CACpB,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,CAAC,SAAS,WAAW,GAAG,WAAW,EACnC,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;IAE3C,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;CACV"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRoute as createRouteHono } from "@hono/zod-openapi";
|
|
2
|
+
import { pluginMiddleware } from "../middlewares/global/global";
|
|
3
|
+
export const buildRoute = ({ route, handler, pluginId })=>{
|
|
4
|
+
const pluginTag = pluginId.split(/[-_]/).map((word)=>word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
|
5
|
+
const tags = [
|
|
6
|
+
pluginTag,
|
|
7
|
+
...route.tags ?? []
|
|
8
|
+
];
|
|
9
|
+
return {
|
|
10
|
+
route: createRouteHono({
|
|
11
|
+
tags,
|
|
12
|
+
middleware: [
|
|
13
|
+
pluginMiddleware(pluginId),
|
|
14
|
+
...Array.isArray(route.middleware) ? route.middleware : route.middleware ? [
|
|
15
|
+
route.middleware
|
|
16
|
+
] : []
|
|
17
|
+
],
|
|
18
|
+
...route
|
|
19
|
+
}),
|
|
20
|
+
handler,
|
|
21
|
+
pluginId
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ColumnBaseConfig, Placeholder, SQL } from 'drizzle-orm';
|
|
2
|
+
import type { PgColumn, PgTableWithColumns, TableConfig } from 'drizzle-orm/pg-core';
|
|
3
|
+
import type { Context } from 'hono';
|
|
4
|
+
import { z } from '@hono/zod-openapi';
|
|
5
|
+
export declare function withPagination<QueryMin extends Record<string, unknown>, T extends TableConfig, Primary extends ColumnBaseConfig<'number', string>>({ query, table, params, where: whereFromParams, primaryCursor, orderBy: orderByFromParams, c, }: {
|
|
6
|
+
c: Context;
|
|
7
|
+
orderBy: {
|
|
8
|
+
column: PgColumn;
|
|
9
|
+
order: 'asc' | 'desc';
|
|
10
|
+
};
|
|
11
|
+
params: {
|
|
12
|
+
query: {
|
|
13
|
+
cursor?: string;
|
|
14
|
+
first?: string;
|
|
15
|
+
last?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
primaryCursor: PgColumn<Primary>;
|
|
19
|
+
query: (args: {
|
|
20
|
+
limit: number | Placeholder<string, unknown>;
|
|
21
|
+
orderBy: SQL;
|
|
22
|
+
where: SQL | undefined;
|
|
23
|
+
}) => Promise<QueryMin[]>;
|
|
24
|
+
table: Omit<PgTableWithColumns<T>, 'enableRLS'>;
|
|
25
|
+
where?: SQL;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
edges: QueryMin[];
|
|
28
|
+
pageInfo: {
|
|
29
|
+
count: number;
|
|
30
|
+
endCursor: null | number;
|
|
31
|
+
hasNextPage: boolean;
|
|
32
|
+
hasPreviousPage: boolean;
|
|
33
|
+
startCursor: null | number;
|
|
34
|
+
totalCount: number;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
export declare const zodPaginationPageInfo: z.ZodObject<{
|
|
38
|
+
totalCount: z.ZodNumber;
|
|
39
|
+
count: z.ZodNumber;
|
|
40
|
+
hasNextPage: z.ZodBoolean;
|
|
41
|
+
hasPreviousPage: z.ZodBoolean;
|
|
42
|
+
startCursor: z.ZodNullable<z.ZodNumber>;
|
|
43
|
+
endCursor: z.ZodNullable<z.ZodNumber>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
count: number;
|
|
46
|
+
totalCount: number;
|
|
47
|
+
hasNextPage: boolean;
|
|
48
|
+
hasPreviousPage: boolean;
|
|
49
|
+
startCursor: number | null;
|
|
50
|
+
endCursor: number | null;
|
|
51
|
+
}, {
|
|
52
|
+
count: number;
|
|
53
|
+
totalCount: number;
|
|
54
|
+
hasNextPage: boolean;
|
|
55
|
+
hasPreviousPage: boolean;
|
|
56
|
+
startCursor: number | null;
|
|
57
|
+
endCursor: number | null;
|
|
58
|
+
}>;
|
|
59
|
+
export declare const zodPaginationQuery: z.ZodObject<{
|
|
60
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
61
|
+
first: z.ZodOptional<z.ZodString>;
|
|
62
|
+
last: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, "strip", z.ZodTypeAny, {
|
|
64
|
+
cursor?: string | undefined;
|
|
65
|
+
first?: string | undefined;
|
|
66
|
+
last?: string | undefined;
|
|
67
|
+
}, {
|
|
68
|
+
cursor?: string | undefined;
|
|
69
|
+
first?: string | undefined;
|
|
70
|
+
last?: string | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
//# sourceMappingURL=with-pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-pagination.d.ts","sourceRoot":"","sources":["../../../../src/api/lib/with-pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EACV,QAAQ,EAER,kBAAkB,EAClB,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAGtC,wBAAsB,cAAc,CAClC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,CAAC,SAAS,WAAW,EACrB,OAAO,SAAS,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAClD,EACA,KAAK,EACL,KAAK,EACL,MAAM,EACN,KAAK,EAAE,eAAe,EACtB,aAAa,EACb,OAAO,EAAE,iBAAiB,EAC1B,CAAC,GACF,EAAE;IACD,CAAC,EAAE,OAAO,CAAC;IACX,OAAO,EAAE;QACP,MAAM,EAAE,QAAQ,CAAC;QACjB,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;KACvB,CAAC;IACF,MAAM,EAAE;QACN,KAAK,EAAE;YACL,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CAAC;KACH,CAAC;IACF,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC,KAAK,EAAE,CAAC,IAAI,EAAE;QACZ,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7C,OAAO,EAAE,GAAG,CAAC;QACb,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC;KACxB,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1B,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAChD,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,GAAG,OAAO,CAAC;IACV,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC;QACzB,WAAW,EAAE,OAAO,CAAC;QACrB,eAAe,EAAE,OAAO,CAAC;QACzB,WAAW,EAAE,IAAI,GAAG,MAAM,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC,CAqFD;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;EAOhC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAI7B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
import { and, asc, count, desc, gt, lt } from "drizzle-orm";
|
|
3
|
+
export async function withPagination({ query, table, params, where: whereFromParams, primaryCursor, orderBy: orderByFromParams, c }) {
|
|
4
|
+
// Parse and validate pagination parameters
|
|
5
|
+
const cursor = params.query.cursor ? parseInt(params.query.cursor, 10) : undefined;
|
|
6
|
+
const first = params.query.first ? Math.min(parseInt(params.query.first, 10), 100) : undefined;
|
|
7
|
+
const last = params.query.last ? Math.min(parseInt(params.query.last, 10), 100) : undefined;
|
|
8
|
+
if (first !== undefined && last !== undefined) {
|
|
9
|
+
throw new Error('Cannot specify both first and last');
|
|
10
|
+
}
|
|
11
|
+
if (first !== undefined && first < 0) {
|
|
12
|
+
throw new Error('first must be positive');
|
|
13
|
+
}
|
|
14
|
+
if (last !== undefined && last < 0) {
|
|
15
|
+
throw new Error('last must be positive');
|
|
16
|
+
}
|
|
17
|
+
// Determine sort direction based on pagination parameters
|
|
18
|
+
const isForward = last === undefined;
|
|
19
|
+
const orderFn = isForward ? orderByFromParams.order === 'asc' ? asc : desc : orderByFromParams.order === 'asc' ? desc : asc;
|
|
20
|
+
const orderBy = orderFn(table[orderByFromParams.column.name]);
|
|
21
|
+
// Build where clause with cursor
|
|
22
|
+
let where = whereFromParams;
|
|
23
|
+
if (cursor) {
|
|
24
|
+
const cursorFilter = isForward ? orderByFromParams.order === 'asc' ? gt : lt : orderByFromParams.order === 'asc' ? lt : gt;
|
|
25
|
+
const cursorWhere = cursorFilter(table[primaryCursor.name], cursor);
|
|
26
|
+
where = where ? and(where, cursorWhere) : cursorWhere;
|
|
27
|
+
}
|
|
28
|
+
// Get total count
|
|
29
|
+
const [{ count: totalCount }] = await c.get('db').select({
|
|
30
|
+
count: count()
|
|
31
|
+
}).from(table).where(whereFromParams);
|
|
32
|
+
// Fetch one extra item to determine if there are more pages
|
|
33
|
+
const limit = (first ?? last ?? 50) + 1;
|
|
34
|
+
const edges = await query({
|
|
35
|
+
limit,
|
|
36
|
+
where,
|
|
37
|
+
orderBy
|
|
38
|
+
});
|
|
39
|
+
// Process results
|
|
40
|
+
const hasMore = edges.length > (first ?? last ?? edges.length);
|
|
41
|
+
const slicedEdges = edges.slice(0, first ?? last ?? edges.length);
|
|
42
|
+
const finalEdges = isForward ? slicedEdges : slicedEdges.reverse();
|
|
43
|
+
// Prepare cursors
|
|
44
|
+
const startCursor = finalEdges[0]?.[primaryCursor.name] ?? null;
|
|
45
|
+
const endCursor = finalEdges[finalEdges.length - 1]?.[primaryCursor.name] ?? null;
|
|
46
|
+
return {
|
|
47
|
+
pageInfo: {
|
|
48
|
+
totalCount,
|
|
49
|
+
count: finalEdges.length,
|
|
50
|
+
hasNextPage: isForward ? hasMore : !!cursor,
|
|
51
|
+
hasPreviousPage: isForward ? !!cursor : hasMore,
|
|
52
|
+
startCursor,
|
|
53
|
+
endCursor
|
|
54
|
+
},
|
|
55
|
+
edges: finalEdges
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export const zodPaginationPageInfo = z.object({
|
|
59
|
+
totalCount: z.number(),
|
|
60
|
+
count: z.number(),
|
|
61
|
+
hasNextPage: z.boolean(),
|
|
62
|
+
hasPreviousPage: z.boolean(),
|
|
63
|
+
startCursor: z.number().nullable(),
|
|
64
|
+
endCursor: z.number().nullable()
|
|
65
|
+
});
|
|
66
|
+
export const zodPaginationQuery = z.object({
|
|
67
|
+
cursor: z.string().optional(),
|
|
68
|
+
first: z.string().optional(),
|
|
69
|
+
last: z.string().optional()
|
|
70
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Context, Env, Next } from 'hono';
|
|
2
|
+
import type { EmailApiPlugin } from '../../../api/models/email';
|
|
3
|
+
import type { VitNodeApiConfig, VitNodeConfig } from '../../../vitnode.config';
|
|
4
|
+
import type { SSOApiPlugin } from '../../models/sso';
|
|
5
|
+
export interface EnvVitNode extends Env {
|
|
6
|
+
Variables: EnvVariablesVitNode;
|
|
7
|
+
}
|
|
8
|
+
interface EnvVariablesVitNode {
|
|
9
|
+
admin: null | {
|
|
10
|
+
user: {
|
|
11
|
+
avatarColor: string;
|
|
12
|
+
birthday: Date | null;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
email: string;
|
|
15
|
+
emailVerified: boolean;
|
|
16
|
+
id: number;
|
|
17
|
+
name: string;
|
|
18
|
+
nameCode: string;
|
|
19
|
+
newsletter: boolean;
|
|
20
|
+
roleId: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
core: {
|
|
24
|
+
authorization: {
|
|
25
|
+
adminCookieExpires: number;
|
|
26
|
+
adminCookieName: string;
|
|
27
|
+
cookie_expires: number;
|
|
28
|
+
cookieName: string;
|
|
29
|
+
cookieSecure: boolean;
|
|
30
|
+
deviceCookieExpires: number;
|
|
31
|
+
deviceCookieName: string;
|
|
32
|
+
ssoPlugins: SSOApiPlugin[];
|
|
33
|
+
};
|
|
34
|
+
emailProvider?: EmailApiPlugin;
|
|
35
|
+
metadata: {
|
|
36
|
+
shortTitle?: string;
|
|
37
|
+
title: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
db: Pick<VitNodeApiConfig, 'dbProvider'>['dbProvider'];
|
|
41
|
+
deviceId: number;
|
|
42
|
+
plugin: {
|
|
43
|
+
id: string;
|
|
44
|
+
};
|
|
45
|
+
user: null | {
|
|
46
|
+
avatarColor: string;
|
|
47
|
+
birthday: Date | null;
|
|
48
|
+
createdAt: Date;
|
|
49
|
+
email: string;
|
|
50
|
+
emailVerified: boolean;
|
|
51
|
+
id: number;
|
|
52
|
+
name: string;
|
|
53
|
+
nameCode: string;
|
|
54
|
+
newsletter: boolean;
|
|
55
|
+
roleId: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
declare module 'hono' {
|
|
59
|
+
interface ContextVariableMap extends EnvVariablesVitNode {
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export declare const globalMiddleware: ({ authorization, metadata, emailProvider, dbProvider, }: Pick<VitNodeApiConfig, "authorization" | "dbProvider" | "emailProvider"> & Pick<VitNodeConfig, "metadata">) => (c: Context, next: Next) => Promise<void>;
|
|
63
|
+
export declare const pluginMiddleware: (pluginId: string) => (c: Context, next: Next) => Promise<void>;
|
|
64
|
+
export declare const globalAdminMiddleware: () => (c: Context, next: Next) => Promise<void>;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=global.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../../../src/api/middlewares/global/global.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,WAAW,UAAW,SAAQ,GAAG;IACrC,SAAS,EAAE,mBAAmB,CAAC;CAChC;AAED,UAAU,mBAAmB;IAC3B,KAAK,EAAE,IAAI,GAAG;QACZ,IAAI,EAAE;YACJ,WAAW,EAAE,MAAM,CAAC;YACpB,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;YACtB,SAAS,EAAE,IAAI,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC;YACd,aAAa,EAAE,OAAO,CAAC;YACvB,EAAE,EAAE,MAAM,CAAC;YACX,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE,OAAO,CAAC;YACpB,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;IACF,IAAI,EAAE;QACJ,aAAa,EAAE;YACb,kBAAkB,EAAE,MAAM,CAAC;YAC3B,eAAe,EAAE,MAAM,CAAC;YACxB,cAAc,EAAE,MAAM,CAAC;YACvB,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,OAAO,CAAC;YACtB,mBAAmB,EAAE,MAAM,CAAC;YAC5B,gBAAgB,EAAE,MAAM,CAAC;YACzB,UAAU,EAAE,YAAY,EAAE,CAAC;SAC5B,CAAC;QACF,aAAa,CAAC,EAAE,cAAc,CAAC;QAC/B,QAAQ,EAAE;YACR,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,KAAK,EAAE,MAAM,CAAC;SACf,CAAC;KACH,CAAC;IACF,EAAE,EAAE,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC,YAAY,CAAC,CAAC;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE;QACN,EAAE,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,IAAI,EAAE,IAAI,GAAG;QACX,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;QACtB,SAAS,EAAE,IAAI,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,aAAa,EAAE,OAAO,CAAC;QACvB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,OAAO,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,OAAO,QAAQ,MAAM,CAAC;IAEpB,UAAU,kBAAmB,SAAQ,mBAAmB;KAAG;CAC5D;AAED,eAAO,MAAM,gBAAgB,GAAI,yDAK9B,IAAI,CAAC,gBAAgB,EAAE,eAAe,GAAG,YAAY,GAAG,eAAe,CAAC,GACzE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,MACjB,GAAG,OAAO,EAAE,MAAM,IAAI,kBA6BrC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,MACjC,GAAG,OAAO,EAAE,MAAM,IAAI,kBAMrC,CAAC;AAEF,eAAO,MAAM,qBAAqB,SAClB,GAAG,OAAO,EAAE,MAAM,IAAI,kBASrC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { HTTPException } from "hono/http-exception";
|
|
2
|
+
import { DeviceModel } from "../../models/device";
|
|
3
|
+
import { SessionModel } from "../../models/session";
|
|
4
|
+
import { SessionAdminModel } from "../../models/session-admin";
|
|
5
|
+
export const globalMiddleware = ({ authorization, metadata, emailProvider, dbProvider })=>{
|
|
6
|
+
return async (c, next)=>{
|
|
7
|
+
c.set('db', dbProvider);
|
|
8
|
+
c.set('core', {
|
|
9
|
+
metadata,
|
|
10
|
+
emailProvider,
|
|
11
|
+
authorization: {
|
|
12
|
+
cookieName: authorization?.cookieName ?? 'vitnode_auth',
|
|
13
|
+
cookie_expires: authorization?.cookieExpires ?? 1000 * 60 * 60 * 24 * 90,
|
|
14
|
+
ssoPlugins: authorization?.ssoPlugins ?? [],
|
|
15
|
+
deviceCookieName: authorization?.deviceCookieName ?? 'vitnode_device',
|
|
16
|
+
deviceCookieExpires: authorization?.deviceCookieExpires ?? 1000 * 60 * 60 * 24 * 365,
|
|
17
|
+
adminCookieName: authorization?.adminCookieName ?? 'vitnode_auth_admin',
|
|
18
|
+
adminCookieExpires: authorization?.adminCookieExpires ?? 1000 * 60 * 60 * 24 * 1,
|
|
19
|
+
cookieSecure: authorization?.cookieSecure ?? true
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const deviceId = await new DeviceModel(c).getDeviceId();
|
|
23
|
+
c.set('deviceId', deviceId);
|
|
24
|
+
const user = await new SessionModel(c).getUser();
|
|
25
|
+
c.set('user', user);
|
|
26
|
+
c.set('admin', null);
|
|
27
|
+
await next();
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export const pluginMiddleware = (pluginId)=>{
|
|
31
|
+
return async (c, next)=>{
|
|
32
|
+
c.set('plugin', {
|
|
33
|
+
id: pluginId
|
|
34
|
+
});
|
|
35
|
+
await next();
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export const globalAdminMiddleware = ()=>{
|
|
39
|
+
return async (c, next)=>{
|
|
40
|
+
const user = await new SessionAdminModel(c).getUser();
|
|
41
|
+
if (!user) throw new HTTPException(403);
|
|
42
|
+
c.set('admin', {
|
|
43
|
+
user
|
|
44
|
+
});
|
|
45
|
+
await next();
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
export declare class DeviceModel {
|
|
3
|
+
constructor(c: Context);
|
|
4
|
+
protected readonly c: Context;
|
|
5
|
+
private createDevice;
|
|
6
|
+
private getUserAgent;
|
|
7
|
+
private setCookieDevice;
|
|
8
|
+
getDeviceId(): Promise<number>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=device.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../../src/api/models/device.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAUpC,qBAAa,WAAW;gBACV,CAAC,EAAE,OAAO;IAGtB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;YAEhB,YAAY;IAe1B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAiBjB,WAAW;CAoClB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { getCookie, setCookie } from "hono/cookie";
|
|
3
|
+
import { core_sessions_known_devices } from "../../database/sessions";
|
|
4
|
+
import { CONFIG } from "../../lib/config";
|
|
5
|
+
import { getUserIp } from "../lib/get-user-ip";
|
|
6
|
+
export class DeviceModel {
|
|
7
|
+
constructor(c){
|
|
8
|
+
this.c = c;
|
|
9
|
+
}
|
|
10
|
+
c;
|
|
11
|
+
async createDevice() {
|
|
12
|
+
const [device] = await this.c.get('db').insert(core_sessions_known_devices).values({
|
|
13
|
+
ipAddress: getUserIp(this.c),
|
|
14
|
+
userAgent: this.getUserAgent()
|
|
15
|
+
}).returning({
|
|
16
|
+
id: core_sessions_known_devices.id
|
|
17
|
+
});
|
|
18
|
+
this.setCookieDevice(device.id);
|
|
19
|
+
return device.id;
|
|
20
|
+
}
|
|
21
|
+
getUserAgent() {
|
|
22
|
+
return this.c.req.header('User-Agent') ?? 'node';
|
|
23
|
+
}
|
|
24
|
+
setCookieDevice(deviceId) {
|
|
25
|
+
setCookie(this.c, this.c.get('core').authorization.deviceCookieName, deviceId.toString(), {
|
|
26
|
+
httpOnly: true,
|
|
27
|
+
secure: this.c.get('core').authorization.cookieSecure,
|
|
28
|
+
path: '/',
|
|
29
|
+
domain: CONFIG.frontend.hostname,
|
|
30
|
+
expires: new Date(Date.now() + this.c.get('core').authorization.deviceCookieExpires)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async getDeviceId() {
|
|
34
|
+
const deviceIdFromCookie = Number(getCookie(this.c, this.c.get('core').authorization.deviceCookieName));
|
|
35
|
+
try {
|
|
36
|
+
if (deviceIdFromCookie) {
|
|
37
|
+
const [device] = await this.c.get('db').select({
|
|
38
|
+
id: core_sessions_known_devices.id
|
|
39
|
+
}).from(core_sessions_known_devices).where(eq(core_sessions_known_devices.id, deviceIdFromCookie));
|
|
40
|
+
if (!device) {
|
|
41
|
+
return await this.createDevice();
|
|
42
|
+
}
|
|
43
|
+
await this.c.get('db').update(core_sessions_known_devices).set({
|
|
44
|
+
ipAddress: getUserIp(this.c),
|
|
45
|
+
userAgent: this.getUserAgent()
|
|
46
|
+
}).where(eq(core_sessions_known_devices.id, deviceIdFromCookie));
|
|
47
|
+
return device.id;
|
|
48
|
+
}
|
|
49
|
+
} catch (_) {
|
|
50
|
+
return await this.createDevice();
|
|
51
|
+
}
|
|
52
|
+
return await this.createDevice();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Context, ContextVariableMap } from 'hono';
|
|
2
|
+
export interface EmailApiPlugin {
|
|
3
|
+
sendEmail: (args: {
|
|
4
|
+
html: string;
|
|
5
|
+
metadata: ContextVariableMap['core']['metadata'];
|
|
6
|
+
replyTo?: string;
|
|
7
|
+
subject: string;
|
|
8
|
+
to: string;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare class EmailModel {
|
|
12
|
+
constructor(c: Context);
|
|
13
|
+
protected readonly c: Context;
|
|
14
|
+
isAvailable(): boolean;
|
|
15
|
+
send(args: {
|
|
16
|
+
html: string;
|
|
17
|
+
replyTo?: string;
|
|
18
|
+
subject: string;
|
|
19
|
+
to: string;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../../src/api/models/email.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAIxD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,CAAC,IAAI,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;QACjD,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,EAAE,EAAE,MAAM,CAAC;KACZ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAED,qBAAa,UAAU;gBACT,CAAC,EAAE,OAAO;IAItB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IAE9B,WAAW;IAIL,IAAI,CAAC,IAAI,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,EAAE,EAAE,MAAM,CAAC;KACZ;CAqBF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { HTTPException } from "hono/http-exception";
|
|
2
|
+
export class EmailModel {
|
|
3
|
+
constructor(c){
|
|
4
|
+
this.c = c;
|
|
5
|
+
}
|
|
6
|
+
c;
|
|
7
|
+
isAvailable() {
|
|
8
|
+
return !!this.c.get('core').emailProvider;
|
|
9
|
+
}
|
|
10
|
+
async send(args) {
|
|
11
|
+
const core = this.c.get('core');
|
|
12
|
+
const provider = core.emailProvider;
|
|
13
|
+
if (!provider) {
|
|
14
|
+
throw new HTTPException(500, {
|
|
15
|
+
message: 'Email provider not found'
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
await provider.sendEmail({
|
|
20
|
+
...args,
|
|
21
|
+
metadata: core.metadata
|
|
22
|
+
});
|
|
23
|
+
} catch (e) {
|
|
24
|
+
const error = e;
|
|
25
|
+
throw new HTTPException(500, {
|
|
26
|
+
message: error.message
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../../../src/api/models/password.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IAClB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYlD,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CASvE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
export class PasswordModel {
|
|
3
|
+
async encryptPassword(password) {
|
|
4
|
+
return new Promise((resolve, reject)=>{
|
|
5
|
+
const salt = crypto.randomBytes(8).toString('hex');
|
|
6
|
+
crypto.scrypt(password, salt, 64, (err, derivedKey)=>{
|
|
7
|
+
if (err) reject(err);
|
|
8
|
+
resolve(salt + ':' + derivedKey.toString('hex'));
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async verifyPassword(password, hash) {
|
|
13
|
+
return new Promise((resolve, reject)=>{
|
|
14
|
+
const [salt, key] = hash.split(':');
|
|
15
|
+
crypto.scrypt(password, salt, 64, (err, derivedKey)=>{
|
|
16
|
+
if (err) reject(err);
|
|
17
|
+
resolve(key == derivedKey.toString('hex'));
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
export declare class SessionAdminModel {
|
|
3
|
+
constructor(c: Context);
|
|
4
|
+
protected readonly c: Context;
|
|
5
|
+
checkIfUserIsAdmin(userId: number): Promise<boolean>;
|
|
6
|
+
createSessionByUserId(userId: number): Promise<{
|
|
7
|
+
token: string;
|
|
8
|
+
deviceId: number;
|
|
9
|
+
}>;
|
|
10
|
+
deleteSession(): Promise<void>;
|
|
11
|
+
getUser(): Promise<{
|
|
12
|
+
id: number;
|
|
13
|
+
email: string;
|
|
14
|
+
name: string;
|
|
15
|
+
nameCode: string;
|
|
16
|
+
createdAt: Date;
|
|
17
|
+
newsletter: boolean;
|
|
18
|
+
avatarColor: string;
|
|
19
|
+
emailVerified: boolean;
|
|
20
|
+
roleId: number;
|
|
21
|
+
birthday: Date | null;
|
|
22
|
+
} | null>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=session-admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-admin.d.ts","sourceRoot":"","sources":["../../../../src/api/models/session-admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAWpC,qBAAa,iBAAiB;gBAChB,CAAC,EAAE,OAAO;IAGtB,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IAExB,kBAAkB,CAAC,MAAM,EAAE,MAAM;IAmBjC,qBAAqB,CAAC,MAAM,EAAE,MAAM;;;;IAsCpC,aAAa;IAgBb,OAAO;;;;;;;;;;;;CAgCd"}
|