@basicbenframework/cms 0.0.0-stage → 0.6.1
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,15 @@
|
|
|
1
|
+
import { TokenController } from "../../controllers/TokenController.js";
|
|
2
|
+
import { auth } from "../../middleware/auth.js";
|
|
3
|
+
import { requireSession } from "../../middleware/api-auth.js";
|
|
4
|
+
export default (router) => {
|
|
5
|
+
// Managing tokens requires a logged-in session, never a token — otherwise a
|
|
6
|
+
// leaked read-only token could mint itself a write-scoped one and scopes
|
|
7
|
+
// would mean nothing.
|
|
8
|
+
//
|
|
9
|
+
// `auth` is what enforces that today; it refuses an API token outright. The
|
|
10
|
+
// second latch is here for the day someone widens these routes to accept one,
|
|
11
|
+
// which is exactly the change that would open the escalation quietly.
|
|
12
|
+
router.get('/api/tokens', auth, requireSession, TokenController.index);
|
|
13
|
+
router.post('/api/tokens', auth, requireSession, TokenController.store);
|
|
14
|
+
router.delete('/api/tokens/:id', auth, requireSession, TokenController.destroy);
|
|
15
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface Router {
|
|
2
|
+
get: (path: string, ...handlers: Function[]) => void;
|
|
3
|
+
post: (path: string, ...handlers: Function[]) => void;
|
|
4
|
+
delete: (path: string, ...handlers: Function[]) => void;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: (router: Router) => void;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TwoFactorController } from "../../controllers/TwoFactorController.js";
|
|
2
|
+
import { auth } from "../../middleware/auth.js";
|
|
3
|
+
import { twoFactorLimit } from "../../middleware/rate-limits.js";
|
|
4
|
+
export default (router) => {
|
|
5
|
+
// Public: this is the second step of a login, so the caller has no session
|
|
6
|
+
// yet — that is the entire point of the challenge.
|
|
7
|
+
router.post('/api/auth/2fa/verify', twoFactorLimit, TwoFactorController.verify);
|
|
8
|
+
// Managing your own factors. Not gated on a capability: these are account
|
|
9
|
+
// security settings, which every signed-in user needs regardless of role.
|
|
10
|
+
router.get('/api/auth/2fa', auth, TwoFactorController.status);
|
|
11
|
+
router.post('/api/auth/2fa/totp/setup', auth, TwoFactorController.setupTotp);
|
|
12
|
+
router.post('/api/auth/2fa/totp/confirm', auth, TwoFactorController.confirmTotp);
|
|
13
|
+
router.delete('/api/auth/2fa/totp', auth, TwoFactorController.disableTotp);
|
|
14
|
+
router.post('/api/auth/2fa/recovery/rotate', auth, TwoFactorController.rotateRecoveryCodes);
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface Router {
|
|
2
|
+
get: (path: string, ...handlers: Function[]) => void;
|
|
3
|
+
post: (path: string, ...handlers: Function[]) => void;
|
|
4
|
+
put: (path: string, ...handlers: Function[]) => void;
|
|
5
|
+
delete: (path: string, ...handlers: Function[]) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: (router: Router) => void;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UserController, InvitationController } from "../../controllers/UserController.js";
|
|
2
|
+
import { auth } from "../../middleware/auth.js";
|
|
3
|
+
import { invitationLimit, tokenRedeemLimit } from "../../middleware/rate-limits.js";
|
|
4
|
+
import { requireCapability } from '@basicbenframework/core/auth/permissions';
|
|
5
|
+
export default (router) => {
|
|
6
|
+
// Every account-management route is `auth` then `user.manage`, and only an
|
|
7
|
+
// admin holds that. `auth` reads the role from the database on each request,
|
|
8
|
+
// so an admin who has just been demoted loses these routes on their next
|
|
9
|
+
// click rather than when their token expires.
|
|
10
|
+
const manage = [auth, requireCapability('user.manage')];
|
|
11
|
+
router.get('/api/users', ...manage, UserController.index);
|
|
12
|
+
// Before /api/users/:id so "invite" is never read as an id.
|
|
13
|
+
router.post('/api/users/invite', ...manage, invitationLimit, InvitationController.store);
|
|
14
|
+
router.put('/api/users/:id', ...manage, UserController.update);
|
|
15
|
+
router.post('/api/users/:id/disable', ...manage, UserController.disable);
|
|
16
|
+
router.post('/api/users/:id/enable', ...manage, UserController.enable);
|
|
17
|
+
router.delete('/api/users/:id', ...manage, UserController.destroy);
|
|
18
|
+
router.get('/api/invitations', ...manage, InvitationController.index);
|
|
19
|
+
router.delete('/api/invitations/:id', ...manage, InvitationController.destroy);
|
|
20
|
+
// Public: the person holding the link has no account yet — the link is the
|
|
21
|
+
// credential. Registered whatever DISABLE_REGISTRATION says, because on a
|
|
22
|
+
// closed site an invitation is how anyone new gets in.
|
|
23
|
+
router.get('/api/invitations/:token', InvitationController.show);
|
|
24
|
+
router.post('/api/invitations/:token/accept', tokenRedeemLimit, InvitationController.accept);
|
|
25
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface Router {
|
|
2
|
+
get: (path: string, ...handlers: Function[]) => void;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* The public content API.
|
|
6
|
+
*
|
|
7
|
+
* Every route needs `content:read` (or `media:read`), satisfied by an API token
|
|
8
|
+
* or a signed-in session — or by nothing at all, if the site has turned on
|
|
9
|
+
* public reads in settings. See `middleware/api-auth.ts`.
|
|
10
|
+
*/
|
|
11
|
+
declare const _default: (router: Router) => void;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PublicApiController } from "../../controllers/PublicApiController.js";
|
|
2
|
+
import { SettingsController } from "../../controllers/SettingsController.js";
|
|
3
|
+
import { NavigationController } from "../../controllers/NavigationController.js";
|
|
4
|
+
import { RedirectController } from "../../controllers/RedirectController.js";
|
|
5
|
+
import { ContentTypeController } from "../../controllers/ContentTypeController.js";
|
|
6
|
+
import { TaxonomyController } from "../../controllers/TaxonomyController.js";
|
|
7
|
+
import { requireScope } from "../../middleware/api-auth.js";
|
|
8
|
+
import { SCOPES } from '@basicbenframework/core/auth/api-tokens';
|
|
9
|
+
import { cacheable } from "../../middleware/cache.js";
|
|
10
|
+
import { publicApiLimit } from "../../middleware/rate-limits.js";
|
|
11
|
+
import { publishDueOpportunistically } from "../../helpers/publish-due.js";
|
|
12
|
+
import { identifyViewer } from "../../middleware/viewer.js";
|
|
13
|
+
/**
|
|
14
|
+
* The public content API.
|
|
15
|
+
*
|
|
16
|
+
* Every route needs `content:read` (or `media:read`), satisfied by an API token
|
|
17
|
+
* or a signed-in session — or by nothing at all, if the site has turned on
|
|
18
|
+
* public reads in settings. See `middleware/api-auth.ts`.
|
|
19
|
+
*/
|
|
20
|
+
export default (router) => {
|
|
21
|
+
const content = requireScope(SCOPES.CONTENT_READ);
|
|
22
|
+
const media = requireScope(SCOPES.MEDIA_READ);
|
|
23
|
+
// Post reads also announce any scheduled post whose time has come, at most
|
|
24
|
+
// once a minute — see helpers/publish-due.ts.
|
|
25
|
+
//
|
|
26
|
+
// `identifyViewer` asks the access policy who is reading (with the members
|
|
27
|
+
// feature, a member session in `X-Member-Token`), which may unlock a
|
|
28
|
+
// restricted post's body. It is separate from the `content:read`
|
|
29
|
+
// credential in `Authorization`, and `cacheable` marks any response to a
|
|
30
|
+
// request carrying the policy's header private.
|
|
31
|
+
router.get('/api/v1/posts', publicApiLimit, content, publishDueOpportunistically, identifyViewer, cacheable, PublicApiController.posts);
|
|
32
|
+
router.get('/api/v1/posts/:slug', publicApiLimit, content, publishDueOpportunistically, identifyViewer, cacheable, PublicApiController.post);
|
|
33
|
+
router.get('/api/v1/pages', publicApiLimit, content, cacheable, PublicApiController.pages);
|
|
34
|
+
router.get('/api/v1/pages/:slug', publicApiLimit, content, cacheable, PublicApiController.page);
|
|
35
|
+
// Author archives: the profile, and `/api/v1/posts?author=` for their work.
|
|
36
|
+
router.get('/api/v1/authors', publicApiLimit, content, cacheable, PublicApiController.authors);
|
|
37
|
+
router.get('/api/v1/authors/:slug', publicApiLimit, content, cacheable, PublicApiController.author);
|
|
38
|
+
router.get('/api/v1/categories', publicApiLimit, content, cacheable, PublicApiController.categories);
|
|
39
|
+
router.get('/api/v1/tags', publicApiLimit, content, cacheable, PublicApiController.tags);
|
|
40
|
+
router.get('/api/v1/media/:id', publicApiLimit, media, cacheable, PublicApiController.media);
|
|
41
|
+
// Site identity, menus and redirects: what a headless front end needs to
|
|
42
|
+
// render its chrome and answer old URLs. Same credential rule as content.
|
|
43
|
+
// (Not on PublicApiController, so the generated reference — which documents
|
|
44
|
+
// PublicContent shapes only — is unaffected until it learns these shapes.)
|
|
45
|
+
router.get('/api/v1/site', publicApiLimit, content, cacheable, SettingsController.publicSite);
|
|
46
|
+
router.get('/api/v1/navigation', publicApiLimit, content, cacheable, NavigationController.publicIndex);
|
|
47
|
+
router.get('/api/v1/redirects', publicApiLimit, content, cacheable, RedirectController.publicIndex);
|
|
48
|
+
// The content model: which public content types exist (with their custom
|
|
49
|
+
// field schemas and route bases), and the custom taxonomies beside the
|
|
50
|
+
// built-in categories and tags. `?type=` and `?tax=` on /api/v1/posts read
|
|
51
|
+
// these. Not on PublicApiController for the same reason as the site routes.
|
|
52
|
+
router.get('/api/v1/types', publicApiLimit, content, cacheable, ContentTypeController.publicIndex);
|
|
53
|
+
router.get('/api/v1/taxonomies', publicApiLimit, content, cacheable, TaxonomyController.publicIndex);
|
|
54
|
+
router.get('/api/v1/taxonomies/:key/terms', publicApiLimit, content, cacheable, TaxonomyController.publicTerms);
|
|
55
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EmailVerificationController } from "../../controllers/EmailVerificationController.js";
|
|
2
|
+
import { auth } from "../../middleware/auth.js";
|
|
3
|
+
export default (router) => {
|
|
4
|
+
// Public: this is the target of the emailed link, so it cannot require a
|
|
5
|
+
// session — the whole point is that it may be opened in another browser.
|
|
6
|
+
router.get('/api/auth/verify/:token', EmailVerificationController.verify);
|
|
7
|
+
// Authenticated. Deliberately not gated on a capability: an unverified user
|
|
8
|
+
// holds almost none, and these two are how they stop being unverified.
|
|
9
|
+
router.get('/api/auth/verify', auth, EmailVerificationController.status);
|
|
10
|
+
router.post('/api/auth/verify/resend', auth, EmailVerificationController.resend);
|
|
11
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@basicbenframework/cms/server`: the CMS's server. A site's
|
|
3
|
+
* src/server/index.ts re-exports it, and api/index.js serves it on Vercel.
|
|
4
|
+
*
|
|
5
|
+
* Routes are imported explicitly, so a bundler and Vercel's tracer can follow
|
|
6
|
+
* every one.
|
|
7
|
+
*/
|
|
8
|
+
import '../hooks.ts';
|
|
9
|
+
import '../host/core-tasks.ts';
|
|
10
|
+
import '../config.ts';
|
|
11
|
+
declare const app: {
|
|
12
|
+
use: (...handlers: any[]) => any;
|
|
13
|
+
server: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
14
|
+
get: (path: any, ...handlers: any[]) => any;
|
|
15
|
+
post: (path: any, ...handlers: any[]) => any;
|
|
16
|
+
put: (path: any, ...handlers: any[]) => any;
|
|
17
|
+
patch: (path: any, ...handlers: any[]) => any;
|
|
18
|
+
delete: (path: any, ...handlers: any[]) => any;
|
|
19
|
+
head: (path: any, ...handlers: any[]) => any;
|
|
20
|
+
options: (path: any, ...handlers: any[]) => any;
|
|
21
|
+
listen(port: any, callback: any): any;
|
|
22
|
+
close(callback: any): void;
|
|
23
|
+
};
|
|
24
|
+
export default app;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@basicbenframework/cms/server`: the CMS's server. A site's
|
|
3
|
+
* src/server/index.ts re-exports it, and api/index.js serves it on Vercel.
|
|
4
|
+
*
|
|
5
|
+
* Routes are imported explicitly, so a bundler and Vercel's tracer can follow
|
|
6
|
+
* every one.
|
|
7
|
+
*/
|
|
8
|
+
import { createServer, createRouter, loadConfig } from '@basicbenframework/core/server';
|
|
9
|
+
// Registers the application's hook listeners. Imported for its side effects —
|
|
10
|
+
// the listeners have to be on the registry before the server starts.
|
|
11
|
+
import "../hooks.js";
|
|
12
|
+
// Core's scheduled work, in the registry features add to.
|
|
13
|
+
import "../host/core-tasks.js";
|
|
14
|
+
import { registerFeatures, mountFeatureRoutes } from "../host/index.js";
|
|
15
|
+
import features from "../features.js";
|
|
16
|
+
import { enabledFeatureNames } from "../host/enabled.js";
|
|
17
|
+
// Not needed to run: the site's basicben.config.js imports it. On Vercel that
|
|
18
|
+
// file is copied into the function by includeFiles, which does not follow its
|
|
19
|
+
// imports, so the import here is what puts config.js (and the manifests and
|
|
20
|
+
// db/migrations it points to) into the trace.
|
|
21
|
+
import "../config.js";
|
|
22
|
+
// Import routes explicitly for Vite bundling
|
|
23
|
+
import authRoutes from "../routes/api/auth.js";
|
|
24
|
+
import verificationRoutes from "../routes/api/verification.js";
|
|
25
|
+
import twoFactorRoutes from "../routes/api/two-factor.js";
|
|
26
|
+
import passkeyRoutes from "../routes/api/passkeys.js";
|
|
27
|
+
import postsRoutes from "../routes/api/posts.js";
|
|
28
|
+
import profileRoutes from "../routes/api/profile.js";
|
|
29
|
+
import authorsRoutes from "../routes/api/authors.js";
|
|
30
|
+
import categoriesRoutes from "../routes/api/categories.js";
|
|
31
|
+
import tagsRoutes from "../routes/api/tags.js";
|
|
32
|
+
import pagesRoutes from "../routes/api/pages.js";
|
|
33
|
+
import commentsRoutes from "../routes/api/comments.js";
|
|
34
|
+
import mediaRoutes from "../routes/api/media.js";
|
|
35
|
+
import settingsRoutes from "../routes/api/settings.js";
|
|
36
|
+
import feedRoutes from "../routes/api/feed.js";
|
|
37
|
+
import adminRoutes from "../routes/api/admin.js";
|
|
38
|
+
import tokensRoutes from "../routes/api/tokens.js";
|
|
39
|
+
import usersRoutes from "../routes/api/users.js";
|
|
40
|
+
import v1Routes from "../routes/api/v1.js";
|
|
41
|
+
import cronRoutes from "../routes/api/cron.js";
|
|
42
|
+
import navigationRoutes from "../routes/api/navigation.js";
|
|
43
|
+
import redirectsRoutes from "../routes/api/redirects.js";
|
|
44
|
+
import snippetsRoutes from "../routes/api/snippets.js";
|
|
45
|
+
import exportRoutes from "../routes/api/export.js";
|
|
46
|
+
import opsRoutes from "../routes/api/ops.js";
|
|
47
|
+
import contentModelRoutes from "../routes/api/content-model.js";
|
|
48
|
+
// Determine static directory based on environment
|
|
49
|
+
// In production, static files are in dist/client (relative to app root/cwd)
|
|
50
|
+
const staticDir = process.env.NODE_ENV === 'production' ? 'dist/client' : 'public';
|
|
51
|
+
const app = await createServer({
|
|
52
|
+
// Disable auto-loading since we're importing routes explicitly
|
|
53
|
+
autoloadRoutes: false,
|
|
54
|
+
// Serve static files from appropriate directory.
|
|
55
|
+
// spa serves index.html for unmatched client routes, so deep links and
|
|
56
|
+
// refreshes work in production instead of returning a JSON 404
|
|
57
|
+
static: { dir: staticDir, spa: true }
|
|
58
|
+
});
|
|
59
|
+
// The features the site lists in basicben.config.js register their settings,
|
|
60
|
+
// tasks and routes before anything is mounted, so a settings save or a health
|
|
61
|
+
// check sees all of them. Features left off are imported but never registered,
|
|
62
|
+
// and do nothing.
|
|
63
|
+
const config = await loadConfig();
|
|
64
|
+
await registerFeatures(enabledFeatureNames(config.features).map((name) => features[name]));
|
|
65
|
+
// Register routes
|
|
66
|
+
const router = createRouter();
|
|
67
|
+
authRoutes(router);
|
|
68
|
+
verificationRoutes(router);
|
|
69
|
+
twoFactorRoutes(router);
|
|
70
|
+
passkeyRoutes(router);
|
|
71
|
+
postsRoutes(router);
|
|
72
|
+
profileRoutes(router);
|
|
73
|
+
authorsRoutes(router);
|
|
74
|
+
categoriesRoutes(router);
|
|
75
|
+
tagsRoutes(router);
|
|
76
|
+
pagesRoutes(router);
|
|
77
|
+
commentsRoutes(router);
|
|
78
|
+
mediaRoutes(router);
|
|
79
|
+
settingsRoutes(router);
|
|
80
|
+
feedRoutes(router);
|
|
81
|
+
adminRoutes(router);
|
|
82
|
+
tokensRoutes(router);
|
|
83
|
+
snippetsRoutes(router);
|
|
84
|
+
cronRoutes(router);
|
|
85
|
+
usersRoutes(router);
|
|
86
|
+
navigationRoutes(router);
|
|
87
|
+
redirectsRoutes(router);
|
|
88
|
+
exportRoutes(router);
|
|
89
|
+
opsRoutes(router);
|
|
90
|
+
// The public content API. Versioned because its consumers are outside this
|
|
91
|
+
// repository, and read-only because the admin API already owns the writes.
|
|
92
|
+
v1Routes(router);
|
|
93
|
+
contentModelRoutes(router);
|
|
94
|
+
// Features, after core and in the order the site lists them. The theme must
|
|
95
|
+
// be last (enabledFeatureNames checks): its /:slug would catch anything after.
|
|
96
|
+
mountFeatureRoutes(router);
|
|
97
|
+
router.applyTo(app);
|
|
98
|
+
// Serverless platforms invoke a handler per request and give you no port to
|
|
99
|
+
// bind, so the listener has to be conditional. `api/index.ts` imports this
|
|
100
|
+
// module for its configured app and drives it directly; see that file for how.
|
|
101
|
+
//
|
|
102
|
+
// Everywhere else — local development, any persistent host — this is the entry
|
|
103
|
+
// point and listening is exactly right.
|
|
104
|
+
if (!process.env.VERCEL) {
|
|
105
|
+
const port = process.env.PORT || 3001;
|
|
106
|
+
app.listen(port, () => {
|
|
107
|
+
console.log(`Server running at http://localhost:${port}`);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
export default app;
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
export interface User {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
email: string;
|
|
5
|
+
password: string;
|
|
6
|
+
role: string;
|
|
7
|
+
/** Author archive segment, e.g. `jane-doe`. Unique; set at registration. */
|
|
8
|
+
slug?: string | null;
|
|
9
|
+
/** The author's biography, shown on a byline and an archive page. */
|
|
10
|
+
bio?: string | null;
|
|
11
|
+
/** The author's own site. */
|
|
12
|
+
website?: string | null;
|
|
13
|
+
/** Foreign key into `media`. Not a filename — resolved into `AuthorProfile`. */
|
|
14
|
+
avatar_id?: number | null;
|
|
15
|
+
email_verified?: number;
|
|
16
|
+
email_verified_at?: string | null;
|
|
17
|
+
created_at: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A user as a reader meets them: the byline, not the account.
|
|
21
|
+
*
|
|
22
|
+
* Deliberately excludes the address, the password and the role. This shape
|
|
23
|
+
* travels to public pages, so anything that must not be published cannot be on
|
|
24
|
+
* it in the first place.
|
|
25
|
+
*/
|
|
26
|
+
export interface AuthorProfile {
|
|
27
|
+
id: number;
|
|
28
|
+
name: string;
|
|
29
|
+
slug: string | null;
|
|
30
|
+
bio: string | null;
|
|
31
|
+
website: string | null;
|
|
32
|
+
/** Resolved through the storage adapter, so buckets can move. */
|
|
33
|
+
avatar_url: string | null;
|
|
34
|
+
}
|
|
35
|
+
/** The authenticated principal, taken from the JWT. Capability checks read this. */
|
|
36
|
+
export interface AuthUser {
|
|
37
|
+
id: number;
|
|
38
|
+
role: string;
|
|
39
|
+
email_verified?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface Post {
|
|
42
|
+
id: number;
|
|
43
|
+
user_id: number;
|
|
44
|
+
title: string;
|
|
45
|
+
/** Markdown source. Canonical — this is what the author wrote. */
|
|
46
|
+
content: string;
|
|
47
|
+
/** Rendered, sanitized HTML. A cache of `content`; never edit it directly. */
|
|
48
|
+
content_html?: string;
|
|
49
|
+
slug?: string;
|
|
50
|
+
excerpt?: string;
|
|
51
|
+
/** Foreign key into `media`. Not a filename — see `featured_image_url`. */
|
|
52
|
+
featured_image?: number | null;
|
|
53
|
+
/** Resolved by the model through the storage adapter. */
|
|
54
|
+
featured_image_url?: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* The primary category — the one a breadcrumb or canonical URL would name.
|
|
57
|
+
* A post can belong to several; see `category_ids`.
|
|
58
|
+
*/
|
|
59
|
+
category_id?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Every category on the post. Returned by `GET /api/posts/:id` so the editor
|
|
62
|
+
* can preselect them; sent back on save to replace the set.
|
|
63
|
+
*/
|
|
64
|
+
category_ids?: number[];
|
|
65
|
+
/** Every tag on the post, same contract as `category_ids`. */
|
|
66
|
+
tag_ids?: number[];
|
|
67
|
+
meta_title?: string | null;
|
|
68
|
+
meta_description?: string | null;
|
|
69
|
+
/** When it goes, or went, live. A future value on a published post is a schedule. */
|
|
70
|
+
publish_at?: string | null;
|
|
71
|
+
published: boolean;
|
|
72
|
+
/** Editorial state: `draft`, `pending` (awaiting review) or `published`. */
|
|
73
|
+
status?: 'draft' | 'pending' | 'published';
|
|
74
|
+
/** Set while the post is in the trash. */
|
|
75
|
+
deleted_at?: string | null;
|
|
76
|
+
og_title?: string | null;
|
|
77
|
+
og_description?: string | null;
|
|
78
|
+
og_image?: number | null;
|
|
79
|
+
twitter_title?: string | null;
|
|
80
|
+
twitter_description?: string | null;
|
|
81
|
+
twitter_image?: number | null;
|
|
82
|
+
canonical_url?: string | null;
|
|
83
|
+
noindex?: number | boolean;
|
|
84
|
+
/** Who may read the body: `public`, or a level the access policy defines (helpers/access.ts). */
|
|
85
|
+
visibility?: string;
|
|
86
|
+
/** Written by the members feature: the author asked for this post to be emailed when it goes live. */
|
|
87
|
+
send_newsletter?: number | boolean;
|
|
88
|
+
/** Content type key (migration 038). `post` for every post that predates types. */
|
|
89
|
+
post_type?: string;
|
|
90
|
+
/** Custom field values: the stored JSON string on a row, an object once shaped for the editor. */
|
|
91
|
+
fields?: string | Record<string, unknown> | null;
|
|
92
|
+
/** Custom taxonomy term ids, for the editor to preselect. */
|
|
93
|
+
term_ids?: number[];
|
|
94
|
+
created_at: string;
|
|
95
|
+
updated_at: string;
|
|
96
|
+
author_name?: string;
|
|
97
|
+
/** The author's profile, when the query asked for one. */
|
|
98
|
+
author?: AuthorProfile | null;
|
|
99
|
+
category_name?: string;
|
|
100
|
+
tags?: Tag[];
|
|
101
|
+
}
|
|
102
|
+
export interface Category {
|
|
103
|
+
id: number;
|
|
104
|
+
name: string;
|
|
105
|
+
slug: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
parent_id?: number;
|
|
108
|
+
created_at: string;
|
|
109
|
+
post_count?: number;
|
|
110
|
+
children?: Category[];
|
|
111
|
+
}
|
|
112
|
+
export interface Tag {
|
|
113
|
+
id: number;
|
|
114
|
+
name: string;
|
|
115
|
+
slug: string;
|
|
116
|
+
created_at: string;
|
|
117
|
+
post_count?: number;
|
|
118
|
+
}
|
|
119
|
+
export interface Page {
|
|
120
|
+
id: number;
|
|
121
|
+
title: string;
|
|
122
|
+
slug: string;
|
|
123
|
+
/** Markdown source. Canonical — this is what the author wrote. */
|
|
124
|
+
content?: string;
|
|
125
|
+
/** Rendered, sanitized HTML. A cache of `content`; never edit it directly. */
|
|
126
|
+
content_html?: string;
|
|
127
|
+
template: string;
|
|
128
|
+
published: boolean;
|
|
129
|
+
parent_id?: number;
|
|
130
|
+
menu_order: number;
|
|
131
|
+
/** Foreign key into `media`. Not a filename — see `featured_image_url`. */
|
|
132
|
+
featured_image?: number | null;
|
|
133
|
+
/** Resolved by the model through the storage adapter. */
|
|
134
|
+
featured_image_url?: string | null;
|
|
135
|
+
meta_title?: string;
|
|
136
|
+
meta_description?: string;
|
|
137
|
+
created_at: string;
|
|
138
|
+
updated_at: string;
|
|
139
|
+
children?: Page[];
|
|
140
|
+
}
|
|
141
|
+
export interface Comment {
|
|
142
|
+
id: number;
|
|
143
|
+
post_id: number;
|
|
144
|
+
user_id?: number;
|
|
145
|
+
parent_id?: number;
|
|
146
|
+
author_name?: string;
|
|
147
|
+
author_email?: string;
|
|
148
|
+
content: string;
|
|
149
|
+
/** Kept in step with `status`: true exactly when it is `approved`. */
|
|
150
|
+
approved: boolean;
|
|
151
|
+
/** pending, approved, spam or trash. Moderators only; the public list is all approved. */
|
|
152
|
+
status?: 'pending' | 'approved' | 'spam' | 'trash';
|
|
153
|
+
/** Why a check held it or called it spam. Moderators only. */
|
|
154
|
+
held_reason?: string | null;
|
|
155
|
+
/** The rate limiter's view of the commenter's address. Moderators only. */
|
|
156
|
+
author_ip?: string | null;
|
|
157
|
+
/** Whether the commenter asked to be emailed about replies. */
|
|
158
|
+
notify_replies?: boolean | number;
|
|
159
|
+
reply_notified?: boolean | number;
|
|
160
|
+
created_at: string;
|
|
161
|
+
user?: User;
|
|
162
|
+
/** 1 for a top-level comment; set on the trees the post thread returns. */
|
|
163
|
+
depth?: number;
|
|
164
|
+
replies?: Comment[];
|
|
165
|
+
}
|
|
166
|
+
export interface Media {
|
|
167
|
+
id: number;
|
|
168
|
+
user_id?: number;
|
|
169
|
+
filename: string;
|
|
170
|
+
original_name: string;
|
|
171
|
+
/** The storage key. Not a URL — see `url`. */
|
|
172
|
+
path: string;
|
|
173
|
+
/** Resolved per request through the storage adapter, so buckets can move. */
|
|
174
|
+
url?: string;
|
|
175
|
+
mime_type?: string;
|
|
176
|
+
size?: number;
|
|
177
|
+
alt_text?: string;
|
|
178
|
+
/** Pixel dimensions, read from the file at upload. Null for non-images. */
|
|
179
|
+
width?: number | null;
|
|
180
|
+
height?: number | null;
|
|
181
|
+
created_at: string;
|
|
182
|
+
}
|
|
183
|
+
export interface Settings {
|
|
184
|
+
id: number;
|
|
185
|
+
key: string;
|
|
186
|
+
value?: string;
|
|
187
|
+
group_name: string;
|
|
188
|
+
created_at: string;
|
|
189
|
+
updated_at: string;
|
|
190
|
+
}
|
|
191
|
+
export interface ApiResponse<T> {
|
|
192
|
+
data?: T;
|
|
193
|
+
error?: string;
|
|
194
|
+
}
|
|
195
|
+
export interface PaginatedResponse<T> {
|
|
196
|
+
data: T[];
|
|
197
|
+
total: number;
|
|
198
|
+
page: number;
|
|
199
|
+
per_page: number;
|
|
200
|
+
total_pages: number;
|
|
201
|
+
}
|
|
202
|
+
export interface Request {
|
|
203
|
+
body: Record<string, unknown>;
|
|
204
|
+
params: Record<string, string>;
|
|
205
|
+
query: Record<string, string>;
|
|
206
|
+
headers: Record<string, string>;
|
|
207
|
+
userId?: number;
|
|
208
|
+
user?: AuthUser;
|
|
209
|
+
/** Set by requireCapability when a loadResource option is supplied */
|
|
210
|
+
resource?: Record<string, unknown>;
|
|
211
|
+
/**
|
|
212
|
+
* Set by requireScope when the credential was an API token rather than a
|
|
213
|
+
* session. Its presence is what distinguishes a program from a person —
|
|
214
|
+
* a token has scopes but no role, so capability checks do not apply to it.
|
|
215
|
+
*/
|
|
216
|
+
apiToken?: {
|
|
217
|
+
id: number;
|
|
218
|
+
name: string;
|
|
219
|
+
scopes: string[];
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* The reader the access policy identified (helpers/access.ts), or null.
|
|
223
|
+
* Opaque to core. Never an admin principal: nothing that sets this touches
|
|
224
|
+
* `user` or `userId`.
|
|
225
|
+
*/
|
|
226
|
+
viewer?: object | null;
|
|
227
|
+
}
|
|
228
|
+
export interface Response {
|
|
229
|
+
json: (data: unknown, status?: number) => void;
|
|
230
|
+
status: (code: number) => Response;
|
|
231
|
+
send: (body?: string) => void;
|
|
232
|
+
redirect: (url: string, status?: number) => void;
|
|
233
|
+
setHeader: (name: string, value: string) => void;
|
|
234
|
+
end: (body?: string) => void;
|
|
235
|
+
}
|
|
236
|
+
export interface PostFormData {
|
|
237
|
+
title: string;
|
|
238
|
+
content: string;
|
|
239
|
+
slug?: string;
|
|
240
|
+
excerpt?: string;
|
|
241
|
+
featured_image?: number;
|
|
242
|
+
/** Who the post is attributed to. Only honoured for `post.edit` holders. */
|
|
243
|
+
user_id?: number;
|
|
244
|
+
category_id?: number;
|
|
245
|
+
tags?: number[];
|
|
246
|
+
meta_title?: string;
|
|
247
|
+
meta_description?: string;
|
|
248
|
+
publish_at?: string;
|
|
249
|
+
published: boolean;
|
|
250
|
+
}
|
|
251
|
+
export interface PageFormData {
|
|
252
|
+
title: string;
|
|
253
|
+
slug?: string;
|
|
254
|
+
content?: string;
|
|
255
|
+
featured_image?: number | null;
|
|
256
|
+
template?: string;
|
|
257
|
+
parent_id?: number;
|
|
258
|
+
menu_order?: number;
|
|
259
|
+
meta_title?: string;
|
|
260
|
+
meta_description?: string;
|
|
261
|
+
published: boolean;
|
|
262
|
+
}
|
|
263
|
+
export interface CategoryFormData {
|
|
264
|
+
name: string;
|
|
265
|
+
slug?: string;
|
|
266
|
+
description?: string;
|
|
267
|
+
parent_id?: number;
|
|
268
|
+
}
|
|
269
|
+
export interface TagFormData {
|
|
270
|
+
name: string;
|
|
271
|
+
slug?: string;
|
|
272
|
+
}
|
|
273
|
+
export interface CommentFormData {
|
|
274
|
+
content: string;
|
|
275
|
+
author_name?: string;
|
|
276
|
+
author_email?: string;
|
|
277
|
+
parent_id?: number;
|
|
278
|
+
/** Email me when someone replies. Needs an address: the guest's, or the account's. */
|
|
279
|
+
notify_replies?: boolean;
|
|
280
|
+
/** The signed timestamp from the comments response's `form.token`. */
|
|
281
|
+
form_token?: string;
|
|
282
|
+
/** The honeypot. A person never fills it in. */
|
|
283
|
+
website?: string;
|
|
284
|
+
}
|
|
285
|
+
export interface UserFormData {
|
|
286
|
+
name: string;
|
|
287
|
+
email: string;
|
|
288
|
+
password?: string;
|
|
289
|
+
}
|
|
290
|
+
export interface LoginFormData {
|
|
291
|
+
email: string;
|
|
292
|
+
password: string;
|
|
293
|
+
}
|
|
294
|
+
export interface RegisterFormData {
|
|
295
|
+
name: string;
|
|
296
|
+
email: string;
|
|
297
|
+
password: string;
|
|
298
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/vite.d.ts
ADDED