@basicbenframework/cms 0.0.0-stage → 0.6.0
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 +9 -0
- package/README.md +206 -2
- package/db/migrations/001_create_users.js +15 -0
- package/db/migrations/002_create_posts.js +18 -0
- package/db/migrations/003_create_categories.js +19 -0
- package/db/migrations/004_create_tags.js +16 -0
- package/db/migrations/005_create_post_tags.js +16 -0
- package/db/migrations/006_create_pages.js +26 -0
- package/db/migrations/007_create_comments.js +24 -0
- package/db/migrations/008_create_media.js +22 -0
- package/db/migrations/009_update_posts_blogging.js +27 -0
- package/db/migrations/010_create_settings.js +29 -0
- package/db/migrations/011_add_user_roles.js +23 -0
- package/db/migrations/012_create_auth_tokens.js +30 -0
- package/db/migrations/013_add_email_verified.js +24 -0
- package/db/migrations/014_create_user_two_factor.js +30 -0
- package/db/migrations/015_create_user_credentials.js +35 -0
- package/db/migrations/016_create_rate_limits.js +31 -0
- package/db/migrations/017_add_content_html.js +38 -0
- package/db/migrations/018_create_api_tokens.js +34 -0
- package/db/migrations/019_create_post_categories.js +40 -0
- package/db/migrations/020_add_author_profiles.js +60 -0
- package/db/migrations/021_add_page_featured_image.js +23 -0
- package/db/migrations/022_backfill_post_slugs_and_excerpts.js +57 -0
- package/db/migrations/023_add_user_session_controls.js +25 -0
- package/db/migrations/024_add_post_status_and_trash.js +45 -0
- package/db/migrations/025_add_social_and_indexing_fields.js +40 -0
- package/db/migrations/026_create_post_revisions.js +29 -0
- package/db/migrations/027_add_media_dimensions.js +19 -0
- package/db/migrations/028_create_navigation_menus.js +65 -0
- package/db/migrations/029_create_redirects.js +40 -0
- package/db/migrations/030_add_comment_status_and_notifications.js +53 -0
- package/db/migrations/031_create_post_locks.js +38 -0
- package/db/migrations/032_create_snippets.js +31 -0
- package/db/migrations/033_create_members.js +70 -0
- package/db/migrations/034_add_post_visibility.js +28 -0
- package/db/migrations/035_create_newsletters.js +72 -0
- package/db/migrations/036_create_analytics.js +89 -0
- package/db/migrations/037_create_ops_heartbeats.js +30 -0
- package/db/migrations/038_create_content_types.js +84 -0
- package/db/migrations/039_create_content_type_fields.js +47 -0
- package/db/migrations/040_create_taxonomies.js +80 -0
- package/db/migrations/041_add_newsletter_handoff.js +28 -0
- package/db/migrations/042_create_mysendbox_contacts.js +63 -0
- package/lib/cli/backup.d.mts +2 -0
- package/lib/cli/backup.mjs +124 -0
- package/lib/cli/export.d.mts +2 -0
- package/lib/cli/export.mjs +54 -0
- package/lib/cli/import-ghost.d.mts +2 -0
- package/lib/cli/import-ghost.mjs +50 -0
- package/lib/cli/import-json.d.mts +2 -0
- package/lib/cli/import-json.mjs +61 -0
- package/lib/cli/import-wordpress.d.mts +2 -0
- package/lib/cli/import-wordpress.mjs +169 -0
- package/lib/cli/import-wxr.d.mts +2 -0
- package/lib/cli/import-wxr.mjs +55 -0
- package/lib/cli/index.d.mts +2 -0
- package/lib/cli/index.mjs +53 -0
- package/lib/cli/lib/backup.d.mts +112 -0
- package/lib/cli/lib/backup.mjs +297 -0
- package/lib/cli/lib/ghost.d.mts +30 -0
- package/lib/cli/lib/ghost.mjs +201 -0
- package/lib/cli/lib/html-to-markdown.d.mts +61 -0
- package/lib/cli/lib/html-to-markdown.mjs +523 -0
- package/lib/cli/lib/import-common.d.mts +100 -0
- package/lib/cli/lib/import-common.mjs +252 -0
- package/lib/cli/lib/json-import.d.mts +22 -0
- package/lib/cli/lib/json-import.mjs +422 -0
- package/lib/cli/lib/site-import.d.mts +32 -0
- package/lib/cli/lib/site-import.mjs +456 -0
- package/lib/cli/lib/wordpress-rest.d.mts +25 -0
- package/lib/cli/lib/wordpress-rest.mjs +177 -0
- package/lib/cli/lib/wxr.d.mts +18 -0
- package/lib/cli/lib/wxr.mjs +307 -0
- package/lib/cli/lib/xml.d.mts +33 -0
- package/lib/cli/lib/xml.mjs +186 -0
- package/lib/cli/restore.d.mts +2 -0
- package/lib/cli/restore.mjs +98 -0
- package/lib/client/components/Alert.d.ts +7 -0
- package/lib/client/components/Alert.js +8 -0
- package/lib/client/components/Avatar.d.ts +15 -0
- package/lib/client/components/Avatar.js +10 -0
- package/lib/client/components/BackLink.d.ts +7 -0
- package/lib/client/components/BackLink.js +6 -0
- package/lib/client/components/Button.d.ts +7 -0
- package/lib/client/components/Button.js +12 -0
- package/lib/client/components/Card.d.ts +7 -0
- package/lib/client/components/Card.js +6 -0
- package/lib/client/components/CommentThread.d.ts +15 -0
- package/lib/client/components/CommentThread.js +101 -0
- package/lib/client/components/Empty.d.ts +6 -0
- package/lib/client/components/Empty.js +6 -0
- package/lib/client/components/Input.d.ts +6 -0
- package/lib/client/components/Input.js +6 -0
- package/lib/client/components/Link.d.ts +31 -0
- package/lib/client/components/Link.js +49 -0
- package/lib/client/components/Loading.d.ts +1 -0
- package/lib/client/components/Loading.js +6 -0
- package/lib/client/components/Logo.d.ts +5 -0
- package/lib/client/components/Logo.js +4 -0
- package/lib/client/components/MarkdownEditor.d.ts +41 -0
- package/lib/client/components/MarkdownEditor.js +156 -0
- package/lib/client/components/Nav/DarkModeToggle.d.ts +6 -0
- package/lib/client/components/Nav/DarkModeToggle.js +6 -0
- package/lib/client/components/Nav/DesktopNav.d.ts +8 -0
- package/lib/client/components/Nav/DesktopNav.js +9 -0
- package/lib/client/components/Nav/MobileNav.d.ts +9 -0
- package/lib/client/components/Nav/MobileNav.js +15 -0
- package/lib/client/components/NavLink.d.ts +8 -0
- package/lib/client/components/NavLink.js +6 -0
- package/lib/client/components/PageHeader.d.ts +8 -0
- package/lib/client/components/PageHeader.js +6 -0
- package/lib/client/components/PostCard.d.ts +8 -0
- package/lib/client/components/PostCard.js +7 -0
- package/lib/client/components/Textarea.d.ts +6 -0
- package/lib/client/components/Textarea.js +6 -0
- package/lib/client/components/ThemeContext.d.ts +18 -0
- package/lib/client/components/ThemeContext.js +8 -0
- package/lib/client/components/admin/AdminIcons.d.ts +13 -0
- package/lib/client/components/admin/AdminIcons.js +66 -0
- package/lib/client/components/admin/ContentModelPanels.d.ts +22 -0
- package/lib/client/components/admin/ContentModelPanels.js +93 -0
- package/lib/client/components/admin/FeaturedImageBox.d.ts +21 -0
- package/lib/client/components/admin/FeaturedImageBox.js +24 -0
- package/lib/client/components/admin/MediaGrid.d.ts +23 -0
- package/lib/client/components/admin/MediaGrid.js +69 -0
- package/lib/client/components/admin/MediaPicker.d.ts +17 -0
- package/lib/client/components/admin/MediaPicker.js +61 -0
- package/lib/client/components/admin/Pagination.d.ts +27 -0
- package/lib/client/components/admin/Pagination.js +29 -0
- package/lib/client/components/admin/SnippetPicker.d.ts +27 -0
- package/lib/client/components/admin/SnippetPicker.js +65 -0
- package/lib/client/components/admin/TermPicker.d.ts +52 -0
- package/lib/client/components/admin/TermPicker.js +58 -0
- package/lib/client/contexts/ToastContext.d.ts +12 -0
- package/lib/client/contexts/ToastContext.js +49 -0
- package/lib/client/features.d.ts +11 -0
- package/lib/client/features.js +7 -0
- package/lib/client/hooks/useContentTypes.d.ts +48 -0
- package/lib/client/hooks/useContentTypes.js +48 -0
- package/lib/client/hooks/useMediaLibrary.d.ts +46 -0
- package/lib/client/hooks/useMediaLibrary.js +189 -0
- package/lib/client/hooks/usePostLock.d.ts +32 -0
- package/lib/client/hooks/usePostLock.js +107 -0
- package/lib/client/host/index.d.ts +71 -0
- package/lib/client/host/index.js +58 -0
- package/lib/client/i18n/index.d.ts +79 -0
- package/lib/client/i18n/index.js +177 -0
- package/lib/client/i18n/locales/es/content.d.ts +4 -0
- package/lib/client/i18n/locales/es/content.js +220 -0
- package/lib/client/i18n/locales/es/editor.d.ts +9 -0
- package/lib/client/i18n/locales/es/editor.js +144 -0
- package/lib/client/i18n/locales/es/index.d.ts +8 -0
- package/lib/client/i18n/locales/es/index.js +7 -0
- package/lib/client/i18n/locales/es/layout.d.ts +4 -0
- package/lib/client/i18n/locales/es/layout.js +35 -0
- package/lib/client/i18n/locales/es/people.d.ts +4 -0
- package/lib/client/i18n/locales/es/people.js +187 -0
- package/lib/client/i18n/locales/es/site.d.ts +4 -0
- package/lib/client/i18n/locales/es/site.js +208 -0
- package/lib/client/layouts/AdminLayout.d.ts +7 -0
- package/lib/client/layouts/AdminLayout.js +1046 -0
- package/lib/client/layouts/AppLayout.d.ts +6 -0
- package/lib/client/layouts/AppLayout.js +19 -0
- package/lib/client/layouts/AuthLayout.d.ts +6 -0
- package/lib/client/layouts/AuthLayout.js +14 -0
- package/lib/client/layouts/DocsLayout.d.ts +6 -0
- package/lib/client/layouts/DocsLayout.js +28 -0
- package/lib/client/layouts/RootLayout.d.ts +6 -0
- package/lib/client/layouts/RootLayout.js +11 -0
- package/lib/client/pages/AcceptInvite.d.ts +8 -0
- package/lib/client/pages/AcceptInvite.js +60 -0
- package/lib/client/pages/Auth.d.ts +1 -0
- package/lib/client/pages/Auth.js +40 -0
- package/lib/client/pages/Authentication.d.ts +1 -0
- package/lib/client/pages/Authentication.js +230 -0
- package/lib/client/pages/Content.d.ts +1 -0
- package/lib/client/pages/Content.js +21 -0
- package/lib/client/pages/Database.d.ts +1 -0
- package/lib/client/pages/Database.js +264 -0
- package/lib/client/pages/Extending.d.ts +1 -0
- package/lib/client/pages/Extending.js +28 -0
- package/lib/client/pages/Feed.d.ts +1 -0
- package/lib/client/pages/Feed.js +19 -0
- package/lib/client/pages/FeedPost.d.ts +1 -0
- package/lib/client/pages/FeedPost.js +31 -0
- package/lib/client/pages/ForgotPassword.d.ts +8 -0
- package/lib/client/pages/ForgotPassword.js +38 -0
- package/lib/client/pages/GettingStarted.d.ts +1 -0
- package/lib/client/pages/GettingStarted.js +84 -0
- package/lib/client/pages/Headless.d.ts +1 -0
- package/lib/client/pages/Headless.js +49 -0
- package/lib/client/pages/Home.d.ts +1 -0
- package/lib/client/pages/Home.js +67 -0
- package/lib/client/pages/PostForm.d.ts +1 -0
- package/lib/client/pages/PostForm.js +55 -0
- package/lib/client/pages/Posts.d.ts +1 -0
- package/lib/client/pages/Posts.js +35 -0
- package/lib/client/pages/Profile.d.ts +1 -0
- package/lib/client/pages/Profile.js +153 -0
- package/lib/client/pages/ResetPassword.d.ts +8 -0
- package/lib/client/pages/ResetPassword.js +52 -0
- package/lib/client/pages/Routing.d.ts +1 -0
- package/lib/client/pages/Routing.js +192 -0
- package/lib/client/pages/Storage.d.ts +1 -0
- package/lib/client/pages/Storage.js +54 -0
- package/lib/client/pages/Testing.d.ts +1 -0
- package/lib/client/pages/Testing.js +141 -0
- package/lib/client/pages/Validation.d.ts +1 -0
- package/lib/client/pages/Validation.js +123 -0
- package/lib/client/pages/admin/Categories.d.ts +2 -0
- package/lib/client/pages/admin/Categories.js +75 -0
- package/lib/client/pages/admin/Comments.d.ts +11 -0
- package/lib/client/pages/admin/Comments.js +247 -0
- package/lib/client/pages/admin/ContentTypes.d.ts +2 -0
- package/lib/client/pages/admin/ContentTypes.js +163 -0
- package/lib/client/pages/admin/Dashboard.d.ts +2 -0
- package/lib/client/pages/admin/Dashboard.js +66 -0
- package/lib/client/pages/admin/Health.d.ts +12 -0
- package/lib/client/pages/admin/Health.js +148 -0
- package/lib/client/pages/admin/Media.d.ts +2 -0
- package/lib/client/pages/admin/Media.js +101 -0
- package/lib/client/pages/admin/Navigation.d.ts +9 -0
- package/lib/client/pages/admin/Navigation.js +230 -0
- package/lib/client/pages/admin/Pages.d.ts +2 -0
- package/lib/client/pages/admin/Pages.js +53 -0
- package/lib/client/pages/admin/PostEditor.d.ts +17 -0
- package/lib/client/pages/admin/PostEditor.js +532 -0
- package/lib/client/pages/admin/Posts.d.ts +2 -0
- package/lib/client/pages/admin/Posts.js +152 -0
- package/lib/client/pages/admin/Redirects.d.ts +10 -0
- package/lib/client/pages/admin/Redirects.js +87 -0
- package/lib/client/pages/admin/Settings.d.ts +2 -0
- package/lib/client/pages/admin/Settings.js +111 -0
- package/lib/client/pages/admin/Snippets.d.ts +14 -0
- package/lib/client/pages/admin/Snippets.js +85 -0
- package/lib/client/pages/admin/Tags.d.ts +2 -0
- package/lib/client/pages/admin/Tags.js +74 -0
- package/lib/client/pages/admin/Taxonomies.d.ts +2 -0
- package/lib/client/pages/admin/Taxonomies.js +130 -0
- package/lib/client/pages/admin/Tokens.d.ts +9 -0
- package/lib/client/pages/admin/Tokens.js +260 -0
- package/lib/client/pages/admin/Tools.d.ts +12 -0
- package/lib/client/pages/admin/Tools.js +111 -0
- package/lib/client/pages/admin/Users.d.ts +13 -0
- package/lib/client/pages/admin/Users.js +313 -0
- package/lib/client/pages/api-reference.d.ts +33 -0
- package/lib/client/pages/api-reference.js +198 -0
- package/lib/client/styles.css +37 -0
- package/lib/config.d.ts +24 -0
- package/lib/config.js +39 -0
- package/lib/controllers/AdminController.d.ts +46 -0
- package/lib/controllers/AdminController.js +134 -0
- package/lib/controllers/AuthController.d.ts +15 -0
- package/lib/controllers/AuthController.js +194 -0
- package/lib/controllers/AuthorController.d.ts +17 -0
- package/lib/controllers/AuthorController.js +19 -0
- package/lib/controllers/CategoryController.d.ts +10 -0
- package/lib/controllers/CategoryController.js +88 -0
- package/lib/controllers/CommentController.d.ts +68 -0
- package/lib/controllers/CommentController.js +438 -0
- package/lib/controllers/ContentTypeController.d.ts +24 -0
- package/lib/controllers/ContentTypeController.js +91 -0
- package/lib/controllers/EmailVerificationController.d.ts +33 -0
- package/lib/controllers/EmailVerificationController.js +116 -0
- package/lib/controllers/ExportController.d.ts +15 -0
- package/lib/controllers/ExportController.js +41 -0
- package/lib/controllers/FeedController.d.ts +14 -0
- package/lib/controllers/FeedController.js +246 -0
- package/lib/controllers/HealthController.d.ts +21 -0
- package/lib/controllers/HealthController.js +176 -0
- package/lib/controllers/HomeController.d.ts +12 -0
- package/lib/controllers/HomeController.js +16 -0
- package/lib/controllers/MediaController.d.ts +24 -0
- package/lib/controllers/MediaController.js +189 -0
- package/lib/controllers/NavigationController.d.ts +22 -0
- package/lib/controllers/NavigationController.js +176 -0
- package/lib/controllers/PageController.d.ts +13 -0
- package/lib/controllers/PageController.js +172 -0
- package/lib/controllers/PasskeyController.d.ts +36 -0
- package/lib/controllers/PasskeyController.js +201 -0
- package/lib/controllers/PasswordResetController.d.ts +44 -0
- package/lib/controllers/PasswordResetController.js +160 -0
- package/lib/controllers/PostController.d.ts +51 -0
- package/lib/controllers/PostController.js +538 -0
- package/lib/controllers/PostLockController.d.ts +62 -0
- package/lib/controllers/PostLockController.js +101 -0
- package/lib/controllers/ProfileController.d.ts +13 -0
- package/lib/controllers/ProfileController.js +160 -0
- package/lib/controllers/PublicApiController.d.ts +23 -0
- package/lib/controllers/PublicApiController.js +100 -0
- package/lib/controllers/RedirectController.d.ts +32 -0
- package/lib/controllers/RedirectController.js +95 -0
- package/lib/controllers/SettingsController.d.ts +28 -0
- package/lib/controllers/SettingsController.js +105 -0
- package/lib/controllers/SnippetController.d.ts +27 -0
- package/lib/controllers/SnippetController.js +123 -0
- package/lib/controllers/TagController.d.ts +9 -0
- package/lib/controllers/TagController.js +70 -0
- package/lib/controllers/TaxonomyController.d.ts +24 -0
- package/lib/controllers/TaxonomyController.js +149 -0
- package/lib/controllers/TokenController.d.ts +27 -0
- package/lib/controllers/TokenController.js +83 -0
- package/lib/controllers/TwoFactorController.d.ts +31 -0
- package/lib/controllers/TwoFactorController.js +213 -0
- package/lib/controllers/UserController.d.ts +110 -0
- package/lib/controllers/UserController.js +504 -0
- package/lib/features/analytics/AnalyticsPage.d.ts +11 -0
- package/lib/features/analytics/AnalyticsPage.js +123 -0
- package/lib/features/analytics/admin.d.ts +3 -0
- package/lib/features/analytics/admin.js +9 -0
- package/lib/features/analytics/controller.d.ts +19 -0
- package/lib/features/analytics/controller.js +79 -0
- package/lib/features/analytics/helpers.d.ts +84 -0
- package/lib/features/analytics/helpers.js +181 -0
- package/lib/features/analytics/i18n/es.d.ts +4 -0
- package/lib/features/analytics/i18n/es.js +31 -0
- package/lib/features/analytics/index.d.ts +28 -0
- package/lib/features/analytics/index.js +91 -0
- package/lib/features/analytics/manifest.d.ts +8 -0
- package/lib/features/analytics/manifest.js +18 -0
- package/lib/features/analytics/model.d.ts +130 -0
- package/lib/features/analytics/model.js +206 -0
- package/lib/features/members/Member.d.ts +93 -0
- package/lib/features/members/Member.js +194 -0
- package/lib/features/members/MemberAdminController.d.ts +60 -0
- package/lib/features/members/MemberAdminController.js +262 -0
- package/lib/features/members/MemberController.d.ts +88 -0
- package/lib/features/members/MemberController.js +250 -0
- package/lib/features/members/MembersPage.d.ts +10 -0
- package/lib/features/members/MembersPage.js +216 -0
- package/lib/features/members/PostAccessBox.d.ts +15 -0
- package/lib/features/members/PostAccessBox.js +70 -0
- package/lib/features/members/admin.d.ts +3 -0
- package/lib/features/members/admin.js +12 -0
- package/lib/features/members/csv.d.ts +21 -0
- package/lib/features/members/csv.js +74 -0
- package/lib/features/members/events.d.ts +34 -0
- package/lib/features/members/events.js +34 -0
- package/lib/features/members/i18n/es.d.ts +4 -0
- package/lib/features/members/i18n/es.js +106 -0
- package/lib/features/members/index.d.ts +44 -0
- package/lib/features/members/index.js +106 -0
- package/lib/features/members/manifest.d.ts +8 -0
- package/lib/features/members/manifest.js +18 -0
- package/lib/features/members/middleware.d.ts +42 -0
- package/lib/features/members/middleware.js +74 -0
- package/lib/features/members/newsletter.d.ts +177 -0
- package/lib/features/members/newsletter.js +439 -0
- package/lib/features/members/rate-limits.d.ts +34 -0
- package/lib/features/members/rate-limits.js +50 -0
- package/lib/features/members/request.d.ts +13 -0
- package/lib/features/members/request.js +6 -0
- package/lib/features/members/routes.d.ts +15 -0
- package/lib/features/members/routes.js +59 -0
- package/lib/features/members/session.d.ts +102 -0
- package/lib/features/members/session.js +158 -0
- package/lib/features/members/settings.d.ts +14 -0
- package/lib/features/members/settings.js +23 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.d.ts +7 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.js +48 -0
- package/lib/features/mysendbox/admin.d.ts +3 -0
- package/lib/features/mysendbox/admin.js +9 -0
- package/lib/features/mysendbox/broadcasts.d.ts +61 -0
- package/lib/features/mysendbox/broadcasts.js +124 -0
- package/lib/features/mysendbox/client.d.ts +95 -0
- package/lib/features/mysendbox/client.js +61 -0
- package/lib/features/mysendbox/config.d.ts +27 -0
- package/lib/features/mysendbox/config.js +74 -0
- package/lib/features/mysendbox/contacts.d.ts +121 -0
- package/lib/features/mysendbox/contacts.js +378 -0
- package/lib/features/mysendbox/controller.d.ts +11 -0
- package/lib/features/mysendbox/controller.js +47 -0
- package/lib/features/mysendbox/i18n/es.d.ts +4 -0
- package/lib/features/mysendbox/i18n/es.js +28 -0
- package/lib/features/mysendbox/index.d.ts +18 -0
- package/lib/features/mysendbox/index.js +71 -0
- package/lib/features/mysendbox/manifest.d.ts +7 -0
- package/lib/features/mysendbox/manifest.js +6 -0
- package/lib/features/mysendbox/routes.d.ts +6 -0
- package/lib/features/mysendbox/routes.js +14 -0
- package/lib/features/mysendbox/webhook.d.ts +23 -0
- package/lib/features/mysendbox/webhook.js +104 -0
- package/lib/features/theme/OEmbedController.d.ts +31 -0
- package/lib/features/theme/OEmbedController.js +128 -0
- package/lib/features/theme/ThemeController.d.ts +20 -0
- package/lib/features/theme/ThemeController.js +256 -0
- package/lib/features/theme/ThemeSettingsCard.d.ts +7 -0
- package/lib/features/theme/ThemeSettingsCard.js +12 -0
- package/lib/features/theme/admin.d.ts +3 -0
- package/lib/features/theme/admin.js +9 -0
- package/lib/features/theme/html.d.ts +48 -0
- package/lib/features/theme/html.js +97 -0
- package/lib/features/theme/i18n/es.d.ts +4 -0
- package/lib/features/theme/i18n/es.js +9 -0
- package/lib/features/theme/index.d.ts +11 -0
- package/lib/features/theme/index.js +23 -0
- package/lib/features/theme/manifest.d.ts +7 -0
- package/lib/features/theme/manifest.js +6 -0
- package/lib/features/theme/oembed.d.ts +36 -0
- package/lib/features/theme/oembed.js +58 -0
- package/lib/features/theme/routes.d.ts +17 -0
- package/lib/features/theme/routes.js +54 -0
- package/lib/features/theme/templates.d.ts +103 -0
- package/lib/features/theme/templates.js +283 -0
- package/lib/features.d.ts +15 -0
- package/lib/features.js +6 -0
- package/lib/features.manifest.d.ts +10 -0
- package/lib/features.manifest.js +6 -0
- package/lib/helpers/access.d.ts +62 -0
- package/lib/helpers/access.js +92 -0
- package/lib/helpers/api.d.ts +20 -0
- package/lib/helpers/api.js +44 -0
- package/lib/helpers/comment-guard.d.ts +145 -0
- package/lib/helpers/comment-guard.js +253 -0
- package/lib/helpers/comment-mail.d.ts +53 -0
- package/lib/helpers/comment-mail.js +188 -0
- package/lib/helpers/content-model.d.ts +50 -0
- package/lib/helpers/content-model.js +84 -0
- package/lib/helpers/content-paths.d.ts +107 -0
- package/lib/helpers/content-paths.js +200 -0
- package/lib/helpers/export-data.d.ts +85 -0
- package/lib/helpers/export-data.js +229 -0
- package/lib/helpers/gating.d.ts +53 -0
- package/lib/helpers/gating.js +83 -0
- package/lib/helpers/health.d.ts +91 -0
- package/lib/helpers/health.js +279 -0
- package/lib/helpers/heartbeat.d.ts +35 -0
- package/lib/helpers/heartbeat.js +55 -0
- package/lib/helpers/image-size.d.ts +18 -0
- package/lib/helpers/image-size.js +83 -0
- package/lib/helpers/images.d.ts +29 -0
- package/lib/helpers/images.js +41 -0
- package/lib/helpers/mail-templates.d.ts +11 -0
- package/lib/helpers/mail-templates.js +42 -0
- package/lib/helpers/publish-due.d.ts +28 -0
- package/lib/helpers/publish-due.js +67 -0
- package/lib/helpers/redirects.d.ts +43 -0
- package/lib/helpers/redirects.js +80 -0
- package/lib/helpers/seo-fields.d.ts +13 -0
- package/lib/helpers/seo-fields.js +52 -0
- package/lib/helpers/session.d.ts +30 -0
- package/lib/helpers/session.js +27 -0
- package/lib/helpers/site-settings.d.ts +98 -0
- package/lib/helpers/site-settings.js +232 -0
- package/lib/helpers/site.d.ts +14 -0
- package/lib/helpers/site.js +23 -0
- package/lib/helpers/write-hooks.d.ts +33 -0
- package/lib/helpers/write-hooks.js +37 -0
- package/lib/hooks.d.ts +17 -0
- package/lib/hooks.js +101 -0
- package/lib/host/core-tasks.d.ts +4 -0
- package/lib/host/core-tasks.js +26 -0
- package/lib/host/cron.d.ts +39 -0
- package/lib/host/cron.js +85 -0
- package/lib/host/enabled.d.ts +4 -0
- package/lib/host/enabled.js +40 -0
- package/lib/host/index.d.ts +81 -0
- package/lib/host/index.js +87 -0
- package/lib/host/manifest.d.ts +34 -0
- package/lib/host/manifest.js +7 -0
- package/lib/host/menu.d.ts +18 -0
- package/lib/host/menu.js +15 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +24 -0
- package/lib/middleware/api-auth.d.ts +59 -0
- package/lib/middleware/api-auth.js +164 -0
- package/lib/middleware/auth.d.ts +49 -0
- package/lib/middleware/auth.js +112 -0
- package/lib/middleware/cache.d.ts +17 -0
- package/lib/middleware/cache.js +52 -0
- package/lib/middleware/rate-limits.d.ts +199 -0
- package/lib/middleware/rate-limits.js +276 -0
- package/lib/middleware/viewer.d.ts +13 -0
- package/lib/middleware/viewer.js +16 -0
- package/lib/models/Category.d.ts +24 -0
- package/lib/models/Category.js +102 -0
- package/lib/models/Comment.d.ts +120 -0
- package/lib/models/Comment.js +283 -0
- package/lib/models/ContentType.d.ts +142 -0
- package/lib/models/ContentType.js +462 -0
- package/lib/models/Credential.d.ts +21 -0
- package/lib/models/Credential.js +31 -0
- package/lib/models/Media.d.ts +53 -0
- package/lib/models/Media.js +132 -0
- package/lib/models/Menu.d.ts +131 -0
- package/lib/models/Menu.js +312 -0
- package/lib/models/Page.d.ts +55 -0
- package/lib/models/Page.js +218 -0
- package/lib/models/Post.d.ts +136 -0
- package/lib/models/Post.js +406 -0
- package/lib/models/PostLock.d.ts +67 -0
- package/lib/models/PostLock.js +112 -0
- package/lib/models/PostRevision.d.ts +45 -0
- package/lib/models/PostRevision.js +82 -0
- package/lib/models/PublicContent.d.ts +283 -0
- package/lib/models/PublicContent.js +577 -0
- package/lib/models/Redirect.d.ts +123 -0
- package/lib/models/Redirect.js +225 -0
- package/lib/models/Settings.d.ts +61 -0
- package/lib/models/Settings.js +128 -0
- package/lib/models/Snippet.d.ts +36 -0
- package/lib/models/Snippet.js +64 -0
- package/lib/models/Tag.d.ts +23 -0
- package/lib/models/Tag.js +117 -0
- package/lib/models/Taxonomy.d.ts +127 -0
- package/lib/models/Taxonomy.js +321 -0
- package/lib/models/TwoFactor.d.ts +26 -0
- package/lib/models/TwoFactor.js +60 -0
- package/lib/models/User.d.ts +49 -0
- package/lib/models/User.js +128 -0
- package/lib/models/derive.d.ts +69 -0
- package/lib/models/derive.js +81 -0
- package/lib/models/pagination.d.ts +30 -0
- package/lib/models/pagination.js +36 -0
- package/lib/models/visibility.d.ts +31 -0
- package/lib/models/visibility.js +47 -0
- package/lib/routes/App.d.ts +2 -0
- package/lib/routes/App.js +146 -0
- package/lib/routes/api/admin.d.ts +6 -0
- package/lib/routes/api/admin.js +11 -0
- package/lib/routes/api/auth.d.ts +6 -0
- package/lib/routes/api/auth.js +24 -0
- package/lib/routes/api/authors.d.ts +5 -0
- package/lib/routes/api/authors.js +8 -0
- package/lib/routes/api/categories.d.ts +8 -0
- package/lib/routes/api/categories.js +15 -0
- package/lib/routes/api/comments.d.ts +8 -0
- package/lib/routes/api/comments.js +35 -0
- package/lib/routes/api/content-model.d.ts +17 -0
- package/lib/routes/api/content-model.js +67 -0
- package/lib/routes/api/cron.d.ts +6 -0
- package/lib/routes/api/cron.js +9 -0
- package/lib/routes/api/export.d.ts +5 -0
- package/lib/routes/api/export.js +11 -0
- package/lib/routes/api/feed.d.ts +5 -0
- package/lib/routes/api/feed.js +16 -0
- package/lib/routes/api/media.d.ts +8 -0
- package/lib/routes/api/media.js +25 -0
- package/lib/routes/api/navigation.d.ts +12 -0
- package/lib/routes/api/navigation.js +17 -0
- package/lib/routes/api/ops.d.ts +9 -0
- package/lib/routes/api/ops.js +19 -0
- package/lib/routes/api/pages.d.ts +8 -0
- package/lib/routes/api/pages.js +21 -0
- package/lib/routes/api/passkeys.d.ts +7 -0
- package/lib/routes/api/passkeys.js +13 -0
- package/lib/routes/api/posts.d.ts +8 -0
- package/lib/routes/api/posts.js +39 -0
- package/lib/routes/api/profile.d.ts +6 -0
- package/lib/routes/api/profile.js +8 -0
- package/lib/routes/api/redirects.d.ts +12 -0
- package/lib/routes/api/redirects.js +13 -0
- package/lib/routes/api/settings.d.ts +8 -0
- package/lib/routes/api/settings.js +15 -0
- package/lib/routes/api/snippets.d.ts +15 -0
- package/lib/routes/api/snippets.js +16 -0
- package/lib/routes/api/tags.d.ts +8 -0
- package/lib/routes/api/tags.js +14 -0
- package/lib/routes/api/tokens.d.ts +7 -0
- package/lib/routes/api/tokens.js +15 -0
- package/lib/routes/api/two-factor.d.ts +7 -0
- package/lib/routes/api/two-factor.js +15 -0
- package/lib/routes/api/users.d.ts +8 -0
- package/lib/routes/api/users.js +25 -0
- package/lib/routes/api/v1.d.ts +12 -0
- package/lib/routes/api/v1.js +55 -0
- package/lib/routes/api/verification.d.ts +6 -0
- package/lib/routes/api/verification.js +11 -0
- package/lib/server/index.d.ts +24 -0
- package/lib/server/index.js +110 -0
- package/lib/types/index.d.ts +298 -0
- package/lib/types/index.js +1 -0
- package/lib/vite.d.ts +2 -0
- package/lib/vite.js +101 -0
- package/mail/comment-moderation.html +27 -0
- package/mail/comment-moderation.txt +13 -0
- package/mail/comment-reply.html +28 -0
- package/mail/comment-reply.txt +14 -0
- package/mail/invitation.html +25 -0
- package/mail/invitation.txt +11 -0
- package/mail/member-magic-link.html +23 -0
- package/mail/member-magic-link.txt +10 -0
- package/mail/newsletter.html +26 -0
- package/mail/newsletter.txt +13 -0
- package/mail/password-reset.html +26 -0
- package/mail/password-reset.txt +10 -0
- package/mail/verify-email.html +25 -0
- package/mail/verify-email.txt +8 -0
- package/package.json +85 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AuthorProfile, User as UserType } from '../types/index.ts';
|
|
2
|
+
interface CreateUserData {
|
|
3
|
+
name: string;
|
|
4
|
+
email: string;
|
|
5
|
+
password: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
slug?: string;
|
|
8
|
+
email_verified?: number;
|
|
9
|
+
email_verified_at?: string | null;
|
|
10
|
+
}
|
|
11
|
+
interface UpdateUserData {
|
|
12
|
+
name?: string;
|
|
13
|
+
email?: string;
|
|
14
|
+
password?: string;
|
|
15
|
+
role?: string;
|
|
16
|
+
slug?: string;
|
|
17
|
+
bio?: string | null;
|
|
18
|
+
website?: string | null;
|
|
19
|
+
avatar_id?: number | null;
|
|
20
|
+
email_verified?: number;
|
|
21
|
+
email_verified_at?: string | null;
|
|
22
|
+
}
|
|
23
|
+
export declare const User: {
|
|
24
|
+
all(): Promise<UserType[]>;
|
|
25
|
+
find(id: number): Promise<UserType | undefined>;
|
|
26
|
+
findByEmail(email: string): Promise<UserType | undefined>;
|
|
27
|
+
count(): Promise<number>;
|
|
28
|
+
create(data: CreateUserData): Promise<UserType>;
|
|
29
|
+
update(id: number, data: UpdateUserData): Promise<UserType>;
|
|
30
|
+
delete(id: number): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* One author profile, with the avatar resolved to a URL.
|
|
33
|
+
*
|
|
34
|
+
* Never returns the password or the address: this is the shape that ends up
|
|
35
|
+
* on a byline, and a byline is public even when the page it sits on is not.
|
|
36
|
+
*/
|
|
37
|
+
profile(id: number): Promise<AuthorProfile | undefined>;
|
|
38
|
+
/** One author profile, by archive slug. */
|
|
39
|
+
profileBySlug(slug: string): Promise<AuthorProfile | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Everyone a post can be attributed to.
|
|
42
|
+
*
|
|
43
|
+
* Filtered by capability rather than by a list of role names, so a role added
|
|
44
|
+
* to the framework appears here without this query being edited — and a
|
|
45
|
+
* subscriber, who cannot write, never shows up in the editor's author menu.
|
|
46
|
+
*/
|
|
47
|
+
authors(): Promise<AuthorProfile[]>;
|
|
48
|
+
};
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { getDb, query } from '@basicbenframework/core/db';
|
|
2
|
+
import { DEFAULT_ROLE, capabilitiesFor } from '@basicbenframework/core/auth/permissions';
|
|
3
|
+
import { getStorage } from '@basicbenframework/core/storage';
|
|
4
|
+
import { uniqueSlug } from "./derive.js";
|
|
5
|
+
// Columns update() is allowed to write. Without this, passing req.body straight
|
|
6
|
+
// through would let a caller set any column, including role.
|
|
7
|
+
const UPDATABLE = [
|
|
8
|
+
'name', 'email', 'password', 'role', 'email_verified', 'email_verified_at',
|
|
9
|
+
// The author profile. `slug` is here because an author may want to choose
|
|
10
|
+
// their own archive URL; update() re-uniquifies whatever arrives.
|
|
11
|
+
'slug', 'bio', 'website', 'avatar_id'
|
|
12
|
+
];
|
|
13
|
+
/** The profile joined to its avatar. Every author read goes through this. */
|
|
14
|
+
const PROFILE_SELECT = `
|
|
15
|
+
SELECT users.id, users.name, users.slug, users.bio, users.website,
|
|
16
|
+
users.role, users.created_at, media.path AS avatar_path
|
|
17
|
+
FROM users
|
|
18
|
+
LEFT JOIN media ON media.id = users.avatar_id
|
|
19
|
+
`;
|
|
20
|
+
export const User = {
|
|
21
|
+
async all() {
|
|
22
|
+
const db = await getDb();
|
|
23
|
+
return db.all('SELECT * FROM users');
|
|
24
|
+
},
|
|
25
|
+
async find(id) {
|
|
26
|
+
const db = await getDb();
|
|
27
|
+
return db.get('SELECT * FROM users WHERE id = ?', [id]);
|
|
28
|
+
},
|
|
29
|
+
async findByEmail(email) {
|
|
30
|
+
const db = await getDb();
|
|
31
|
+
return db.get('SELECT * FROM users WHERE email = ?', [email]);
|
|
32
|
+
},
|
|
33
|
+
async count() {
|
|
34
|
+
const db = await getDb();
|
|
35
|
+
const row = await db.get('SELECT COUNT(*) as count FROM users');
|
|
36
|
+
return Number(row?.count ?? 0);
|
|
37
|
+
},
|
|
38
|
+
async create(data) {
|
|
39
|
+
const role = data.role ?? DEFAULT_ROLE;
|
|
40
|
+
// Every account is a potential author, so every account gets an archive
|
|
41
|
+
// URL at registration rather than the first time someone edits a profile.
|
|
42
|
+
// Two people with the same name get `jane-doe` and `jane-doe-2`.
|
|
43
|
+
const slug = await uniqueSlug('users', data.slug || data.name, { fallback: 'author' });
|
|
44
|
+
// Goes through the query builder so Postgres gets a RETURNING clause and
|
|
45
|
+
// the new id comes back — a raw INSERT yields a null id there.
|
|
46
|
+
const users = await query('users');
|
|
47
|
+
const result = await users.insert({ ...data, role, slug });
|
|
48
|
+
return {
|
|
49
|
+
id: result.lastInsertRowid,
|
|
50
|
+
...data,
|
|
51
|
+
role,
|
|
52
|
+
slug,
|
|
53
|
+
created_at: new Date().toISOString()
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
async update(id, data) {
|
|
57
|
+
const db = await getDb();
|
|
58
|
+
// A chosen slug is still made unique. `users.slug` is uniquely indexed, so
|
|
59
|
+
// the alternative to renaming a clash is a failed save halfway through
|
|
60
|
+
// someone editing their profile.
|
|
61
|
+
if (typeof data.slug === 'string') {
|
|
62
|
+
data = { ...data, slug: await uniqueSlug('users', data.slug, { excludeId: id, fallback: 'author' }) };
|
|
63
|
+
}
|
|
64
|
+
const entries = Object.entries(data).filter(([k]) => UPDATABLE.includes(k));
|
|
65
|
+
if (entries.length === 0) {
|
|
66
|
+
return this.find(id);
|
|
67
|
+
}
|
|
68
|
+
const fields = entries.map(([k]) => `${k} = ?`).join(', ');
|
|
69
|
+
await db.run(`UPDATE users SET ${fields} WHERE id = ?`, [...entries.map(([, v]) => v), id]);
|
|
70
|
+
return this.find(id);
|
|
71
|
+
},
|
|
72
|
+
async delete(id) {
|
|
73
|
+
const db = await getDb();
|
|
74
|
+
await db.run('DELETE FROM users WHERE id = ?', [id]);
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* One author profile, with the avatar resolved to a URL.
|
|
78
|
+
*
|
|
79
|
+
* Never returns the password or the address: this is the shape that ends up
|
|
80
|
+
* on a byline, and a byline is public even when the page it sits on is not.
|
|
81
|
+
*/
|
|
82
|
+
async profile(id) {
|
|
83
|
+
const db = await getDb();
|
|
84
|
+
const row = (await db.get(`${PROFILE_SELECT} WHERE users.id = ?`, [id]));
|
|
85
|
+
return row ? (await withAvatars([row]))[0] : undefined;
|
|
86
|
+
},
|
|
87
|
+
/** One author profile, by archive slug. */
|
|
88
|
+
async profileBySlug(slug) {
|
|
89
|
+
const db = await getDb();
|
|
90
|
+
const row = (await db.get(`${PROFILE_SELECT} WHERE users.slug = ?`, [slug]));
|
|
91
|
+
return row ? (await withAvatars([row]))[0] : undefined;
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* Everyone a post can be attributed to.
|
|
95
|
+
*
|
|
96
|
+
* Filtered by capability rather than by a list of role names, so a role added
|
|
97
|
+
* to the framework appears here without this query being edited — and a
|
|
98
|
+
* subscriber, who cannot write, never shows up in the editor's author menu.
|
|
99
|
+
*/
|
|
100
|
+
async authors() {
|
|
101
|
+
const db = await getDb();
|
|
102
|
+
const rows = (await db.all(`${PROFILE_SELECT} ORDER BY users.name ASC`));
|
|
103
|
+
const canWrite = rows.filter((row) => {
|
|
104
|
+
const held = capabilitiesFor(row.role);
|
|
105
|
+
return held.includes('*') || held.includes('post.create');
|
|
106
|
+
});
|
|
107
|
+
return withAvatars(canWrite);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Resolve each avatar to a URL.
|
|
112
|
+
*
|
|
113
|
+
* `avatar_id` is a foreign key into `media`; the join supplies the storage key
|
|
114
|
+
* and this turns it into something a browser can load. Resolved on read rather
|
|
115
|
+
* than stored so that moving buckets does not mean rewriting every row — the
|
|
116
|
+
* same reason posts resolve their featured image here rather than in the table.
|
|
117
|
+
*/
|
|
118
|
+
async function withAvatars(rows) {
|
|
119
|
+
const storage = rows.some((row) => row.avatar_path) ? await getStorage() : null;
|
|
120
|
+
return rows.map((row) => ({
|
|
121
|
+
id: row.id,
|
|
122
|
+
name: row.name,
|
|
123
|
+
slug: row.slug,
|
|
124
|
+
bio: row.bio,
|
|
125
|
+
website: row.website,
|
|
126
|
+
avatar_url: row.avatar_path && storage ? storage.publicUrl(row.avatar_path) : null
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fields an author should not have to fill in.
|
|
3
|
+
*
|
|
4
|
+
* A slug and an excerpt are derivable from a title and a body, and asking for
|
|
5
|
+
* them by hand produces exactly two outcomes: a post with no slug (so its URL
|
|
6
|
+
* is an id) and a listing with no summary (so it shows the first paragraph of
|
|
7
|
+
* raw Markdown, hashes and all). Every CMS people arrive from fills both in and
|
|
8
|
+
* lets you override them, so this does too.
|
|
9
|
+
*
|
|
10
|
+
* Derivation happens on write rather than on read. A slug computed per request
|
|
11
|
+
* is not a permalink — it would follow the title around, breaking every link to
|
|
12
|
+
* the post the first time someone fixed a typo in a headline.
|
|
13
|
+
*/
|
|
14
|
+
/** Tables with a `slug` column. Named as a union so no caller can pass SQL. */
|
|
15
|
+
export type Sluggable = 'posts' | 'pages' | 'users';
|
|
16
|
+
/**
|
|
17
|
+
* A slug for this table that nothing else is using.
|
|
18
|
+
*
|
|
19
|
+
* `posts.slug` and `pages.slug` are uniquely indexed, so a collision is not a
|
|
20
|
+
* cosmetic problem — it is a failed write in the middle of someone's save. Two
|
|
21
|
+
* posts called "Hello world" is ordinary, so the second becomes `hello-world-2`
|
|
22
|
+
* the way WordPress numbers them, rather than being refused.
|
|
23
|
+
*
|
|
24
|
+
* @param table - which table the slug has to be unique within
|
|
25
|
+
* @param desired - a slug or the text to make one from; slugified either way
|
|
26
|
+
* @param options.excludeId - the row being updated, so it does not collide with itself
|
|
27
|
+
* @param options.fallback - used when `desired` slugifies to nothing at all
|
|
28
|
+
*/
|
|
29
|
+
export declare function uniqueSlug(table: Sluggable, desired: string, options?: {
|
|
30
|
+
excludeId?: number;
|
|
31
|
+
fallback?: string;
|
|
32
|
+
}): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* A plain-text summary of a body of Markdown.
|
|
35
|
+
*
|
|
36
|
+
* Thin on purpose: the framework already renders and strips, and a second
|
|
37
|
+
* implementation here would be a second answer to "what is a summary" — one of
|
|
38
|
+
* which would end mid-word.
|
|
39
|
+
*/
|
|
40
|
+
export declare function summarise(content: string | undefined | null, length?: number): string;
|
|
41
|
+
/**
|
|
42
|
+
* The slug and excerpt to store, given what the author actually filled in.
|
|
43
|
+
*
|
|
44
|
+
* Three cases, and they are different on purpose:
|
|
45
|
+
*
|
|
46
|
+
* - **Typed**: theirs. Slugified, made unique, otherwise untouched.
|
|
47
|
+
* - **Blank**: derive one. An empty box is how you ask for a fresh slug after
|
|
48
|
+
* retitling, and how you go back to an automatic summary.
|
|
49
|
+
* - **Absent**: leave what is there. A client that patches a title has not
|
|
50
|
+
* said anything about the slug, and a permalink that moved because someone
|
|
51
|
+
* fixed a typo in a headline is a broken link on every site that linked to
|
|
52
|
+
* it.
|
|
53
|
+
*
|
|
54
|
+
* `existing*` are what make the third case possible; without them "absent" and
|
|
55
|
+
* "blank" collapse into each other.
|
|
56
|
+
*/
|
|
57
|
+
export declare function derivedFields(table: Sluggable, input: {
|
|
58
|
+
title?: string;
|
|
59
|
+
content?: string;
|
|
60
|
+
slug?: string;
|
|
61
|
+
excerpt?: string;
|
|
62
|
+
}, options?: {
|
|
63
|
+
excludeId?: number;
|
|
64
|
+
existingSlug?: string | null;
|
|
65
|
+
existingExcerpt?: string | null;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
slug: string;
|
|
68
|
+
excerpt: string;
|
|
69
|
+
}>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fields an author should not have to fill in.
|
|
3
|
+
*
|
|
4
|
+
* A slug and an excerpt are derivable from a title and a body, and asking for
|
|
5
|
+
* them by hand produces exactly two outcomes: a post with no slug (so its URL
|
|
6
|
+
* is an id) and a listing with no summary (so it shows the first paragraph of
|
|
7
|
+
* raw Markdown, hashes and all). Every CMS people arrive from fills both in and
|
|
8
|
+
* lets you override them, so this does too.
|
|
9
|
+
*
|
|
10
|
+
* Derivation happens on write rather than on read. A slug computed per request
|
|
11
|
+
* is not a permalink — it would follow the title around, breaking every link to
|
|
12
|
+
* the post the first time someone fixed a typo in a headline.
|
|
13
|
+
*/
|
|
14
|
+
import { getDb } from '@basicbenframework/core/db';
|
|
15
|
+
import { slugify, excerpt } from '@basicbenframework/core/content';
|
|
16
|
+
/**
|
|
17
|
+
* A slug for this table that nothing else is using.
|
|
18
|
+
*
|
|
19
|
+
* `posts.slug` and `pages.slug` are uniquely indexed, so a collision is not a
|
|
20
|
+
* cosmetic problem — it is a failed write in the middle of someone's save. Two
|
|
21
|
+
* posts called "Hello world" is ordinary, so the second becomes `hello-world-2`
|
|
22
|
+
* the way WordPress numbers them, rather than being refused.
|
|
23
|
+
*
|
|
24
|
+
* @param table - which table the slug has to be unique within
|
|
25
|
+
* @param desired - a slug or the text to make one from; slugified either way
|
|
26
|
+
* @param options.excludeId - the row being updated, so it does not collide with itself
|
|
27
|
+
* @param options.fallback - used when `desired` slugifies to nothing at all
|
|
28
|
+
*/
|
|
29
|
+
export async function uniqueSlug(table, desired, options = {}) {
|
|
30
|
+
const db = await getDb();
|
|
31
|
+
const base = slugify(desired || '') || options.fallback || table.replace(/s$/, '');
|
|
32
|
+
const sql = options.excludeId
|
|
33
|
+
? `SELECT id FROM ${table} WHERE slug = ? AND id != ?`
|
|
34
|
+
: `SELECT id FROM ${table} WHERE slug = ?`;
|
|
35
|
+
let slug = base;
|
|
36
|
+
let suffix = 2;
|
|
37
|
+
// Bounded by how many rows already hold this base, so it terminates.
|
|
38
|
+
while (await db.get(sql, options.excludeId ? [slug, options.excludeId] : [slug])) {
|
|
39
|
+
slug = `${base}-${suffix++}`;
|
|
40
|
+
}
|
|
41
|
+
return slug;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A plain-text summary of a body of Markdown.
|
|
45
|
+
*
|
|
46
|
+
* Thin on purpose: the framework already renders and strips, and a second
|
|
47
|
+
* implementation here would be a second answer to "what is a summary" — one of
|
|
48
|
+
* which would end mid-word.
|
|
49
|
+
*/
|
|
50
|
+
export function summarise(content, length = 200) {
|
|
51
|
+
return excerpt(content || '', length);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The slug and excerpt to store, given what the author actually filled in.
|
|
55
|
+
*
|
|
56
|
+
* Three cases, and they are different on purpose:
|
|
57
|
+
*
|
|
58
|
+
* - **Typed**: theirs. Slugified, made unique, otherwise untouched.
|
|
59
|
+
* - **Blank**: derive one. An empty box is how you ask for a fresh slug after
|
|
60
|
+
* retitling, and how you go back to an automatic summary.
|
|
61
|
+
* - **Absent**: leave what is there. A client that patches a title has not
|
|
62
|
+
* said anything about the slug, and a permalink that moved because someone
|
|
63
|
+
* fixed a typo in a headline is a broken link on every site that linked to
|
|
64
|
+
* it.
|
|
65
|
+
*
|
|
66
|
+
* `existing*` are what make the third case possible; without them "absent" and
|
|
67
|
+
* "blank" collapse into each other.
|
|
68
|
+
*/
|
|
69
|
+
export async function derivedFields(table, input, options = {}) {
|
|
70
|
+
const slugMentioned = input.slug !== undefined;
|
|
71
|
+
const typed = (input.slug || '').trim();
|
|
72
|
+
const slug = !slugMentioned && options.existingSlug
|
|
73
|
+
? options.existingSlug
|
|
74
|
+
: await uniqueSlug(table, typed || input.title || '', { excludeId: options.excludeId });
|
|
75
|
+
const excerptMentioned = input.excerpt !== undefined;
|
|
76
|
+
const typedExcerpt = (input.excerpt || '').trim();
|
|
77
|
+
const summary = excerptMentioned
|
|
78
|
+
? typedExcerpt || summarise(input.content)
|
|
79
|
+
: options.existingExcerpt ?? summarise(input.content);
|
|
80
|
+
return { slug, excerpt: summary };
|
|
81
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many rows a listing may ask for at once.
|
|
3
|
+
*
|
|
4
|
+
* The admin tables were unpaginated: every post and every page came back on
|
|
5
|
+
* every load, so the query, the JSON and the DOM all grew without limit. A
|
|
6
|
+
* clamp rather than a default alone, because the page size arrives from the
|
|
7
|
+
* query string and an unbounded one hands any caller a way to ask for the
|
|
8
|
+
* whole table.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MAX_PER_PAGE = 100;
|
|
11
|
+
export declare const DEFAULT_PER_PAGE = 20;
|
|
12
|
+
/**
|
|
13
|
+
* Turn `page` and `per_page` query values into a safe window.
|
|
14
|
+
*
|
|
15
|
+
* Anything unparseable, negative or absurd collapses to the default rather
|
|
16
|
+
* than erroring: a listing is not the place to argue about input, and a
|
|
17
|
+
* malformed page number should show page one, not a 422.
|
|
18
|
+
*/
|
|
19
|
+
export declare function paginationFrom(query?: Record<string, string>): {
|
|
20
|
+
page: number;
|
|
21
|
+
perPage: number;
|
|
22
|
+
offset: number;
|
|
23
|
+
};
|
|
24
|
+
/** The envelope a paginated listing returns, matching /api/v1's shape. */
|
|
25
|
+
export declare function meta(page: number, perPage: number, total: number): {
|
|
26
|
+
page: number;
|
|
27
|
+
per_page: number;
|
|
28
|
+
total: number;
|
|
29
|
+
total_pages: number;
|
|
30
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many rows a listing may ask for at once.
|
|
3
|
+
*
|
|
4
|
+
* The admin tables were unpaginated: every post and every page came back on
|
|
5
|
+
* every load, so the query, the JSON and the DOM all grew without limit. A
|
|
6
|
+
* clamp rather than a default alone, because the page size arrives from the
|
|
7
|
+
* query string and an unbounded one hands any caller a way to ask for the
|
|
8
|
+
* whole table.
|
|
9
|
+
*/
|
|
10
|
+
export const MAX_PER_PAGE = 100;
|
|
11
|
+
export const DEFAULT_PER_PAGE = 20;
|
|
12
|
+
/**
|
|
13
|
+
* Turn `page` and `per_page` query values into a safe window.
|
|
14
|
+
*
|
|
15
|
+
* Anything unparseable, negative or absurd collapses to the default rather
|
|
16
|
+
* than erroring: a listing is not the place to argue about input, and a
|
|
17
|
+
* malformed page number should show page one, not a 422.
|
|
18
|
+
*/
|
|
19
|
+
export function paginationFrom(query = {}) {
|
|
20
|
+
const page = Math.max(1, Number.parseInt(query.page ?? '', 10) || 1);
|
|
21
|
+
const requested = Number.parseInt(query.per_page ?? '', 10) || DEFAULT_PER_PAGE;
|
|
22
|
+
const perPage = Math.min(MAX_PER_PAGE, Math.max(1, requested));
|
|
23
|
+
return { page, perPage, offset: (page - 1) * perPage };
|
|
24
|
+
}
|
|
25
|
+
/** The envelope a paginated listing returns, matching /api/v1's shape. */
|
|
26
|
+
export function meta(page, perPage, total) {
|
|
27
|
+
return {
|
|
28
|
+
page,
|
|
29
|
+
per_page: perPage,
|
|
30
|
+
total,
|
|
31
|
+
// Computed here so no caller has to: total / per_page is the sum people
|
|
32
|
+
// get wrong, and an off-by-one means a paging client either misses the
|
|
33
|
+
// last page or loops forever on an empty one.
|
|
34
|
+
total_pages: Math.max(1, Math.ceil(total / perPage))
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a post is on the public site.
|
|
3
|
+
*
|
|
4
|
+
* Published, not in the trash, and its publish time has arrived. Every public
|
|
5
|
+
* read — the content API, the feeds, the sitemap, taxonomy and author counts,
|
|
6
|
+
* comments — goes through this one fragment, because a second copy of the rule
|
|
7
|
+
* is the copy that forgets the schedule.
|
|
8
|
+
*
|
|
9
|
+
* The cutoff is inlined as a literal rather than bound, so the fragment drops
|
|
10
|
+
* into any query without disturbing its placeholders. It is safe to inline: it
|
|
11
|
+
* is always our own `toISOString()`, never input. ISO-8601 UTC strings compare
|
|
12
|
+
* correctly as text on SQLite and cast to a timestamp on Postgres.
|
|
13
|
+
*
|
|
14
|
+
* Scheduling needs no cron: a scheduled post simply starts matching when its
|
|
15
|
+
* time comes. What does need a tick is telling webhooks — see `publishDue()` in
|
|
16
|
+
* `src/hooks.ts`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function livePost(alias?: string): string;
|
|
19
|
+
/** Normalise a date to the stored form, or null. Throws on nonsense. */
|
|
20
|
+
export declare function toStoredTimestamp(value: unknown): string | null;
|
|
21
|
+
/** The editorial states a post can be in. Scheduled is published-in-the-future. */
|
|
22
|
+
export declare const POST_STATUSES: readonly ["draft", "pending", "published"];
|
|
23
|
+
export type PostStatus = (typeof POST_STATUSES)[number];
|
|
24
|
+
/**
|
|
25
|
+
* Read a stored timestamp as UTC.
|
|
26
|
+
*
|
|
27
|
+
* SQLite's CURRENT_TIMESTAMP writes `YYYY-MM-DD HH:MM:SS` with no zone, and
|
|
28
|
+
* `new Date()` reads that as *local* time — off by the server's offset. Rows
|
|
29
|
+
* written by the app carry a `Z`; this makes the two agree.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseStoredTimestamp(value: string | Date | null | undefined): number;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a post is on the public site.
|
|
3
|
+
*
|
|
4
|
+
* Published, not in the trash, and its publish time has arrived. Every public
|
|
5
|
+
* read — the content API, the feeds, the sitemap, taxonomy and author counts,
|
|
6
|
+
* comments — goes through this one fragment, because a second copy of the rule
|
|
7
|
+
* is the copy that forgets the schedule.
|
|
8
|
+
*
|
|
9
|
+
* The cutoff is inlined as a literal rather than bound, so the fragment drops
|
|
10
|
+
* into any query without disturbing its placeholders. It is safe to inline: it
|
|
11
|
+
* is always our own `toISOString()`, never input. ISO-8601 UTC strings compare
|
|
12
|
+
* correctly as text on SQLite and cast to a timestamp on Postgres.
|
|
13
|
+
*
|
|
14
|
+
* Scheduling needs no cron: a scheduled post simply starts matching when its
|
|
15
|
+
* time comes. What does need a tick is telling webhooks — see `publishDue()` in
|
|
16
|
+
* `src/hooks.ts`.
|
|
17
|
+
*/
|
|
18
|
+
export function livePost(alias = 'posts') {
|
|
19
|
+
const now = new Date().toISOString();
|
|
20
|
+
return `(${alias}.published = 1 AND ${alias}.deleted_at IS NULL AND (${alias}.publish_at IS NULL OR ${alias}.publish_at <= '${now}'))`;
|
|
21
|
+
}
|
|
22
|
+
/** Normalise a date to the stored form, or null. Throws on nonsense. */
|
|
23
|
+
export function toStoredTimestamp(value) {
|
|
24
|
+
if (value === null || value === undefined || value === '')
|
|
25
|
+
return null;
|
|
26
|
+
const date = new Date(value);
|
|
27
|
+
if (Number.isNaN(date.getTime()))
|
|
28
|
+
throw new RangeError('Invalid date');
|
|
29
|
+
return date.toISOString();
|
|
30
|
+
}
|
|
31
|
+
/** The editorial states a post can be in. Scheduled is published-in-the-future. */
|
|
32
|
+
export const POST_STATUSES = ['draft', 'pending', 'published'];
|
|
33
|
+
/**
|
|
34
|
+
* Read a stored timestamp as UTC.
|
|
35
|
+
*
|
|
36
|
+
* SQLite's CURRENT_TIMESTAMP writes `YYYY-MM-DD HH:MM:SS` with no zone, and
|
|
37
|
+
* `new Date()` reads that as *local* time — off by the server's offset. Rows
|
|
38
|
+
* written by the app carry a `Z`; this makes the two agree.
|
|
39
|
+
*/
|
|
40
|
+
export function parseStoredTimestamp(value) {
|
|
41
|
+
if (!value)
|
|
42
|
+
return NaN;
|
|
43
|
+
if (value instanceof Date)
|
|
44
|
+
return value.getTime();
|
|
45
|
+
const bare = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d+)?$/.test(value);
|
|
46
|
+
return new Date(bare ? `${value.replace(' ', 'T')}Z` : value).getTime();
|
|
47
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createClientApp } from '@basicbenframework/core/client';
|
|
3
|
+
import { AppLayout } from "../client/layouts/AppLayout.js";
|
|
4
|
+
import { AuthLayout } from "../client/layouts/AuthLayout.js";
|
|
5
|
+
import { DocsLayout } from "../client/layouts/DocsLayout.js";
|
|
6
|
+
import { Home } from "../client/pages/Home.js";
|
|
7
|
+
import { Auth } from "../client/pages/Auth.js";
|
|
8
|
+
import { AcceptInvite } from "../client/pages/AcceptInvite.js";
|
|
9
|
+
import { ForgotPassword } from "../client/pages/ForgotPassword.js";
|
|
10
|
+
import { ResetPassword } from "../client/pages/ResetPassword.js";
|
|
11
|
+
import { Feed } from "../client/pages/Feed.js";
|
|
12
|
+
import { FeedPost } from "../client/pages/FeedPost.js";
|
|
13
|
+
import { Posts } from "../client/pages/Posts.js";
|
|
14
|
+
import { PostForm } from "../client/pages/PostForm.js";
|
|
15
|
+
import { Profile } from "../client/pages/Profile.js";
|
|
16
|
+
import { GettingStarted } from "../client/pages/GettingStarted.js";
|
|
17
|
+
import { Database } from "../client/pages/Database.js";
|
|
18
|
+
import { Routing } from "../client/pages/Routing.js";
|
|
19
|
+
import { Authentication } from "../client/pages/Authentication.js";
|
|
20
|
+
import { Validation } from "../client/pages/Validation.js";
|
|
21
|
+
import { Content } from "../client/pages/Content.js";
|
|
22
|
+
import { Storage } from "../client/pages/Storage.js";
|
|
23
|
+
import { Extending } from "../client/pages/Extending.js";
|
|
24
|
+
import { Headless } from "../client/pages/Headless.js";
|
|
25
|
+
import { Testing } from "../client/pages/Testing.js";
|
|
26
|
+
// Admin pages
|
|
27
|
+
import AdminDashboard from "../client/pages/admin/Dashboard.js";
|
|
28
|
+
import AdminPosts from "../client/pages/admin/Posts.js";
|
|
29
|
+
import AdminContentTypes from "../client/pages/admin/ContentTypes.js";
|
|
30
|
+
import AdminTaxonomies from "../client/pages/admin/Taxonomies.js";
|
|
31
|
+
import AdminPostEditor from "../client/pages/admin/PostEditor.js";
|
|
32
|
+
import AdminPages from "../client/pages/admin/Pages.js";
|
|
33
|
+
import AdminCategories from "../client/pages/admin/Categories.js";
|
|
34
|
+
import AdminTags from "../client/pages/admin/Tags.js";
|
|
35
|
+
import AdminComments from "../client/pages/admin/Comments.js";
|
|
36
|
+
import AdminMedia from "../client/pages/admin/Media.js";
|
|
37
|
+
import AdminTokens from "../client/pages/admin/Tokens.js";
|
|
38
|
+
import AdminUsers from "../client/pages/admin/Users.js";
|
|
39
|
+
import AdminSettings from "../client/pages/admin/Settings.js";
|
|
40
|
+
import AdminNavigation from "../client/pages/admin/Navigation.js";
|
|
41
|
+
import AdminRedirects from "../client/pages/admin/Redirects.js";
|
|
42
|
+
import AdminSnippets from "../client/pages/admin/Snippets.js";
|
|
43
|
+
import AdminTools from "../client/pages/admin/Tools.js";
|
|
44
|
+
import AdminHealth from "../client/pages/admin/Health.js";
|
|
45
|
+
import { featurePages } from "../client/host/index.js";
|
|
46
|
+
// Admin layout wrapper (no default layout)
|
|
47
|
+
const NoLayout = ({ children }) => _jsx(_Fragment, { children: children });
|
|
48
|
+
// Features' admin screens were registered by src/main.tsx before it imported
|
|
49
|
+
// this module, so featurePages() below already lists them.
|
|
50
|
+
/**
|
|
51
|
+
* The public site: the marketing page, the built-in blog, and the framework
|
|
52
|
+
* documentation. Present unless DISABLE_PUBLIC_SITE is set, which is how you
|
|
53
|
+
* run this purely as a backend for something else — the admin and the content
|
|
54
|
+
* API, with nothing for a visitor to land on.
|
|
55
|
+
*
|
|
56
|
+
* `__DISABLE_PUBLIC_SITE__` is a build-time constant, so these routes and the
|
|
57
|
+
* pages they name are dropped from the bundle rather than merely unreachable.
|
|
58
|
+
*/
|
|
59
|
+
const publicRoutes = __DISABLE_PUBLIC_SITE__
|
|
60
|
+
? {}
|
|
61
|
+
: {
|
|
62
|
+
'/': Home,
|
|
63
|
+
'/feed': Feed,
|
|
64
|
+
'/feed/:id': FeedPost,
|
|
65
|
+
'/docs': { component: GettingStarted, layout: DocsLayout },
|
|
66
|
+
'/docs/routing': { component: Routing, layout: DocsLayout },
|
|
67
|
+
'/docs/database': { component: Database, layout: DocsLayout },
|
|
68
|
+
'/docs/authentication': { component: Authentication, layout: DocsLayout },
|
|
69
|
+
'/docs/validation': { component: Validation, layout: DocsLayout },
|
|
70
|
+
'/docs/content': { component: Content, layout: DocsLayout },
|
|
71
|
+
'/docs/storage': { component: Storage, layout: DocsLayout },
|
|
72
|
+
'/docs/extending': { component: Extending, layout: DocsLayout },
|
|
73
|
+
'/docs/headless': { component: Headless, layout: DocsLayout },
|
|
74
|
+
'/docs/testing': { component: Testing, layout: DocsLayout }
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Signing in is always reachable; signing *up* is not.
|
|
78
|
+
*
|
|
79
|
+
* With DISABLE_REGISTRATION the route goes, so the form cannot be reached by
|
|
80
|
+
* typing the URL either. The server refuses the request regardless — see
|
|
81
|
+
* AuthController.register — because a missing route is presentation and this
|
|
82
|
+
* needs to be a control.
|
|
83
|
+
*/
|
|
84
|
+
const authRoutes = {
|
|
85
|
+
'/login': { component: Auth, layout: AuthLayout, guest: true },
|
|
86
|
+
// Getting back in, and getting in for the first time by invitation. Outside
|
|
87
|
+
// both build flags on purpose: a closed site with no public pages still has
|
|
88
|
+
// people who forget passwords, and an invitation is how a closed site adds
|
|
89
|
+
// anyone. Only the request form is guest-only — a reset or an invitation
|
|
90
|
+
// link may well be opened in a browser already signed in as someone else.
|
|
91
|
+
'/forgot-password': { component: ForgotPassword, layout: AuthLayout, guest: true },
|
|
92
|
+
'/reset-password/:token': { component: ResetPassword, layout: AuthLayout },
|
|
93
|
+
'/invite/:token': { component: AcceptInvite, layout: AuthLayout },
|
|
94
|
+
...(__DISABLE_REGISTRATION__
|
|
95
|
+
? {}
|
|
96
|
+
: { '/register': { component: Auth, layout: AuthLayout, guest: true } })
|
|
97
|
+
};
|
|
98
|
+
export default createClientApp({
|
|
99
|
+
layout: AppLayout,
|
|
100
|
+
routes: {
|
|
101
|
+
...publicRoutes,
|
|
102
|
+
...authRoutes,
|
|
103
|
+
// With no public site, `/` would otherwise 404 for someone who simply
|
|
104
|
+
// opened the domain, so it points at the admin instead.
|
|
105
|
+
//
|
|
106
|
+
// `auth: true` and not `guest: true`, which is what this was first and was
|
|
107
|
+
// wrong: the router sends a signed-in visitor away from a guest route by
|
|
108
|
+
// navigating to `/`, so making `/` itself a guest route looped it against
|
|
109
|
+
// itself and rendered nothing. A blank page, only once you were logged in.
|
|
110
|
+
//
|
|
111
|
+
// As an auth route it works from both sides — the same guard sends a
|
|
112
|
+
// signed-out visitor to /login, and a signed-in one lands where they were
|
|
113
|
+
// going anyway.
|
|
114
|
+
...(__DISABLE_PUBLIC_SITE__
|
|
115
|
+
? { '/': { component: AdminDashboard, layout: NoLayout, auth: true } }
|
|
116
|
+
: {}),
|
|
117
|
+
'/posts': { component: Posts, auth: true },
|
|
118
|
+
'/posts/new': { component: PostForm, auth: true },
|
|
119
|
+
'/posts/:id/edit': { component: PostForm, auth: true },
|
|
120
|
+
'/profile': { component: Profile, auth: true },
|
|
121
|
+
// Admin routes (use their own layout)
|
|
122
|
+
'/admin': { component: AdminDashboard, layout: NoLayout, auth: true },
|
|
123
|
+
'/admin/posts': { component: AdminPosts, layout: NoLayout, auth: true },
|
|
124
|
+
'/admin/content/:type': { component: AdminPosts, layout: NoLayout, auth: true },
|
|
125
|
+
'/admin/content-types': { component: AdminContentTypes, layout: NoLayout, auth: true },
|
|
126
|
+
'/admin/taxonomies': { component: AdminTaxonomies, layout: NoLayout, auth: true },
|
|
127
|
+
'/admin/posts/new': { component: AdminPostEditor, layout: NoLayout, auth: true },
|
|
128
|
+
'/admin/posts/:id/edit': { component: AdminPostEditor, layout: NoLayout, auth: true },
|
|
129
|
+
'/admin/pages': { component: AdminPages, layout: NoLayout, auth: true },
|
|
130
|
+
'/admin/pages/new': { component: AdminPostEditor, layout: NoLayout, auth: true },
|
|
131
|
+
'/admin/pages/:id/edit': { component: AdminPostEditor, layout: NoLayout, auth: true },
|
|
132
|
+
'/admin/categories': { component: AdminCategories, layout: NoLayout, auth: true },
|
|
133
|
+
'/admin/tags': { component: AdminTags, layout: NoLayout, auth: true },
|
|
134
|
+
'/admin/comments': { component: AdminComments, layout: NoLayout, auth: true },
|
|
135
|
+
'/admin/media': { component: AdminMedia, layout: NoLayout, auth: true },
|
|
136
|
+
'/admin/tokens': { component: AdminTokens, layout: NoLayout, auth: true },
|
|
137
|
+
'/admin/settings': { component: AdminSettings, layout: NoLayout, auth: true },
|
|
138
|
+
'/admin/navigation': { component: AdminNavigation, layout: NoLayout, auth: true },
|
|
139
|
+
'/admin/redirects': { component: AdminRedirects, layout: NoLayout, auth: true },
|
|
140
|
+
'/admin/snippets': { component: AdminSnippets, layout: NoLayout, auth: true },
|
|
141
|
+
'/admin/tools': { component: AdminTools, layout: NoLayout, auth: true },
|
|
142
|
+
'/admin/health': { component: AdminHealth, layout: NoLayout, auth: true },
|
|
143
|
+
...Object.fromEntries(featurePages().map(([path, component]) => [path, { component, layout: NoLayout, auth: true }])),
|
|
144
|
+
'/admin/users': { component: AdminUsers, layout: NoLayout, auth: true },
|
|
145
|
+
}
|
|
146
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdminController } from "../../controllers/AdminController.js";
|
|
2
|
+
import { auth } from "../../middleware/auth.js";
|
|
3
|
+
import { requireCapability } from '@basicbenframework/core/auth/permissions';
|
|
4
|
+
export default (router) => {
|
|
5
|
+
// The admin UI asks the server what to render, because that is the realm
|
|
6
|
+
// listeners are registered in — a hook fired in the browser would consult an
|
|
7
|
+
// empty registry.
|
|
8
|
+
router.get('/api/admin/menu', auth, AdminController.menu);
|
|
9
|
+
router.get('/api/admin/dashboard', auth, requireCapability('post.edit'), AdminController.dashboard);
|
|
10
|
+
router.post('/api/admin/init', auth, AdminController.init);
|
|
11
|
+
};
|