@vitnode/core 1.2.0-canary.52 → 1.2.0-canary.54
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/config/next.config.ts +3 -3
- package/dist/scripts/get-config.d.ts +2 -2
- package/dist/scripts/get-config.d.ts.map +1 -1
- package/dist/scripts/plugin.d.ts.map +1 -1
- package/dist/scripts/prepare-database.d.ts +0 -1
- package/dist/scripts/prepare-database.d.ts.map +1 -1
- package/dist/scripts/prepare-plugins-files.d.ts.map +1 -1
- package/dist/scripts/scripts.js +3 -3
- package/dist/scripts/shared/file-utils.d.ts.map +1 -1
- package/dist/src/api/adapters/cron/node-cron.adapter.d.ts +3 -0
- package/dist/src/api/adapters/cron/node-cron.adapter.d.ts.map +1 -0
- package/dist/src/api/adapters/cron/node-cron.adapter.js +11 -0
- package/dist/src/api/adapters/email/nodemailer.d.ts +1 -1
- package/dist/src/api/adapters/email/nodemailer.js +3 -3
- package/dist/src/api/adapters/email/resend.d.ts +1 -1
- package/dist/src/api/adapters/email/resend.js +2 -2
- package/dist/src/api/adapters/sso/discord.d.ts +1 -1
- package/dist/src/api/adapters/sso/discord.d.ts.map +1 -1
- package/dist/src/api/adapters/sso/discord.js +21 -21
- package/dist/src/api/adapters/sso/facebook.d.ts +1 -1
- package/dist/src/api/adapters/sso/facebook.d.ts.map +1 -1
- package/dist/src/api/adapters/sso/facebook.js +23 -23
- package/dist/src/api/adapters/sso/google.d.ts +1 -1
- package/dist/src/api/adapters/sso/google.d.ts.map +1 -1
- package/dist/src/api/adapters/sso/google.js +21 -21
- package/dist/src/api/config.d.ts +3 -3
- package/dist/src/api/config.d.ts.map +1 -1
- package/dist/src/api/config.js +30 -18
- package/dist/src/api/lib/check-plugin-id.js +8 -8
- package/dist/src/api/lib/cron.d.ts +18 -0
- package/dist/src/api/lib/cron.d.ts.map +1 -0
- package/dist/src/api/lib/cron.js +22 -0
- package/dist/src/api/lib/logger-middleware.d.ts +1 -1
- package/dist/src/api/lib/logger-middleware.js +9 -9
- package/dist/src/api/lib/module.d.ts +6 -3
- package/dist/src/api/lib/module.d.ts.map +1 -1
- package/dist/src/api/lib/module.js +3 -2
- package/dist/src/api/lib/plugin.d.ts +4 -2
- package/dist/src/api/lib/plugin.d.ts.map +1 -1
- package/dist/src/api/lib/plugin.js +9 -1
- package/dist/src/api/lib/route.d.ts +2 -2
- package/dist/src/api/lib/route.d.ts.map +1 -1
- package/dist/src/api/lib/route.js +1 -1
- package/dist/src/api/lib/with-pagination.d.ts +7 -7
- package/dist/src/api/lib/with-pagination.d.ts.map +1 -1
- package/dist/src/api/lib/with-pagination.js +37 -24
- package/dist/src/api/middlewares/captcha.middleware.d.ts +1 -1
- package/dist/src/api/middlewares/captcha.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/captcha.middleware.js +14 -13
- package/dist/src/api/middlewares/cron-auth.middleware.d.ts +3 -0
- package/dist/src/api/middlewares/cron-auth.middleware.d.ts.map +1 -0
- package/dist/src/api/middlewares/cron-auth.middleware.js +19 -0
- package/dist/src/api/middlewares/global.middleware.d.ts +18 -12
- package/dist/src/api/middlewares/global.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/global.middleware.js +46 -34
- package/dist/src/api/middlewares/rate-limiter.middleware.d.ts +3 -3
- package/dist/src/api/middlewares/rate-limiter.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/rate-limiter.middleware.js +4 -4
- package/dist/src/api/models/device.d.ts +1 -1
- package/dist/src/api/models/device.d.ts.map +1 -1
- package/dist/src/api/models/device.js +13 -13
- package/dist/src/api/models/email.d.ts +15 -15
- package/dist/src/api/models/email.d.ts.map +1 -1
- package/dist/src/api/models/email.js +11 -10
- package/dist/src/api/models/password.js +9 -9
- package/dist/src/api/models/session-admin.d.ts +1 -1
- package/dist/src/api/models/session-admin.d.ts.map +1 -1
- package/dist/src/api/models/session-admin.js +19 -19
- package/dist/src/api/models/session.d.ts +1 -1
- package/dist/src/api/models/session.d.ts.map +1 -1
- package/dist/src/api/models/session.js +17 -17
- package/dist/src/api/models/sso.d.ts +1 -1
- package/dist/src/api/models/sso.d.ts.map +1 -1
- package/dist/src/api/models/sso.js +22 -25
- package/dist/src/api/models/user/get-user-by-id.d.ts +1 -1
- package/dist/src/api/models/user/get-user-by-id.d.ts.map +1 -1
- package/dist/src/api/models/user/get-user-by-id.js +1 -1
- package/dist/src/api/models/user/sign-in-with-passwords.d.ts +1 -1
- package/dist/src/api/models/user/sign-in-with-passwords.d.ts.map +1 -1
- package/dist/src/api/models/user/sign-in-with-passwords.js +1 -1
- package/dist/src/api/models/user/sign-up.d.ts +2 -2
- package/dist/src/api/models/user/sign-up.d.ts.map +1 -1
- package/dist/src/api/models/user/sign-up.js +11 -12
- package/dist/src/api/models/user.d.ts +1 -1
- package/dist/src/api/models/user.d.ts.map +1 -1
- package/dist/src/api/modules/admin/admin.module.d.ts +166 -4
- package/dist/src/api/modules/admin/admin.module.d.ts.map +1 -1
- package/dist/src/api/modules/admin/admin.module.js +7 -4
- package/dist/src/api/modules/admin/advanced/advanced.admin.module.d.ts +164 -0
- package/dist/src/api/modules/admin/advanced/advanced.admin.module.d.ts.map +1 -0
- package/dist/src/api/modules/admin/advanced/advanced.admin.module.js +11 -0
- package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.d.ts +164 -0
- package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.d.ts.map +1 -0
- package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.js +12 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/get.route.d.ts +98 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/get.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/get.route.js +66 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/run.route.d.ts +70 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/run.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/advanced/cron/routes/run.route.js +95 -0
- package/dist/src/api/modules/admin/debug/debug.admin.module.d.ts +1 -1
- package/dist/src/api/modules/admin/debug/debug.admin.module.js +2 -2
- package/dist/src/api/modules/admin/debug/routes/logs.route.d.ts +2 -2
- package/dist/src/api/modules/admin/debug/routes/logs.route.js +17 -17
- package/dist/src/api/modules/admin/routes/session.route.d.ts +2 -2
- package/dist/src/api/modules/admin/routes/session.route.js +8 -8
- package/dist/src/api/modules/admin/users/routes/list.route.d.ts +2 -2
- package/dist/src/api/modules/admin/users/routes/list.route.js +13 -13
- package/dist/src/api/modules/admin/users/routes/users.route.d.ts +5 -5
- package/dist/src/api/modules/admin/users/routes/users.route.js +16 -16
- package/dist/src/api/modules/admin/users/users.admin.module.d.ts +1 -1
- package/dist/src/api/modules/admin/users/users.admin.module.js +2 -2
- package/dist/src/api/modules/cron/cron/clean.cron.d.ts +2 -0
- package/dist/src/api/modules/cron/cron/clean.cron.d.ts.map +1 -0
- package/dist/src/api/modules/cron/cron/clean.cron.js +24 -0
- package/dist/src/api/modules/cron/cron.module.d.ts +26 -0
- package/dist/src/api/modules/cron/cron.module.d.ts.map +1 -0
- package/dist/src/api/modules/cron/cron.module.js +14 -0
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts +36 -0
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts.map +1 -0
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.js +72 -0
- package/dist/src/api/modules/cron/routes/cron.route.d.ts +27 -0
- package/dist/src/api/modules/cron/routes/cron.route.d.ts.map +1 -0
- package/dist/src/api/modules/cron/routes/cron.route.js +95 -0
- package/dist/src/api/modules/middleware/middleware.module.d.ts +1 -1
- package/dist/src/api/modules/middleware/middleware.module.js +2 -2
- package/dist/src/api/modules/middleware/route.d.ts +2 -2
- package/dist/src/api/modules/middleware/route.js +13 -13
- package/dist/src/api/modules/users/routes/change-password.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/change-password.route.js +14 -14
- package/dist/src/api/modules/users/routes/reset-passowrd.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/reset-passowrd.route.js +18 -18
- package/dist/src/api/modules/users/routes/session.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/session.route.js +7 -7
- package/dist/src/api/modules/users/routes/sign-in.route.d.ts +3 -3
- package/dist/src/api/modules/users/routes/sign-in.route.js +11 -11
- package/dist/src/api/modules/users/routes/sign-out.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/sign-out.route.js +8 -8
- package/dist/src/api/modules/users/routes/sign-up.route.d.ts +3 -3
- package/dist/src/api/modules/users/routes/sign-up.route.js +15 -15
- package/dist/src/api/modules/users/routes/test.route.d.ts +3 -3
- package/dist/src/api/modules/users/routes/test.route.js +10 -10
- package/dist/src/api/modules/users/sso/routes/callback.route.d.ts +2 -2
- package/dist/src/api/modules/users/sso/routes/callback.route.js +9 -9
- package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts +2 -2
- package/dist/src/api/modules/users/sso/routes/create-url.route.js +7 -7
- package/dist/src/api/modules/users/sso/sso.module.d.ts +2 -2
- package/dist/src/api/modules/users/sso/sso.module.js +2 -2
- package/dist/src/api/modules/users/users.module.d.ts +12 -12
- package/dist/src/api/modules/users/users.module.js +2 -2
- package/dist/src/api/plugin.d.ts.map +1 -1
- package/dist/src/api/plugin.js +4 -2
- package/dist/src/app/login/page.d.ts +1 -1
- package/dist/src/app/login/page.js +2 -2
- package/dist/src/app/login/reset-password/page.d.ts +2 -2
- package/dist/src/app/login/reset-password/page.js +2 -2
- package/dist/src/app/register/page.d.ts +1 -1
- package/dist/src/app/register/page.js +2 -2
- package/dist/src/app_admin/core/advanced/cron/page.d.ts +11 -0
- package/dist/src/app_admin/core/advanced/cron/page.d.ts.map +1 -0
- package/dist/src/app_admin/core/advanced/cron/page.js +42 -0
- package/dist/src/app_admin/core/debug/page.d.ts +1 -1
- package/dist/src/app_admin/core/debug/page.js +8 -8
- package/dist/src/app_admin/core/users/page.d.ts +2 -2
- package/dist/src/app_admin/core/users/page.d.ts.map +1 -1
- package/dist/src/app_admin/core/users/page.js +7 -7
- package/dist/src/components/avatar.d.ts +1 -1
- package/dist/src/components/avatar.js +1 -1
- package/dist/src/components/confirm-action/confirm-action-alert-dialog.d.ts +2 -2
- package/dist/src/components/confirm-action/confirm-action-alert-dialog.js +5 -5
- package/dist/src/components/confirm-action/content.d.ts.map +1 -1
- package/dist/src/components/confirm-action/content.js +3 -4
- package/dist/src/components/date-format.js +8 -8
- package/dist/src/components/form/auto-form.d.ts +16 -16
- package/dist/src/components/form/auto-form.d.ts.map +1 -1
- package/dist/src/components/form/auto-form.js +13 -12
- package/dist/src/components/form/common/desc.js +1 -1
- package/dist/src/components/form/common/label.d.ts +1 -1
- package/dist/src/components/form/common/label.js +1 -1
- package/dist/src/components/form/fields/checkbox.d.ts +2 -2
- package/dist/src/components/form/fields/checkbox.d.ts.map +1 -1
- package/dist/src/components/form/fields/combobox-async.d.ts +3 -3
- package/dist/src/components/form/fields/combobox-async.d.ts.map +1 -1
- package/dist/src/components/form/fields/combobox-async.js +29 -23
- package/dist/src/components/form/fields/combobox.d.ts +3 -3
- package/dist/src/components/form/fields/combobox.d.ts.map +1 -1
- package/dist/src/components/form/fields/combobox.js +6 -7
- package/dist/src/components/form/fields/input.d.ts +2 -2
- package/dist/src/components/form/fields/input.d.ts.map +1 -1
- package/dist/src/components/form/fields/input.js +2 -2
- package/dist/src/components/form/fields/radio-group.d.ts +3 -3
- package/dist/src/components/form/fields/radio-group.d.ts.map +1 -1
- package/dist/src/components/form/fields/radio-group.js +0 -1
- package/dist/src/components/form/fields/select.d.ts +3 -3
- package/dist/src/components/form/fields/select.d.ts.map +1 -1
- package/dist/src/components/form/fields/select.js +2 -3
- package/dist/src/components/form/fields/switch.d.ts +2 -2
- package/dist/src/components/form/fields/switch.d.ts.map +1 -1
- package/dist/src/components/form/fields/textarea.d.ts +3 -3
- package/dist/src/components/form/fields/textarea.d.ts.map +1 -1
- package/dist/src/components/form/fields/textarea.js +1 -2
- package/dist/src/components/i18n-provider.d.ts +2 -2
- package/dist/src/components/i18n-provider.js +3 -3
- package/dist/src/components/logo-vitnode.d.ts.map +1 -1
- package/dist/src/components/logo-vitnode.js +8 -2
- package/dist/src/components/switchers/langs/{language-swietcher.d.ts → language-switcher.d.ts} +2 -2
- package/dist/src/components/switchers/langs/language-switcher.d.ts.map +1 -0
- package/dist/src/components/switchers/langs/{language-swietcher.js → language-switcher.js} +3 -3
- package/dist/src/components/switchers/themes/theme-switcher.js +4 -4
- package/dist/src/components/table/content.d.ts +1 -1
- package/dist/src/components/table/content.d.ts.map +1 -1
- package/dist/src/components/table/content.js +5 -5
- package/dist/src/components/table/data-table.d.ts +7 -7
- package/dist/src/components/table/data-table.d.ts.map +1 -1
- package/dist/src/components/table/data-table.js +22 -15
- package/dist/src/components/table/order-table-head.d.ts +4 -4
- package/dist/src/components/table/order-table-head.d.ts.map +1 -1
- package/dist/src/components/table/order-table-head.js +20 -9
- package/dist/src/components/table/pagination.js +19 -19
- package/dist/src/components/tiptap/extension.d.ts +4 -0
- package/dist/src/components/tiptap/extension.d.ts.map +1 -0
- package/dist/src/components/tiptap/extension.js +26 -0
- package/dist/src/components/tiptap/toolbar/actions/bold-action.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/bold-action.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/bold-action.js +39 -0
- package/dist/src/components/tiptap/toolbar/actions/headings-action.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/headings-action.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/headings-action.js +94 -0
- package/dist/src/components/tiptap/toolbar/actions/italic-action.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/italic-action.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/italic-action.js +38 -0
- package/dist/src/components/tiptap/toolbar/actions/list-action.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/list-action.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/list-action.js +60 -0
- package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.js +59 -0
- package/dist/src/components/tiptap/toolbar/actions/underline-action.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/underline-action.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/underline-action.js +38 -0
- package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.d.ts +2 -0
- package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.js +63 -0
- package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.d.ts +4 -0
- package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.js +11 -0
- package/dist/src/components/tiptap/toolbar/tiptap-toolbar.d.ts +5 -0
- package/dist/src/components/tiptap/toolbar/tiptap-toolbar.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/tiptap-toolbar.js +35 -0
- package/dist/src/components/tiptap/toolbar/use-toolbar-editor.d.ts +9 -0
- package/dist/src/components/tiptap/toolbar/use-toolbar-editor.d.ts.map +1 -0
- package/dist/src/components/tiptap/toolbar/use-toolbar-editor.js +5 -0
- package/dist/src/components/ui/accordion.d.ts +2 -2
- package/dist/src/components/ui/accordion.d.ts.map +1 -1
- package/dist/src/components/ui/accordion.js +4 -5
- package/dist/src/components/ui/alert-dialog.d.ts +7 -7
- package/dist/src/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/src/components/ui/alert-dialog.js +12 -12
- package/dist/src/components/ui/alert.d.ts +5 -5
- package/dist/src/components/ui/alert.d.ts.map +1 -1
- package/dist/src/components/ui/alert.js +6 -7
- package/dist/src/components/ui/badge.d.ts +3 -3
- package/dist/src/components/ui/badge.d.ts.map +1 -1
- package/dist/src/components/ui/badge.js +7 -8
- package/dist/src/components/ui/button-client.d.ts +1 -1
- package/dist/src/components/ui/button-client.d.ts.map +1 -1
- package/dist/src/components/ui/button-client.js +10 -10
- package/dist/src/components/ui/button.d.ts +8 -8
- package/dist/src/components/ui/button.d.ts.map +1 -1
- package/dist/src/components/ui/button.js +14 -15
- package/dist/src/components/ui/card.d.ts +8 -8
- package/dist/src/components/ui/card.js +7 -7
- package/dist/src/components/ui/checkbox.d.ts +2 -2
- package/dist/src/components/ui/checkbox.d.ts.map +1 -1
- package/dist/src/components/ui/checkbox.js +2 -3
- package/dist/src/components/ui/collapsible.d.ts +1 -1
- package/dist/src/components/ui/collapsible.js +1 -1
- package/dist/src/components/ui/command.d.ts +4 -4
- package/dist/src/components/ui/command.d.ts.map +1 -1
- package/dist/src/components/ui/command.js +9 -10
- package/dist/src/components/ui/context-menu.d.ts +4 -4
- package/dist/src/components/ui/context-menu.d.ts.map +1 -1
- package/dist/src/components/ui/context-menu.js +7 -8
- package/dist/src/components/ui/dialog.d.ts +6 -6
- package/dist/src/components/ui/dialog.d.ts.map +1 -1
- package/dist/src/components/ui/dialog.js +16 -16
- package/dist/src/components/ui/drawer.d.ts +4 -4
- package/dist/src/components/ui/drawer.d.ts.map +1 -1
- package/dist/src/components/ui/drawer.js +7 -8
- package/dist/src/components/ui/dropdown-menu.d.ts +4 -4
- package/dist/src/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/src/components/ui/dropdown-menu.js +8 -9
- package/dist/src/components/ui/editor-content.d.ts +4 -0
- package/dist/src/components/ui/editor-content.d.ts.map +1 -0
- package/dist/src/components/ui/editor-content.js +10 -0
- package/dist/src/components/ui/editor.d.ts +6 -0
- package/dist/src/components/ui/editor.d.ts.map +1 -0
- package/dist/src/components/ui/editor.js +35 -0
- package/dist/src/components/ui/form.d.ts +10 -10
- package/dist/src/components/ui/form.d.ts.map +1 -1
- package/dist/src/components/ui/form.js +15 -15
- package/dist/src/components/ui/header-content.js +1 -1
- package/dist/src/components/ui/hover-card.d.ts +2 -2
- package/dist/src/components/ui/hover-card.d.ts.map +1 -1
- package/dist/src/components/ui/hover-card.js +3 -4
- package/dist/src/components/ui/input-otp.d.ts +5 -5
- package/dist/src/components/ui/input-otp.d.ts.map +1 -1
- package/dist/src/components/ui/input-otp.js +6 -7
- package/dist/src/components/ui/input.d.ts +2 -2
- package/dist/src/components/ui/input.d.ts.map +1 -1
- package/dist/src/components/ui/input.js +1 -2
- package/dist/src/components/ui/label.d.ts +2 -2
- package/dist/src/components/ui/label.d.ts.map +1 -1
- package/dist/src/components/ui/label.js +2 -3
- package/dist/src/components/ui/loader.js +3 -3
- package/dist/src/components/ui/menubar.d.ts +4 -4
- package/dist/src/components/ui/menubar.d.ts.map +1 -1
- package/dist/src/components/ui/menubar.js +11 -12
- package/dist/src/components/ui/navigation-menu.d.ts +2 -2
- package/dist/src/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/src/components/ui/navigation-menu.js +10 -11
- package/dist/src/components/ui/popover.d.ts +2 -2
- package/dist/src/components/ui/popover.d.ts.map +1 -1
- package/dist/src/components/ui/popover.js +3 -4
- package/dist/src/components/ui/progress.d.ts +2 -2
- package/dist/src/components/ui/progress.d.ts.map +1 -1
- package/dist/src/components/ui/progress.js +2 -3
- package/dist/src/components/ui/radio-group.d.ts +2 -2
- package/dist/src/components/ui/radio-group.d.ts.map +1 -1
- package/dist/src/components/ui/radio-group.js +3 -4
- package/dist/src/components/ui/select.d.ts +3 -3
- package/dist/src/components/ui/select.d.ts.map +1 -1
- package/dist/src/components/ui/select.js +9 -10
- package/dist/src/components/ui/separator.d.ts +2 -2
- package/dist/src/components/ui/separator.d.ts.map +1 -1
- package/dist/src/components/ui/separator.js +3 -4
- package/dist/src/components/ui/sheet.d.ts +5 -5
- package/dist/src/components/ui/sheet.d.ts.map +1 -1
- package/dist/src/components/ui/sheet.js +8 -9
- package/dist/src/components/ui/sidebar.d.ts +31 -31
- package/dist/src/components/ui/sidebar.d.ts.map +1 -1
- package/dist/src/components/ui/sidebar.js +78 -80
- package/dist/src/components/ui/skeleton.d.ts +1 -1
- package/dist/src/components/ui/skeleton.js +1 -1
- package/dist/src/components/ui/slider.d.ts +2 -2
- package/dist/src/components/ui/slider.d.ts.map +1 -1
- package/dist/src/components/ui/slider.js +16 -8
- package/dist/src/components/ui/sonner.d.ts +1 -1
- package/dist/src/components/ui/sonner.d.ts.map +1 -1
- package/dist/src/components/ui/sonner.js +6 -6
- package/dist/src/components/ui/switch.d.ts +2 -2
- package/dist/src/components/ui/switch.d.ts.map +1 -1
- package/dist/src/components/ui/switch.js +3 -4
- package/dist/src/components/ui/table.d.ts +9 -9
- package/dist/src/components/ui/table.d.ts.map +1 -1
- package/dist/src/components/ui/table.js +8 -9
- package/dist/src/components/ui/tabs.d.ts +2 -2
- package/dist/src/components/ui/tabs.d.ts.map +1 -1
- package/dist/src/components/ui/tabs.js +4 -5
- package/dist/src/components/ui/textarea.d.ts +2 -2
- package/dist/src/components/ui/textarea.d.ts.map +1 -1
- package/dist/src/components/ui/textarea.js +1 -2
- package/dist/src/components/ui/toggle-group.d.ts +4 -4
- package/dist/src/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/src/components/ui/toggle-group.js +6 -6
- package/dist/src/components/ui/toggle.d.ts +3 -3
- package/dist/src/components/ui/toggle.d.ts.map +1 -1
- package/dist/src/components/ui/toggle.js +8 -9
- package/dist/src/components/ui/tooltip.d.ts +6 -3
- package/dist/src/components/ui/tooltip.d.ts.map +1 -1
- package/dist/src/components/ui/tooltip.js +20 -5
- package/dist/src/config.js +2 -2
- package/dist/src/database/admins.js +10 -10
- package/dist/src/database/cron.d.ts +171 -0
- package/dist/src/database/cron.d.ts.map +1 -0
- package/dist/src/database/cron.js +22 -0
- package/dist/src/database/languages.js +7 -7
- package/dist/src/database/logs.js +9 -9
- package/dist/src/database/moderators.js +5 -5
- package/dist/src/database/roles.js +1 -1
- package/dist/src/database/sessions.js +6 -6
- package/dist/src/database/users.d.ts +2 -2
- package/dist/src/database/users.js +14 -14
- package/dist/src/drizzle.config.d.ts +2 -2
- package/dist/src/drizzle.config.d.ts.map +1 -1
- package/dist/src/drizzle.config.js +19 -12
- package/dist/src/emails/default-template.d.ts +3 -3
- package/dist/src/emails/default-template.d.ts.map +1 -1
- package/dist/src/emails/default-template.js +39 -38
- package/dist/src/emails/reset-password.d.ts +1 -1
- package/dist/src/emails/reset-password.d.ts.map +1 -1
- package/dist/src/emails/reset-password.js +51 -51
- package/dist/src/emails/ui/button.d.ts +2 -2
- package/dist/src/emails/ui/button.js +13 -13
- package/dist/src/emails/ui/card.d.ts +1 -1
- package/dist/src/emails/ui/card.js +6 -6
- package/dist/src/hooks/use-before-unload.js +3 -3
- package/dist/src/hooks/use-captcha.d.ts +2 -2
- package/dist/src/hooks/use-captcha.d.ts.map +1 -1
- package/dist/src/hooks/use-captcha.js +29 -37
- package/dist/src/hooks/use-mobile.d.ts.map +1 -1
- package/dist/src/hooks/use-mobile.js +3 -4
- package/dist/src/lib/api/get-middleware-api.js +4 -4
- package/dist/src/lib/api/get-next-cron-run-date.d.ts +2 -0
- package/dist/src/lib/api/get-next-cron-run-date.d.ts.map +1 -0
- package/dist/src/lib/api/get-next-cron-run-date.js +14 -0
- package/dist/src/lib/api/get-next-cron-run-date.test.d.ts +2 -0
- package/dist/src/lib/api/get-next-cron-run-date.test.d.ts.map +1 -0
- package/dist/src/lib/api/get-next-cron-run-date.test.js +55 -0
- package/dist/src/lib/api/get-session-admin-api.js +5 -5
- package/dist/src/lib/api/get-session-api.js +4 -4
- package/dist/src/lib/api/should-cron-job-run.d.ts +2 -0
- package/dist/src/lib/api/should-cron-job-run.d.ts.map +1 -0
- package/dist/src/lib/api/should-cron-job-run.js +16 -0
- package/dist/src/lib/api/should-cron-job-run.test.d.ts +2 -0
- package/dist/src/lib/api/should-cron-job-run.test.d.ts.map +1 -0
- package/dist/src/lib/api/should-cron-job-run.test.js +213 -0
- package/dist/src/lib/colors.js +28 -19
- package/dist/src/lib/colors.test.js +60 -60
- package/dist/src/lib/config.d.ts +1 -0
- package/dist/src/lib/config.d.ts.map +1 -1
- package/dist/src/lib/config.js +8 -6
- package/dist/src/lib/ctrl-or-command-character.d.ts +2 -0
- package/dist/src/lib/ctrl-or-command-character.d.ts.map +1 -0
- package/dist/src/lib/ctrl-or-command-character.js +9 -0
- package/dist/src/lib/fetcher/cookie-from-string-to-object.d.ts.map +1 -1
- package/dist/src/lib/fetcher/cookie-from-string-to-object.js +1 -1
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +27 -27
- package/dist/src/lib/fetcher/core.d.ts +5 -5
- package/dist/src/lib/fetcher/core.d.ts.map +1 -1
- package/dist/src/lib/fetcher/core.js +11 -10
- package/dist/src/lib/fetcher/helpers-server.d.ts +1 -1
- package/dist/src/lib/fetcher/helpers-server.js +1 -1
- package/dist/src/lib/fetcher/helpers.test.js +17 -17
- package/dist/src/lib/fetcher/types.d.ts +26 -26
- package/dist/src/lib/fetcher/types.d.ts.map +1 -1
- package/dist/src/lib/fetcher-client.d.ts +4 -4
- package/dist/src/lib/fetcher-client.d.ts.map +1 -1
- package/dist/src/lib/fetcher-client.js +3 -3
- package/dist/src/lib/fetcher.d.ts +5 -5
- package/dist/src/lib/fetcher.d.ts.map +1 -1
- package/dist/src/lib/fetcher.js +4 -4
- package/dist/src/lib/helpers/auto-form.d.ts +3 -3
- package/dist/src/lib/helpers/auto-form.d.ts.map +1 -1
- package/dist/src/lib/helpers/auto-form.js +16 -15
- package/dist/src/lib/helpers/auto-form.test.js +129 -129
- package/dist/src/lib/navigation.d.ts +3 -3
- package/dist/src/lib/navigation.d.ts.map +1 -1
- package/dist/src/lib/plugin.d.ts +3 -3
- package/dist/src/lib/special-characters.js +1 -1
- package/dist/src/lib/special-characters.test.js +36 -36
- package/dist/src/lib/utils.d.ts +1 -1
- package/dist/src/tests/setup.d.ts +1 -1
- package/dist/src/views/admin/layouts/admin-layout.d.ts +1 -1
- package/dist/src/views/admin/layouts/admin-layout.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/admin-layout.js +5 -9
- package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/item.js +8 -12
- package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/nav.js +23 -12
- package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts +1 -1
- package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/sidebar/sidebar.js +1 -2
- package/dist/src/views/admin/layouts/sidebar/sign-out.js +1 -1
- package/dist/src/views/admin/layouts/user-bar/client.js +5 -5
- package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts +1 -1
- package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/user-bar/user-bar.js +1 -1
- package/dist/src/views/admin/sign-in/sign-in-admin-view.js +1 -1
- package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.d.ts +5 -0
- package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.d.ts.map +1 -0
- package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.js +97 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.d.ts +4 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.d.ts.map +1 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.js +23 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.d.ts +4 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.d.ts.map +1 -0
- package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.js +37 -0
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +3 -3
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/clear-cache.js +10 -10
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/mutation-api.js +2 -2
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.d.ts +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.js +15 -15
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.d.ts +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +16 -25
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.js +7 -1
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.d.ts +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.js +3 -3
- package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.js +25 -25
- package/dist/src/views/admin/views/core/test.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/test.js +134 -124
- package/dist/src/views/admin/views/core/users/users-admin-view.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/users/users-admin-view.js +13 -14
- package/dist/src/views/auth/password-reset/change-password-form/form.js +9 -9
- package/dist/src/views/auth/password-reset/change-password-form/mutation-api.d.ts +2 -2
- package/dist/src/views/auth/password-reset/change-password-form/mutation-api.js +5 -5
- package/dist/src/views/auth/password-reset/change-password-form/use-form.d.ts +2 -2
- package/dist/src/views/auth/password-reset/change-password-form/use-form.d.ts.map +1 -1
- package/dist/src/views/auth/password-reset/change-password-form/use-form.js +7 -7
- package/dist/src/views/auth/password-reset/form/form.d.ts +2 -2
- package/dist/src/views/auth/password-reset/form/form.d.ts.map +1 -1
- package/dist/src/views/auth/password-reset/form/form.js +15 -15
- package/dist/src/views/auth/password-reset/form/mutation-api.js +5 -5
- package/dist/src/views/auth/password-reset/form/use-form.d.ts +2 -2
- package/dist/src/views/auth/password-reset/form/use-form.js +7 -7
- package/dist/src/views/auth/password-reset/password-reset-view.js +4 -4
- package/dist/src/views/auth/sign-in/form/form.js +9 -9
- package/dist/src/views/auth/sign-in/form/mutation-api.d.ts +2 -2
- package/dist/src/views/auth/sign-in/form/mutation-api.d.ts.map +1 -1
- package/dist/src/views/auth/sign-in/form/mutation-api.js +10 -10
- package/dist/src/views/auth/sign-in/form/use-form.d.ts +2 -2
- package/dist/src/views/auth/sign-in/form/use-form.js +11 -11
- package/dist/src/views/auth/sign-in/sign-in-view.js +5 -5
- package/dist/src/views/auth/sign-up/components/password-input.d.ts +3 -3
- package/dist/src/views/auth/sign-up/components/password-input.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/components/password-input.js +9 -10
- package/dist/src/views/auth/sign-up/email-confirmation-view.js +4 -4
- package/dist/src/views/auth/sign-up/form/form.d.ts +2 -2
- package/dist/src/views/auth/sign-up/form/form.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/form/form.js +18 -18
- package/dist/src/views/auth/sign-up/form/mutation-api.d.ts +2 -2
- package/dist/src/views/auth/sign-up/form/mutation-api.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/form/mutation-api.js +6 -6
- package/dist/src/views/auth/sign-up/form/use-form.d.ts +2 -2
- package/dist/src/views/auth/sign-up/form/use-form.js +21 -21
- package/dist/src/views/auth/sign-up/sign-up-view.js +5 -5
- package/dist/src/views/auth/sign-up/wrapper.d.ts +1 -1
- package/dist/src/views/auth/sign-up/wrapper.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/wrapper.js +5 -8
- package/dist/src/views/auth/sso/buttons/client.js +4 -4
- package/dist/src/views/auth/sso/buttons/mutation-api.js +5 -5
- package/dist/src/views/auth/sso/buttons/sso-buttons.js +2 -2
- package/dist/src/views/auth/sso/callback/callback-sso-view.js +6 -6
- package/dist/src/views/auth/sso/callback/client/client.d.ts +1 -1
- package/dist/src/views/auth/sso/callback/client/client.d.ts.map +1 -1
- package/dist/src/views/auth/sso/callback/client/client.js +9 -9
- package/dist/src/views/auth/sso/callback/client/mutation-api.js +7 -7
- package/dist/src/views/error/back-button.js +1 -1
- package/dist/src/views/error/error-view.js +4 -4
- package/dist/src/views/error/global-error-view.d.ts +3 -3
- package/dist/src/views/error/global-error-view.d.ts.map +1 -1
- package/dist/src/views/error/global-error-view.js +36 -44
- package/dist/src/views/layouts/provider.d.ts +4 -4
- package/dist/src/views/layouts/provider.d.ts.map +1 -1
- package/dist/src/views/layouts/provider.js +3 -3
- package/dist/src/views/layouts/root-layout.d.ts +3 -3
- package/dist/src/views/layouts/root-layout.d.ts.map +1 -1
- package/dist/src/views/layouts/root-layout.js +1 -2
- package/dist/src/views/layouts/theme/header/header.d.ts +2 -2
- package/dist/src/views/layouts/theme/header/header.d.ts.map +1 -1
- package/dist/src/views/layouts/theme/header/header.js +2 -2
- package/dist/src/views/layouts/theme/header/user/auth/client.d.ts +1 -1
- package/dist/src/views/layouts/theme/header/user/auth/client.d.ts.map +1 -1
- package/dist/src/views/layouts/theme/header/user/auth/client.js +4 -4
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +8 -8
- package/dist/src/views/layouts/theme/header/user/user.js +4 -4
- package/dist/src/views/layouts/theme/layout.d.ts +2 -2
- package/dist/src/views/layouts/theme/layout.js +1 -1
- package/dist/src/vitnode.config.d.ts +18 -16
- package/dist/src/vitnode.config.d.ts.map +1 -1
- package/dist/src/vitnode.config.js +3 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -29
- package/src/app/login/page.tsx +5 -5
- package/src/app/login/reset-password/page.tsx +5 -5
- package/src/app/login/sso/[providerId]/page.tsx +1 -1
- package/src/app/register/page.tsx +5 -5
- package/src/app_admin/core/advanced/cron/page.tsx +41 -0
- package/src/app_admin/core/debug/page.tsx +14 -14
- package/src/app_admin/core/page.tsx +1 -1
- package/src/app_admin/core/test/page.tsx +1 -1
- package/src/app_admin/core/users/page.tsx +12 -13
- package/src/locales/en.json +43 -0
- package/src/tiptap.css +20 -0
- package/dist/src/components/switchers/langs/language-swietcher.d.ts.map +0 -1
|
@@ -4,29 +4,29 @@ import { withPagination, zodPaginationPageInfo, zodPaginationQuery } from "../..
|
|
|
4
4
|
import { CONFIG_PLUGIN } from "../../../../../config.js";
|
|
5
5
|
import { core_users } from "../../../../../database/users.js";
|
|
6
6
|
export const usersAdminRoute = buildRoute({
|
|
7
|
-
|
|
7
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
8
8
|
route: {
|
|
9
|
-
method:
|
|
10
|
-
description:
|
|
11
|
-
path:
|
|
9
|
+
method: "get",
|
|
10
|
+
description: "Get list of all users (Admin only)",
|
|
11
|
+
path: "/list",
|
|
12
12
|
request: {
|
|
13
13
|
query: zodPaginationQuery.extend({
|
|
14
14
|
order: z.enum([
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
"asc",
|
|
16
|
+
"desc"
|
|
17
17
|
]).optional(),
|
|
18
18
|
orderBy: z.enum([
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
"id",
|
|
20
|
+
"name",
|
|
21
|
+
"email",
|
|
22
|
+
"createdAt"
|
|
23
23
|
]).optional()
|
|
24
24
|
})
|
|
25
25
|
},
|
|
26
26
|
responses: {
|
|
27
27
|
200: {
|
|
28
28
|
content: {
|
|
29
|
-
|
|
29
|
+
"application/json": {
|
|
30
30
|
schema: z.object({
|
|
31
31
|
edges: z.array(z.object({
|
|
32
32
|
id: z.number(),
|
|
@@ -45,21 +45,21 @@ export const usersAdminRoute = buildRoute({
|
|
|
45
45
|
})
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
description:
|
|
48
|
+
description: "List of users"
|
|
49
49
|
},
|
|
50
50
|
403: {
|
|
51
|
-
description:
|
|
51
|
+
description: "Access Denied"
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
handler: async (c)=>{
|
|
56
|
-
const query = c.req.valid(
|
|
56
|
+
const query = c.req.valid("query");
|
|
57
57
|
const data = await withPagination({
|
|
58
58
|
params: {
|
|
59
59
|
query
|
|
60
60
|
},
|
|
61
61
|
primaryCursor: core_users.id,
|
|
62
|
-
query: async ({ limit, where, orderBy })=>await c.get(
|
|
62
|
+
query: async ({ limit, where, orderBy })=>await c.get("db").select({
|
|
63
63
|
id: core_users.id,
|
|
64
64
|
name: core_users.name,
|
|
65
65
|
email: core_users.email,
|
|
@@ -75,7 +75,7 @@ export const usersAdminRoute = buildRoute({
|
|
|
75
75
|
table: core_users,
|
|
76
76
|
orderBy: {
|
|
77
77
|
column: query.orderBy ? core_users[query.orderBy] : core_users.createdAt,
|
|
78
|
-
order: query.order ??
|
|
78
|
+
order: query.order ?? "desc"
|
|
79
79
|
},
|
|
80
80
|
c
|
|
81
81
|
});
|
|
@@ -64,7 +64,7 @@ export declare const usersAdminModule: import("../../../../api/lib/module").Buil
|
|
|
64
64
|
responses: {
|
|
65
65
|
200: {
|
|
66
66
|
content: {
|
|
67
|
-
|
|
67
|
+
"application/json": {
|
|
68
68
|
schema: import("zod").ZodObject<{
|
|
69
69
|
edges: import("zod").ZodArray<import("zod").ZodObject<{
|
|
70
70
|
id: import("zod").ZodNumber;
|
|
@@ -2,8 +2,8 @@ import { buildModule } from "../../../lib/module.js";
|
|
|
2
2
|
import { CONFIG_PLUGIN } from "../../../../config.js";
|
|
3
3
|
import { listUsersAdminRoute } from "./routes/list.route.js";
|
|
4
4
|
export const usersAdminModule = buildModule({
|
|
5
|
-
|
|
6
|
-
name:
|
|
5
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
6
|
+
name: "users",
|
|
7
7
|
routes: [
|
|
8
8
|
listUsersAdminRoute
|
|
9
9
|
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean.cron.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/cron/cron/clean.cron.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,0CA0BpB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { lt } from "drizzle-orm";
|
|
2
|
+
import { buildCron } from "../../../lib/cron.js";
|
|
3
|
+
import { core_admin_sessions } from "../../../../database/admins.js";
|
|
4
|
+
import { core_sessions } from "../../../../database/sessions.js";
|
|
5
|
+
import { core_users_forgot_password } from "../../../../database/users.js";
|
|
6
|
+
export const cleanCron = buildCron({
|
|
7
|
+
name: "clean",
|
|
8
|
+
description: "Clean up expired sessions and tokens",
|
|
9
|
+
// Run every 1 hour
|
|
10
|
+
schedule: "0 * * * *",
|
|
11
|
+
handler: async (c)=>{
|
|
12
|
+
await c.get("db").transaction(async (tx)=>{
|
|
13
|
+
// Delete expired sessions
|
|
14
|
+
await tx.delete(core_sessions).where(lt(core_sessions.expiresAt, new Date()));
|
|
15
|
+
await tx.delete(core_admin_sessions).where(lt(core_admin_sessions.expiresAt, new Date()));
|
|
16
|
+
// Delete expired forgot password tokens
|
|
17
|
+
await tx.delete(core_users_forgot_password).where(lt(core_users_forgot_password.expiresAt, new Date()));
|
|
18
|
+
// // Delete expired email confirmation tokens
|
|
19
|
+
// await tx
|
|
20
|
+
// .delete(core_users_confirm_emails)
|
|
21
|
+
// .where(lt(core_users_confirm_emails.expiresAt, new Date()));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const cronModule: import("../../../api/lib/module").BuildModuleReturn<"@vitnode/core", "cron", [{
|
|
2
|
+
handler: (c: import("hono").Context<import("../../middlewares/global.middleware").EnvVitNode, "/", {}>) => Promise<(Response & import("hono").TypedResponse<`Cron jobs processed. Executed ${number} jobs.`, 200, "text">) | (Response & import("hono").TypedResponse<"Error processing cron jobs", 500, "text">)>;
|
|
3
|
+
pluginId: "@vitnode/core";
|
|
4
|
+
route: {
|
|
5
|
+
method: "post";
|
|
6
|
+
description: string;
|
|
7
|
+
path: "/";
|
|
8
|
+
middleware: ((c: import("hono").Context, next: import("hono").Next) => Promise<void>)[];
|
|
9
|
+
responses: {
|
|
10
|
+
200: {
|
|
11
|
+
content: {
|
|
12
|
+
"text/plain": {
|
|
13
|
+
schema: import("zod").ZodString;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
403: {
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
} & {
|
|
23
|
+
getRoutingPath: () => "/";
|
|
24
|
+
};
|
|
25
|
+
}], import("../../../api/lib/module").BaseBuildModuleReturn<"@vitnode/core", string, import("../../lib/route").Route<"@vitnode/core", import("@hono/zod-openapi").RouteConfig, import("@hono/zod-openapi").RouteHandler<import("@hono/zod-openapi").RouteConfig>>[]>[]>;
|
|
26
|
+
//# sourceMappingURL=cron.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron.module.d.ts","sourceRoot":"","sources":["../../../../../src/api/modules/cron/cron.module.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;gQAKrB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { buildModule } from "../../lib/module.js";
|
|
2
|
+
import { CONFIG_PLUGIN } from "../../../config.js";
|
|
3
|
+
import { cleanCron } from "./cron/clean.cron.js";
|
|
4
|
+
import { runCronRoute } from "./routes/cron.route.js";
|
|
5
|
+
export const cronModule = buildModule({
|
|
6
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
7
|
+
name: "cron",
|
|
8
|
+
routes: [
|
|
9
|
+
runCronRoute
|
|
10
|
+
],
|
|
11
|
+
cronJobs: [
|
|
12
|
+
cleanCron
|
|
13
|
+
]
|
|
14
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { CronJobConfig } from "../../../../api/lib/cron";
|
|
3
|
+
interface CronJobFromDb {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string | null;
|
|
7
|
+
lastRun: Date | null;
|
|
8
|
+
nextRun: Date | null;
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
pluginId: string;
|
|
11
|
+
module: string;
|
|
12
|
+
schedule: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function cleanupOutdatedCronJobs(db: PostgresJsDatabase<Record<string, never>>, cronFromDb: CronJobFromDb[], currentCronJobs: CronJobConfig[]): Promise<void>;
|
|
15
|
+
export declare function processCronJobs(cronJobs: CronJobConfig[], cronFromDb: CronJobFromDb[]): {
|
|
16
|
+
newJobs: CronJobConfig[];
|
|
17
|
+
jobsToExecute: CronJobConfig[];
|
|
18
|
+
jobsToUpdate: {
|
|
19
|
+
job: CronJobConfig;
|
|
20
|
+
existingJob: CronJobFromDb;
|
|
21
|
+
changes: {
|
|
22
|
+
description?: boolean;
|
|
23
|
+
schedule?: boolean;
|
|
24
|
+
};
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
export declare function updateCronJobs(db: PostgresJsDatabase<Record<string, never>>, jobsToUpdate: {
|
|
28
|
+
job: CronJobConfig;
|
|
29
|
+
existingJob: CronJobFromDb;
|
|
30
|
+
changes: {
|
|
31
|
+
description?: boolean;
|
|
32
|
+
schedule?: boolean;
|
|
33
|
+
};
|
|
34
|
+
}[]): Promise<void>;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=process-cron-jobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-cron-jobs.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/cron/helpers/process-cron-jobs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AA4BD,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAC7C,UAAU,EAAE,aAAa,EAAE,EAC3B,eAAe,EAAE,aAAa,EAAE,iBAoBjC;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,aAAa,EAAE,EACzB,UAAU,EAAE,aAAa,EAAE;;;;aAKpB,aAAa;qBACL,aAAa;iBACjB;YAAE,WAAW,CAAC,EAAE,OAAO,CAAC;YAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;;EA6BzD;AAED,wBAAsB,cAAc,CAClC,EAAE,EAAE,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAC7C,YAAY,EAAE;IACZ,GAAG,EAAE,aAAa,CAAC;IACnB,WAAW,EAAE,aAAa,CAAC;IAC3B,OAAO,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACxD,EAAE,iBAyBJ"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { eq, inArray } from "drizzle-orm";
|
|
2
|
+
import { validate } from "node-cron";
|
|
3
|
+
import { core_cron } from "../../../../database/cron.js";
|
|
4
|
+
import { shouldCronJobRun } from "../../../../lib/api/should-cron-job-run.js";
|
|
5
|
+
function findExistingJob(job, cronFromDb) {
|
|
6
|
+
return cronFromDb.find((dbJob)=>dbJob.name === job.name && dbJob.pluginId === job.pluginId && dbJob.module === job.module);
|
|
7
|
+
}
|
|
8
|
+
function getJobChanges(job, existingJob) {
|
|
9
|
+
const changes = {};
|
|
10
|
+
if (existingJob.description !== job.description) {
|
|
11
|
+
changes.description = true;
|
|
12
|
+
}
|
|
13
|
+
if (existingJob.schedule !== job.schedule) {
|
|
14
|
+
changes.schedule = true;
|
|
15
|
+
}
|
|
16
|
+
return changes;
|
|
17
|
+
}
|
|
18
|
+
export async function cleanupOutdatedCronJobs(db, cronFromDb, currentCronJobs) {
|
|
19
|
+
if (cronFromDb.length === 0) return;
|
|
20
|
+
const currentCronIdentifiers = currentCronJobs.map((job)=>`${job.pluginId}:${job.module}:${job.name}`);
|
|
21
|
+
const cronJobsToDelete = cronFromDb.filter((dbCron)=>!currentCronIdentifiers.includes(`${dbCron.pluginId}:${dbCron.module}:${dbCron.name}`)).map((dbCron)=>dbCron.id);
|
|
22
|
+
if (cronJobsToDelete.length > 0) {
|
|
23
|
+
await db.delete(core_cron).where(inArray(core_cron.id, cronJobsToDelete));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function processCronJobs(cronJobs, cronFromDb) {
|
|
27
|
+
const newJobs = [];
|
|
28
|
+
const jobsToExecute = [];
|
|
29
|
+
const jobsToUpdate = [];
|
|
30
|
+
for (const job of cronJobs){
|
|
31
|
+
if (!validate(job.schedule)) {
|
|
32
|
+
// biome-ignore lint/suspicious/noConsole: needed for cron job monitoring
|
|
33
|
+
console.warn(`\x1b[34m[VitNode]\x1b[0m \x1b[33mInvalid cron schedule for job "${job.pluginId}:${job.module}:${job.name}"\x1b[0m: ${job.schedule}`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const existingJob = findExistingJob(job, cronFromDb);
|
|
37
|
+
if (existingJob) {
|
|
38
|
+
const changes = getJobChanges(job, existingJob);
|
|
39
|
+
if (Object.keys(changes).length > 0) {
|
|
40
|
+
jobsToUpdate.push({
|
|
41
|
+
job,
|
|
42
|
+
existingJob,
|
|
43
|
+
changes
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
newJobs.push(job);
|
|
48
|
+
}
|
|
49
|
+
if (shouldCronJobRun(job.schedule, existingJob?.lastRun || null)) {
|
|
50
|
+
jobsToExecute.push(job);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
newJobs,
|
|
55
|
+
jobsToExecute,
|
|
56
|
+
jobsToUpdate
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export async function updateCronJobs(db, jobsToUpdate) {
|
|
60
|
+
if (jobsToUpdate.length === 0) return;
|
|
61
|
+
const updatePromises = jobsToUpdate.map(({ job, existingJob, changes })=>{
|
|
62
|
+
const updateData = {};
|
|
63
|
+
if (changes.description) {
|
|
64
|
+
updateData.description = job.description || null;
|
|
65
|
+
}
|
|
66
|
+
if (changes.schedule) {
|
|
67
|
+
updateData.schedule = job.schedule;
|
|
68
|
+
}
|
|
69
|
+
return db.update(core_cron).set(updateData).where(eq(core_cron.id, existingJob.id));
|
|
70
|
+
});
|
|
71
|
+
await Promise.all(updatePromises);
|
|
72
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const runCronRoute: {
|
|
3
|
+
handler: (c: import("hono").Context<import("../../../middlewares/global.middleware").EnvVitNode, "/", {}>) => Promise<(Response & import("hono").TypedResponse<`Cron jobs processed. Executed ${number} jobs.`, 200, "text">) | (Response & import("hono").TypedResponse<"Error processing cron jobs", 500, "text">)>;
|
|
4
|
+
pluginId: "@vitnode/core";
|
|
5
|
+
route: {
|
|
6
|
+
method: "post";
|
|
7
|
+
description: string;
|
|
8
|
+
path: "/";
|
|
9
|
+
middleware: ((c: import("hono").Context, next: import("hono").Next) => Promise<void>)[];
|
|
10
|
+
responses: {
|
|
11
|
+
200: {
|
|
12
|
+
content: {
|
|
13
|
+
"text/plain": {
|
|
14
|
+
schema: z.ZodString;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
403: {
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
} & {
|
|
24
|
+
getRoutingPath: () => "/";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=cron.route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/cron/routes/cron.route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;CA4GvB,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { buildRoute } from "../../../lib/route.js";
|
|
4
|
+
import { cronAuthMiddleware } from "../../../middlewares/cron-auth.middleware.js";
|
|
5
|
+
import { CONFIG_PLUGIN } from "../../../../config.js";
|
|
6
|
+
import { core_cron } from "../../../../database/cron.js";
|
|
7
|
+
import { getNextCronRunDate } from "../../../../lib/api/get-next-cron-run-date.js";
|
|
8
|
+
import { cleanupOutdatedCronJobs, processCronJobs, updateCronJobs } from "../helpers/process-cron-jobs.js";
|
|
9
|
+
export const runCronRoute = buildRoute({
|
|
10
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
11
|
+
route: {
|
|
12
|
+
method: "post",
|
|
13
|
+
description: "Run cron job",
|
|
14
|
+
path: "/",
|
|
15
|
+
middleware: [
|
|
16
|
+
cronAuthMiddleware()
|
|
17
|
+
],
|
|
18
|
+
responses: {
|
|
19
|
+
200: {
|
|
20
|
+
content: {
|
|
21
|
+
"text/plain": {
|
|
22
|
+
schema: z.string()
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
description: "Cron started successfully"
|
|
26
|
+
},
|
|
27
|
+
403: {
|
|
28
|
+
description: "Access Denied"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
handler: async (c)=>{
|
|
33
|
+
const db = c.get("db");
|
|
34
|
+
const cronJobs = c.get("core").cron;
|
|
35
|
+
try {
|
|
36
|
+
const cronFromDb = await db.select().from(core_cron);
|
|
37
|
+
await cleanupOutdatedCronJobs(db, cronFromDb, cronJobs);
|
|
38
|
+
const now = new Date();
|
|
39
|
+
let executedJobs = 0;
|
|
40
|
+
const { newJobs, jobsToExecute, jobsToUpdate } = processCronJobs(cronJobs, cronFromDb);
|
|
41
|
+
if (newJobs.length > 0) {
|
|
42
|
+
try {
|
|
43
|
+
const newJobsValues = newJobs.map((job)=>({
|
|
44
|
+
name: job.name,
|
|
45
|
+
description: job.description || null,
|
|
46
|
+
lastRun: null,
|
|
47
|
+
nextRun: null,
|
|
48
|
+
pluginId: job.pluginId,
|
|
49
|
+
module: job.module,
|
|
50
|
+
schedule: job.schedule
|
|
51
|
+
}));
|
|
52
|
+
await db.insert(core_cron).values(newJobsValues);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
await c.get("log").error(`Error inserting new cron jobs: ${error}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
await updateCronJobs(db, jobsToUpdate);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
await c.get("log").error(`Error updating cron jobs: ${error}`);
|
|
61
|
+
}
|
|
62
|
+
if (jobsToExecute.length > 0) {
|
|
63
|
+
const executionPromises = jobsToExecute.map(async (job)=>{
|
|
64
|
+
try {
|
|
65
|
+
await job.handler(c);
|
|
66
|
+
const dbJob = cronFromDb.find((dbJob)=>dbJob.name === job.name && dbJob.pluginId === job.pluginId && dbJob.module === job.module);
|
|
67
|
+
if (dbJob) {
|
|
68
|
+
await db.update(core_cron).set({
|
|
69
|
+
lastRun: now,
|
|
70
|
+
nextRun: getNextCronRunDate(job.schedule, now)
|
|
71
|
+
}).where(eq(core_cron.id, dbJob.id));
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
success: true,
|
|
75
|
+
jobName: job.name
|
|
76
|
+
};
|
|
77
|
+
} catch (error) {
|
|
78
|
+
await c.get("log").error(`Error executing cron job "${job.pluginId}:${job.module}:${job.name}": ${error}`);
|
|
79
|
+
return {
|
|
80
|
+
success: false,
|
|
81
|
+
jobName: job.name,
|
|
82
|
+
error
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const results = await Promise.allSettled(executionPromises);
|
|
87
|
+
executedJobs = results.filter((result)=>result.status === "fulfilled" && result.value.success).length;
|
|
88
|
+
}
|
|
89
|
+
return c.text(`Cron jobs processed. Executed ${executedJobs} jobs.`, 200);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
await c.get("log").error(`Error processing cron jobs: ${error}`);
|
|
92
|
+
return c.text("Error processing cron jobs", 500);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
@@ -18,7 +18,7 @@ export declare const middlewareModule: import("../../../api/lib/module").BuildMo
|
|
|
18
18
|
responses: {
|
|
19
19
|
200: {
|
|
20
20
|
content: {
|
|
21
|
-
|
|
21
|
+
"application/json": {
|
|
22
22
|
schema: import("zod").ZodObject<{
|
|
23
23
|
sso: import("zod").ZodArray<import("zod").ZodObject<{
|
|
24
24
|
id: import("zod").ZodString;
|
|
@@ -2,8 +2,8 @@ import { buildModule } from "../../lib/module.js";
|
|
|
2
2
|
import { CONFIG_PLUGIN } from "../../../config.js";
|
|
3
3
|
import { routeMiddleware } from "./route.js";
|
|
4
4
|
export const middlewareModule = buildModule({
|
|
5
|
-
|
|
6
|
-
name:
|
|
5
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
6
|
+
name: "middleware",
|
|
7
7
|
routes: [
|
|
8
8
|
routeMiddleware
|
|
9
9
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
export declare const routeMiddlewareSchema: z.ZodObject<{
|
|
3
3
|
sso: z.ZodArray<z.ZodObject<{
|
|
4
4
|
id: z.ZodString;
|
|
@@ -33,7 +33,7 @@ export declare const routeMiddleware: {
|
|
|
33
33
|
responses: {
|
|
34
34
|
200: {
|
|
35
35
|
content: {
|
|
36
|
-
|
|
36
|
+
"application/json": {
|
|
37
37
|
schema: z.ZodObject<{
|
|
38
38
|
sso: z.ZodArray<z.ZodObject<{
|
|
39
39
|
id: z.ZodString;
|
|
@@ -10,39 +10,39 @@ export const routeMiddlewareSchema = z.object({
|
|
|
10
10
|
captcha: z.object({
|
|
11
11
|
siteKey: z.string(),
|
|
12
12
|
type: z.enum([
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
"cloudflare_turnstile",
|
|
14
|
+
"recaptcha_v3"
|
|
15
15
|
])
|
|
16
16
|
}).optional()
|
|
17
17
|
});
|
|
18
18
|
export const routeMiddleware = buildRoute({
|
|
19
|
-
|
|
19
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
20
20
|
route: {
|
|
21
|
-
path:
|
|
22
|
-
method:
|
|
23
|
-
description:
|
|
21
|
+
path: "/",
|
|
22
|
+
method: "get",
|
|
23
|
+
description: "Middleware route with user authentication",
|
|
24
24
|
responses: {
|
|
25
25
|
200: {
|
|
26
26
|
content: {
|
|
27
|
-
|
|
27
|
+
"application/json": {
|
|
28
28
|
schema: routeMiddlewareSchema
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
-
description:
|
|
31
|
+
description: "Middleware route"
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
handler: (c)=>{
|
|
36
|
-
const sso = c.get(
|
|
36
|
+
const sso = c.get("core").authorization.ssoAdapters;
|
|
37
37
|
return c.json({
|
|
38
|
-
isEmail: !!c.get(
|
|
38
|
+
isEmail: !!c.get("core").email?.adapter,
|
|
39
39
|
sso: sso.map((s)=>({
|
|
40
40
|
id: s.id,
|
|
41
41
|
name: s.name
|
|
42
42
|
})),
|
|
43
|
-
captcha: c.get(
|
|
44
|
-
siteKey: c.get(
|
|
45
|
-
type: c.get(
|
|
43
|
+
captcha: c.get("core").captcha ? {
|
|
44
|
+
siteKey: c.get("core").captcha?.siteKey ?? "",
|
|
45
|
+
type: c.get("core").captcha?.type ?? "cloudflare_turnstile"
|
|
46
46
|
} : undefined
|
|
47
47
|
}, 200);
|
|
48
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
export declare const zodChangePasswordSchema: z.ZodObject<{
|
|
3
3
|
password: z.ZodString;
|
|
4
4
|
userId: z.ZodNumber;
|
|
@@ -30,7 +30,7 @@ export declare const changePasswordRoute: {
|
|
|
30
30
|
body: {
|
|
31
31
|
required: true;
|
|
32
32
|
content: {
|
|
33
|
-
|
|
33
|
+
"application/json": {
|
|
34
34
|
schema: z.ZodObject<{
|
|
35
35
|
password: z.ZodString;
|
|
36
36
|
userId: z.ZodNumber;
|
|
@@ -7,26 +7,26 @@ import { CONFIG_PLUGIN } from "../../../../config.js";
|
|
|
7
7
|
import { core_users, core_users_forgot_password } from "../../../../database/users.js";
|
|
8
8
|
export const zodChangePasswordSchema = z.object({
|
|
9
9
|
password: z.string().min(8).openapi({
|
|
10
|
-
example:
|
|
10
|
+
example: "Test123!"
|
|
11
11
|
}),
|
|
12
12
|
userId: z.number().openapi({
|
|
13
13
|
example: 123456
|
|
14
14
|
}),
|
|
15
15
|
token: z.string().openapi({
|
|
16
|
-
example:
|
|
16
|
+
example: "abcdefg12345"
|
|
17
17
|
})
|
|
18
18
|
});
|
|
19
19
|
export const changePasswordRoute = buildRoute({
|
|
20
|
-
|
|
20
|
+
pluginId: CONFIG_PLUGIN.pluginId,
|
|
21
21
|
route: {
|
|
22
|
-
method:
|
|
23
|
-
description:
|
|
24
|
-
path:
|
|
22
|
+
method: "post",
|
|
23
|
+
description: "Change user password",
|
|
24
|
+
path: "/change-password",
|
|
25
25
|
request: {
|
|
26
26
|
body: {
|
|
27
27
|
required: true,
|
|
28
28
|
content: {
|
|
29
|
-
|
|
29
|
+
"application/json": {
|
|
30
30
|
schema: zodChangePasswordSchema
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -34,25 +34,25 @@ export const changePasswordRoute = buildRoute({
|
|
|
34
34
|
},
|
|
35
35
|
responses: {
|
|
36
36
|
201: {
|
|
37
|
-
description:
|
|
37
|
+
description: "Password changed"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
handler: async (c)=>{
|
|
42
|
-
const { password, userId, token } = c.req.valid(
|
|
43
|
-
const [user] = await c.get(
|
|
42
|
+
const { password, userId, token } = c.req.valid("json");
|
|
43
|
+
const [user] = await c.get("db").select().from(core_users_forgot_password).where(and(eq(core_users_forgot_password.userId, userId), eq(core_users_forgot_password.token, token), gt(core_users_forgot_password.expiresAt, new Date()))).limit(1);
|
|
44
44
|
if (!user) {
|
|
45
45
|
throw new HTTPException(400, {
|
|
46
|
-
message:
|
|
46
|
+
message: "Invalid token"
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
const hashPassword = await new PasswordModel().encryptPassword(password);
|
|
50
50
|
await Promise.all([
|
|
51
|
-
c.get(
|
|
51
|
+
c.get("db").update(core_users).set({
|
|
52
52
|
password: hashPassword
|
|
53
53
|
}).where(eq(core_users.id, userId)),
|
|
54
|
-
c.get(
|
|
54
|
+
c.get("db").delete(core_users_forgot_password).where(eq(core_users_forgot_password.id, user.id))
|
|
55
55
|
]);
|
|
56
|
-
return c.text(
|
|
56
|
+
return c.text("Password changed", 201);
|
|
57
57
|
}
|
|
58
58
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
export declare const resetPasswordRoute: {
|
|
3
3
|
handler: (c: import("hono").Context<import("../../../middlewares/global.middleware").EnvVitNode, "/reset-password", {
|
|
4
4
|
in: {
|
|
@@ -22,7 +22,7 @@ export declare const resetPasswordRoute: {
|
|
|
22
22
|
body: {
|
|
23
23
|
required: true;
|
|
24
24
|
content: {
|
|
25
|
-
|
|
25
|
+
"application/json": {
|
|
26
26
|
schema: z.ZodObject<{
|
|
27
27
|
email: z.ZodEmail;
|
|
28
28
|
}, z.core.$strip>;
|