@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.
Files changed (590) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +206 -2
  3. package/db/migrations/001_create_users.js +15 -0
  4. package/db/migrations/002_create_posts.js +18 -0
  5. package/db/migrations/003_create_categories.js +19 -0
  6. package/db/migrations/004_create_tags.js +16 -0
  7. package/db/migrations/005_create_post_tags.js +16 -0
  8. package/db/migrations/006_create_pages.js +26 -0
  9. package/db/migrations/007_create_comments.js +24 -0
  10. package/db/migrations/008_create_media.js +22 -0
  11. package/db/migrations/009_update_posts_blogging.js +27 -0
  12. package/db/migrations/010_create_settings.js +29 -0
  13. package/db/migrations/011_add_user_roles.js +23 -0
  14. package/db/migrations/012_create_auth_tokens.js +30 -0
  15. package/db/migrations/013_add_email_verified.js +24 -0
  16. package/db/migrations/014_create_user_two_factor.js +30 -0
  17. package/db/migrations/015_create_user_credentials.js +35 -0
  18. package/db/migrations/016_create_rate_limits.js +31 -0
  19. package/db/migrations/017_add_content_html.js +38 -0
  20. package/db/migrations/018_create_api_tokens.js +34 -0
  21. package/db/migrations/019_create_post_categories.js +40 -0
  22. package/db/migrations/020_add_author_profiles.js +60 -0
  23. package/db/migrations/021_add_page_featured_image.js +23 -0
  24. package/db/migrations/022_backfill_post_slugs_and_excerpts.js +57 -0
  25. package/db/migrations/023_add_user_session_controls.js +25 -0
  26. package/db/migrations/024_add_post_status_and_trash.js +45 -0
  27. package/db/migrations/025_add_social_and_indexing_fields.js +40 -0
  28. package/db/migrations/026_create_post_revisions.js +29 -0
  29. package/db/migrations/027_add_media_dimensions.js +19 -0
  30. package/db/migrations/028_create_navigation_menus.js +65 -0
  31. package/db/migrations/029_create_redirects.js +40 -0
  32. package/db/migrations/030_add_comment_status_and_notifications.js +53 -0
  33. package/db/migrations/031_create_post_locks.js +38 -0
  34. package/db/migrations/032_create_snippets.js +31 -0
  35. package/db/migrations/033_create_members.js +70 -0
  36. package/db/migrations/034_add_post_visibility.js +28 -0
  37. package/db/migrations/035_create_newsletters.js +72 -0
  38. package/db/migrations/036_create_analytics.js +89 -0
  39. package/db/migrations/037_create_ops_heartbeats.js +30 -0
  40. package/db/migrations/038_create_content_types.js +84 -0
  41. package/db/migrations/039_create_content_type_fields.js +47 -0
  42. package/db/migrations/040_create_taxonomies.js +80 -0
  43. package/db/migrations/041_add_newsletter_handoff.js +28 -0
  44. package/db/migrations/042_create_mysendbox_contacts.js +63 -0
  45. package/lib/cli/backup.d.mts +2 -0
  46. package/lib/cli/backup.mjs +124 -0
  47. package/lib/cli/export.d.mts +2 -0
  48. package/lib/cli/export.mjs +54 -0
  49. package/lib/cli/import-ghost.d.mts +2 -0
  50. package/lib/cli/import-ghost.mjs +50 -0
  51. package/lib/cli/import-json.d.mts +2 -0
  52. package/lib/cli/import-json.mjs +61 -0
  53. package/lib/cli/import-wordpress.d.mts +2 -0
  54. package/lib/cli/import-wordpress.mjs +169 -0
  55. package/lib/cli/import-wxr.d.mts +2 -0
  56. package/lib/cli/import-wxr.mjs +55 -0
  57. package/lib/cli/index.d.mts +2 -0
  58. package/lib/cli/index.mjs +53 -0
  59. package/lib/cli/lib/backup.d.mts +112 -0
  60. package/lib/cli/lib/backup.mjs +297 -0
  61. package/lib/cli/lib/ghost.d.mts +30 -0
  62. package/lib/cli/lib/ghost.mjs +201 -0
  63. package/lib/cli/lib/html-to-markdown.d.mts +61 -0
  64. package/lib/cli/lib/html-to-markdown.mjs +523 -0
  65. package/lib/cli/lib/import-common.d.mts +100 -0
  66. package/lib/cli/lib/import-common.mjs +252 -0
  67. package/lib/cli/lib/json-import.d.mts +22 -0
  68. package/lib/cli/lib/json-import.mjs +422 -0
  69. package/lib/cli/lib/site-import.d.mts +32 -0
  70. package/lib/cli/lib/site-import.mjs +456 -0
  71. package/lib/cli/lib/wordpress-rest.d.mts +25 -0
  72. package/lib/cli/lib/wordpress-rest.mjs +177 -0
  73. package/lib/cli/lib/wxr.d.mts +18 -0
  74. package/lib/cli/lib/wxr.mjs +307 -0
  75. package/lib/cli/lib/xml.d.mts +33 -0
  76. package/lib/cli/lib/xml.mjs +186 -0
  77. package/lib/cli/restore.d.mts +2 -0
  78. package/lib/cli/restore.mjs +98 -0
  79. package/lib/client/components/Alert.d.ts +7 -0
  80. package/lib/client/components/Alert.js +8 -0
  81. package/lib/client/components/Avatar.d.ts +15 -0
  82. package/lib/client/components/Avatar.js +10 -0
  83. package/lib/client/components/BackLink.d.ts +7 -0
  84. package/lib/client/components/BackLink.js +6 -0
  85. package/lib/client/components/Button.d.ts +7 -0
  86. package/lib/client/components/Button.js +12 -0
  87. package/lib/client/components/Card.d.ts +7 -0
  88. package/lib/client/components/Card.js +6 -0
  89. package/lib/client/components/CommentThread.d.ts +15 -0
  90. package/lib/client/components/CommentThread.js +101 -0
  91. package/lib/client/components/Empty.d.ts +6 -0
  92. package/lib/client/components/Empty.js +6 -0
  93. package/lib/client/components/Input.d.ts +6 -0
  94. package/lib/client/components/Input.js +6 -0
  95. package/lib/client/components/Link.d.ts +31 -0
  96. package/lib/client/components/Link.js +49 -0
  97. package/lib/client/components/Loading.d.ts +1 -0
  98. package/lib/client/components/Loading.js +6 -0
  99. package/lib/client/components/Logo.d.ts +5 -0
  100. package/lib/client/components/Logo.js +4 -0
  101. package/lib/client/components/MarkdownEditor.d.ts +41 -0
  102. package/lib/client/components/MarkdownEditor.js +156 -0
  103. package/lib/client/components/Nav/DarkModeToggle.d.ts +6 -0
  104. package/lib/client/components/Nav/DarkModeToggle.js +6 -0
  105. package/lib/client/components/Nav/DesktopNav.d.ts +8 -0
  106. package/lib/client/components/Nav/DesktopNav.js +9 -0
  107. package/lib/client/components/Nav/MobileNav.d.ts +9 -0
  108. package/lib/client/components/Nav/MobileNav.js +15 -0
  109. package/lib/client/components/NavLink.d.ts +8 -0
  110. package/lib/client/components/NavLink.js +6 -0
  111. package/lib/client/components/PageHeader.d.ts +8 -0
  112. package/lib/client/components/PageHeader.js +6 -0
  113. package/lib/client/components/PostCard.d.ts +8 -0
  114. package/lib/client/components/PostCard.js +7 -0
  115. package/lib/client/components/Textarea.d.ts +6 -0
  116. package/lib/client/components/Textarea.js +6 -0
  117. package/lib/client/components/ThemeContext.d.ts +18 -0
  118. package/lib/client/components/ThemeContext.js +8 -0
  119. package/lib/client/components/admin/AdminIcons.d.ts +13 -0
  120. package/lib/client/components/admin/AdminIcons.js +66 -0
  121. package/lib/client/components/admin/ContentModelPanels.d.ts +22 -0
  122. package/lib/client/components/admin/ContentModelPanels.js +93 -0
  123. package/lib/client/components/admin/FeaturedImageBox.d.ts +21 -0
  124. package/lib/client/components/admin/FeaturedImageBox.js +24 -0
  125. package/lib/client/components/admin/MediaGrid.d.ts +23 -0
  126. package/lib/client/components/admin/MediaGrid.js +69 -0
  127. package/lib/client/components/admin/MediaPicker.d.ts +17 -0
  128. package/lib/client/components/admin/MediaPicker.js +61 -0
  129. package/lib/client/components/admin/Pagination.d.ts +27 -0
  130. package/lib/client/components/admin/Pagination.js +29 -0
  131. package/lib/client/components/admin/SnippetPicker.d.ts +27 -0
  132. package/lib/client/components/admin/SnippetPicker.js +65 -0
  133. package/lib/client/components/admin/TermPicker.d.ts +52 -0
  134. package/lib/client/components/admin/TermPicker.js +58 -0
  135. package/lib/client/contexts/ToastContext.d.ts +12 -0
  136. package/lib/client/contexts/ToastContext.js +49 -0
  137. package/lib/client/features.d.ts +11 -0
  138. package/lib/client/features.js +7 -0
  139. package/lib/client/hooks/useContentTypes.d.ts +48 -0
  140. package/lib/client/hooks/useContentTypes.js +48 -0
  141. package/lib/client/hooks/useMediaLibrary.d.ts +46 -0
  142. package/lib/client/hooks/useMediaLibrary.js +189 -0
  143. package/lib/client/hooks/usePostLock.d.ts +32 -0
  144. package/lib/client/hooks/usePostLock.js +107 -0
  145. package/lib/client/host/index.d.ts +71 -0
  146. package/lib/client/host/index.js +58 -0
  147. package/lib/client/i18n/index.d.ts +79 -0
  148. package/lib/client/i18n/index.js +177 -0
  149. package/lib/client/i18n/locales/es/content.d.ts +4 -0
  150. package/lib/client/i18n/locales/es/content.js +220 -0
  151. package/lib/client/i18n/locales/es/editor.d.ts +9 -0
  152. package/lib/client/i18n/locales/es/editor.js +144 -0
  153. package/lib/client/i18n/locales/es/index.d.ts +8 -0
  154. package/lib/client/i18n/locales/es/index.js +7 -0
  155. package/lib/client/i18n/locales/es/layout.d.ts +4 -0
  156. package/lib/client/i18n/locales/es/layout.js +35 -0
  157. package/lib/client/i18n/locales/es/people.d.ts +4 -0
  158. package/lib/client/i18n/locales/es/people.js +187 -0
  159. package/lib/client/i18n/locales/es/site.d.ts +4 -0
  160. package/lib/client/i18n/locales/es/site.js +208 -0
  161. package/lib/client/layouts/AdminLayout.d.ts +7 -0
  162. package/lib/client/layouts/AdminLayout.js +1046 -0
  163. package/lib/client/layouts/AppLayout.d.ts +6 -0
  164. package/lib/client/layouts/AppLayout.js +19 -0
  165. package/lib/client/layouts/AuthLayout.d.ts +6 -0
  166. package/lib/client/layouts/AuthLayout.js +14 -0
  167. package/lib/client/layouts/DocsLayout.d.ts +6 -0
  168. package/lib/client/layouts/DocsLayout.js +28 -0
  169. package/lib/client/layouts/RootLayout.d.ts +6 -0
  170. package/lib/client/layouts/RootLayout.js +11 -0
  171. package/lib/client/pages/AcceptInvite.d.ts +8 -0
  172. package/lib/client/pages/AcceptInvite.js +60 -0
  173. package/lib/client/pages/Auth.d.ts +1 -0
  174. package/lib/client/pages/Auth.js +40 -0
  175. package/lib/client/pages/Authentication.d.ts +1 -0
  176. package/lib/client/pages/Authentication.js +230 -0
  177. package/lib/client/pages/Content.d.ts +1 -0
  178. package/lib/client/pages/Content.js +21 -0
  179. package/lib/client/pages/Database.d.ts +1 -0
  180. package/lib/client/pages/Database.js +264 -0
  181. package/lib/client/pages/Extending.d.ts +1 -0
  182. package/lib/client/pages/Extending.js +28 -0
  183. package/lib/client/pages/Feed.d.ts +1 -0
  184. package/lib/client/pages/Feed.js +19 -0
  185. package/lib/client/pages/FeedPost.d.ts +1 -0
  186. package/lib/client/pages/FeedPost.js +31 -0
  187. package/lib/client/pages/ForgotPassword.d.ts +8 -0
  188. package/lib/client/pages/ForgotPassword.js +38 -0
  189. package/lib/client/pages/GettingStarted.d.ts +1 -0
  190. package/lib/client/pages/GettingStarted.js +84 -0
  191. package/lib/client/pages/Headless.d.ts +1 -0
  192. package/lib/client/pages/Headless.js +49 -0
  193. package/lib/client/pages/Home.d.ts +1 -0
  194. package/lib/client/pages/Home.js +67 -0
  195. package/lib/client/pages/PostForm.d.ts +1 -0
  196. package/lib/client/pages/PostForm.js +55 -0
  197. package/lib/client/pages/Posts.d.ts +1 -0
  198. package/lib/client/pages/Posts.js +35 -0
  199. package/lib/client/pages/Profile.d.ts +1 -0
  200. package/lib/client/pages/Profile.js +153 -0
  201. package/lib/client/pages/ResetPassword.d.ts +8 -0
  202. package/lib/client/pages/ResetPassword.js +52 -0
  203. package/lib/client/pages/Routing.d.ts +1 -0
  204. package/lib/client/pages/Routing.js +192 -0
  205. package/lib/client/pages/Storage.d.ts +1 -0
  206. package/lib/client/pages/Storage.js +54 -0
  207. package/lib/client/pages/Testing.d.ts +1 -0
  208. package/lib/client/pages/Testing.js +141 -0
  209. package/lib/client/pages/Validation.d.ts +1 -0
  210. package/lib/client/pages/Validation.js +123 -0
  211. package/lib/client/pages/admin/Categories.d.ts +2 -0
  212. package/lib/client/pages/admin/Categories.js +75 -0
  213. package/lib/client/pages/admin/Comments.d.ts +11 -0
  214. package/lib/client/pages/admin/Comments.js +247 -0
  215. package/lib/client/pages/admin/ContentTypes.d.ts +2 -0
  216. package/lib/client/pages/admin/ContentTypes.js +163 -0
  217. package/lib/client/pages/admin/Dashboard.d.ts +2 -0
  218. package/lib/client/pages/admin/Dashboard.js +66 -0
  219. package/lib/client/pages/admin/Health.d.ts +12 -0
  220. package/lib/client/pages/admin/Health.js +148 -0
  221. package/lib/client/pages/admin/Media.d.ts +2 -0
  222. package/lib/client/pages/admin/Media.js +101 -0
  223. package/lib/client/pages/admin/Navigation.d.ts +9 -0
  224. package/lib/client/pages/admin/Navigation.js +230 -0
  225. package/lib/client/pages/admin/Pages.d.ts +2 -0
  226. package/lib/client/pages/admin/Pages.js +53 -0
  227. package/lib/client/pages/admin/PostEditor.d.ts +17 -0
  228. package/lib/client/pages/admin/PostEditor.js +532 -0
  229. package/lib/client/pages/admin/Posts.d.ts +2 -0
  230. package/lib/client/pages/admin/Posts.js +152 -0
  231. package/lib/client/pages/admin/Redirects.d.ts +10 -0
  232. package/lib/client/pages/admin/Redirects.js +87 -0
  233. package/lib/client/pages/admin/Settings.d.ts +2 -0
  234. package/lib/client/pages/admin/Settings.js +111 -0
  235. package/lib/client/pages/admin/Snippets.d.ts +14 -0
  236. package/lib/client/pages/admin/Snippets.js +85 -0
  237. package/lib/client/pages/admin/Tags.d.ts +2 -0
  238. package/lib/client/pages/admin/Tags.js +74 -0
  239. package/lib/client/pages/admin/Taxonomies.d.ts +2 -0
  240. package/lib/client/pages/admin/Taxonomies.js +130 -0
  241. package/lib/client/pages/admin/Tokens.d.ts +9 -0
  242. package/lib/client/pages/admin/Tokens.js +260 -0
  243. package/lib/client/pages/admin/Tools.d.ts +12 -0
  244. package/lib/client/pages/admin/Tools.js +111 -0
  245. package/lib/client/pages/admin/Users.d.ts +13 -0
  246. package/lib/client/pages/admin/Users.js +313 -0
  247. package/lib/client/pages/api-reference.d.ts +33 -0
  248. package/lib/client/pages/api-reference.js +198 -0
  249. package/lib/client/styles.css +37 -0
  250. package/lib/config.d.ts +24 -0
  251. package/lib/config.js +39 -0
  252. package/lib/controllers/AdminController.d.ts +46 -0
  253. package/lib/controllers/AdminController.js +134 -0
  254. package/lib/controllers/AuthController.d.ts +15 -0
  255. package/lib/controllers/AuthController.js +194 -0
  256. package/lib/controllers/AuthorController.d.ts +17 -0
  257. package/lib/controllers/AuthorController.js +19 -0
  258. package/lib/controllers/CategoryController.d.ts +10 -0
  259. package/lib/controllers/CategoryController.js +88 -0
  260. package/lib/controllers/CommentController.d.ts +68 -0
  261. package/lib/controllers/CommentController.js +438 -0
  262. package/lib/controllers/ContentTypeController.d.ts +24 -0
  263. package/lib/controllers/ContentTypeController.js +91 -0
  264. package/lib/controllers/EmailVerificationController.d.ts +33 -0
  265. package/lib/controllers/EmailVerificationController.js +116 -0
  266. package/lib/controllers/ExportController.d.ts +15 -0
  267. package/lib/controllers/ExportController.js +41 -0
  268. package/lib/controllers/FeedController.d.ts +14 -0
  269. package/lib/controllers/FeedController.js +246 -0
  270. package/lib/controllers/HealthController.d.ts +21 -0
  271. package/lib/controllers/HealthController.js +176 -0
  272. package/lib/controllers/HomeController.d.ts +12 -0
  273. package/lib/controllers/HomeController.js +16 -0
  274. package/lib/controllers/MediaController.d.ts +24 -0
  275. package/lib/controllers/MediaController.js +189 -0
  276. package/lib/controllers/NavigationController.d.ts +22 -0
  277. package/lib/controllers/NavigationController.js +176 -0
  278. package/lib/controllers/PageController.d.ts +13 -0
  279. package/lib/controllers/PageController.js +172 -0
  280. package/lib/controllers/PasskeyController.d.ts +36 -0
  281. package/lib/controllers/PasskeyController.js +201 -0
  282. package/lib/controllers/PasswordResetController.d.ts +44 -0
  283. package/lib/controllers/PasswordResetController.js +160 -0
  284. package/lib/controllers/PostController.d.ts +51 -0
  285. package/lib/controllers/PostController.js +538 -0
  286. package/lib/controllers/PostLockController.d.ts +62 -0
  287. package/lib/controllers/PostLockController.js +101 -0
  288. package/lib/controllers/ProfileController.d.ts +13 -0
  289. package/lib/controllers/ProfileController.js +160 -0
  290. package/lib/controllers/PublicApiController.d.ts +23 -0
  291. package/lib/controllers/PublicApiController.js +100 -0
  292. package/lib/controllers/RedirectController.d.ts +32 -0
  293. package/lib/controllers/RedirectController.js +95 -0
  294. package/lib/controllers/SettingsController.d.ts +28 -0
  295. package/lib/controllers/SettingsController.js +105 -0
  296. package/lib/controllers/SnippetController.d.ts +27 -0
  297. package/lib/controllers/SnippetController.js +123 -0
  298. package/lib/controllers/TagController.d.ts +9 -0
  299. package/lib/controllers/TagController.js +70 -0
  300. package/lib/controllers/TaxonomyController.d.ts +24 -0
  301. package/lib/controllers/TaxonomyController.js +149 -0
  302. package/lib/controllers/TokenController.d.ts +27 -0
  303. package/lib/controllers/TokenController.js +83 -0
  304. package/lib/controllers/TwoFactorController.d.ts +31 -0
  305. package/lib/controllers/TwoFactorController.js +213 -0
  306. package/lib/controllers/UserController.d.ts +110 -0
  307. package/lib/controllers/UserController.js +504 -0
  308. package/lib/features/analytics/AnalyticsPage.d.ts +11 -0
  309. package/lib/features/analytics/AnalyticsPage.js +123 -0
  310. package/lib/features/analytics/admin.d.ts +3 -0
  311. package/lib/features/analytics/admin.js +9 -0
  312. package/lib/features/analytics/controller.d.ts +19 -0
  313. package/lib/features/analytics/controller.js +79 -0
  314. package/lib/features/analytics/helpers.d.ts +84 -0
  315. package/lib/features/analytics/helpers.js +181 -0
  316. package/lib/features/analytics/i18n/es.d.ts +4 -0
  317. package/lib/features/analytics/i18n/es.js +31 -0
  318. package/lib/features/analytics/index.d.ts +28 -0
  319. package/lib/features/analytics/index.js +91 -0
  320. package/lib/features/analytics/manifest.d.ts +8 -0
  321. package/lib/features/analytics/manifest.js +18 -0
  322. package/lib/features/analytics/model.d.ts +130 -0
  323. package/lib/features/analytics/model.js +206 -0
  324. package/lib/features/members/Member.d.ts +93 -0
  325. package/lib/features/members/Member.js +194 -0
  326. package/lib/features/members/MemberAdminController.d.ts +60 -0
  327. package/lib/features/members/MemberAdminController.js +262 -0
  328. package/lib/features/members/MemberController.d.ts +88 -0
  329. package/lib/features/members/MemberController.js +250 -0
  330. package/lib/features/members/MembersPage.d.ts +10 -0
  331. package/lib/features/members/MembersPage.js +216 -0
  332. package/lib/features/members/PostAccessBox.d.ts +15 -0
  333. package/lib/features/members/PostAccessBox.js +70 -0
  334. package/lib/features/members/admin.d.ts +3 -0
  335. package/lib/features/members/admin.js +12 -0
  336. package/lib/features/members/csv.d.ts +21 -0
  337. package/lib/features/members/csv.js +74 -0
  338. package/lib/features/members/events.d.ts +34 -0
  339. package/lib/features/members/events.js +34 -0
  340. package/lib/features/members/i18n/es.d.ts +4 -0
  341. package/lib/features/members/i18n/es.js +106 -0
  342. package/lib/features/members/index.d.ts +44 -0
  343. package/lib/features/members/index.js +106 -0
  344. package/lib/features/members/manifest.d.ts +8 -0
  345. package/lib/features/members/manifest.js +18 -0
  346. package/lib/features/members/middleware.d.ts +42 -0
  347. package/lib/features/members/middleware.js +74 -0
  348. package/lib/features/members/newsletter.d.ts +177 -0
  349. package/lib/features/members/newsletter.js +439 -0
  350. package/lib/features/members/rate-limits.d.ts +34 -0
  351. package/lib/features/members/rate-limits.js +50 -0
  352. package/lib/features/members/request.d.ts +13 -0
  353. package/lib/features/members/request.js +6 -0
  354. package/lib/features/members/routes.d.ts +15 -0
  355. package/lib/features/members/routes.js +59 -0
  356. package/lib/features/members/session.d.ts +102 -0
  357. package/lib/features/members/session.js +158 -0
  358. package/lib/features/members/settings.d.ts +14 -0
  359. package/lib/features/members/settings.js +23 -0
  360. package/lib/features/mysendbox/MySendboxSettingsCard.d.ts +7 -0
  361. package/lib/features/mysendbox/MySendboxSettingsCard.js +48 -0
  362. package/lib/features/mysendbox/admin.d.ts +3 -0
  363. package/lib/features/mysendbox/admin.js +9 -0
  364. package/lib/features/mysendbox/broadcasts.d.ts +61 -0
  365. package/lib/features/mysendbox/broadcasts.js +124 -0
  366. package/lib/features/mysendbox/client.d.ts +95 -0
  367. package/lib/features/mysendbox/client.js +61 -0
  368. package/lib/features/mysendbox/config.d.ts +27 -0
  369. package/lib/features/mysendbox/config.js +74 -0
  370. package/lib/features/mysendbox/contacts.d.ts +121 -0
  371. package/lib/features/mysendbox/contacts.js +378 -0
  372. package/lib/features/mysendbox/controller.d.ts +11 -0
  373. package/lib/features/mysendbox/controller.js +47 -0
  374. package/lib/features/mysendbox/i18n/es.d.ts +4 -0
  375. package/lib/features/mysendbox/i18n/es.js +28 -0
  376. package/lib/features/mysendbox/index.d.ts +18 -0
  377. package/lib/features/mysendbox/index.js +71 -0
  378. package/lib/features/mysendbox/manifest.d.ts +7 -0
  379. package/lib/features/mysendbox/manifest.js +6 -0
  380. package/lib/features/mysendbox/routes.d.ts +6 -0
  381. package/lib/features/mysendbox/routes.js +14 -0
  382. package/lib/features/mysendbox/webhook.d.ts +23 -0
  383. package/lib/features/mysendbox/webhook.js +104 -0
  384. package/lib/features/theme/OEmbedController.d.ts +31 -0
  385. package/lib/features/theme/OEmbedController.js +128 -0
  386. package/lib/features/theme/ThemeController.d.ts +20 -0
  387. package/lib/features/theme/ThemeController.js +256 -0
  388. package/lib/features/theme/ThemeSettingsCard.d.ts +7 -0
  389. package/lib/features/theme/ThemeSettingsCard.js +12 -0
  390. package/lib/features/theme/admin.d.ts +3 -0
  391. package/lib/features/theme/admin.js +9 -0
  392. package/lib/features/theme/html.d.ts +48 -0
  393. package/lib/features/theme/html.js +97 -0
  394. package/lib/features/theme/i18n/es.d.ts +4 -0
  395. package/lib/features/theme/i18n/es.js +9 -0
  396. package/lib/features/theme/index.d.ts +11 -0
  397. package/lib/features/theme/index.js +23 -0
  398. package/lib/features/theme/manifest.d.ts +7 -0
  399. package/lib/features/theme/manifest.js +6 -0
  400. package/lib/features/theme/oembed.d.ts +36 -0
  401. package/lib/features/theme/oembed.js +58 -0
  402. package/lib/features/theme/routes.d.ts +17 -0
  403. package/lib/features/theme/routes.js +54 -0
  404. package/lib/features/theme/templates.d.ts +103 -0
  405. package/lib/features/theme/templates.js +283 -0
  406. package/lib/features.d.ts +15 -0
  407. package/lib/features.js +6 -0
  408. package/lib/features.manifest.d.ts +10 -0
  409. package/lib/features.manifest.js +6 -0
  410. package/lib/helpers/access.d.ts +62 -0
  411. package/lib/helpers/access.js +92 -0
  412. package/lib/helpers/api.d.ts +20 -0
  413. package/lib/helpers/api.js +44 -0
  414. package/lib/helpers/comment-guard.d.ts +145 -0
  415. package/lib/helpers/comment-guard.js +253 -0
  416. package/lib/helpers/comment-mail.d.ts +53 -0
  417. package/lib/helpers/comment-mail.js +188 -0
  418. package/lib/helpers/content-model.d.ts +50 -0
  419. package/lib/helpers/content-model.js +84 -0
  420. package/lib/helpers/content-paths.d.ts +107 -0
  421. package/lib/helpers/content-paths.js +200 -0
  422. package/lib/helpers/export-data.d.ts +85 -0
  423. package/lib/helpers/export-data.js +229 -0
  424. package/lib/helpers/gating.d.ts +53 -0
  425. package/lib/helpers/gating.js +83 -0
  426. package/lib/helpers/health.d.ts +91 -0
  427. package/lib/helpers/health.js +279 -0
  428. package/lib/helpers/heartbeat.d.ts +35 -0
  429. package/lib/helpers/heartbeat.js +55 -0
  430. package/lib/helpers/image-size.d.ts +18 -0
  431. package/lib/helpers/image-size.js +83 -0
  432. package/lib/helpers/images.d.ts +29 -0
  433. package/lib/helpers/images.js +41 -0
  434. package/lib/helpers/mail-templates.d.ts +11 -0
  435. package/lib/helpers/mail-templates.js +42 -0
  436. package/lib/helpers/publish-due.d.ts +28 -0
  437. package/lib/helpers/publish-due.js +67 -0
  438. package/lib/helpers/redirects.d.ts +43 -0
  439. package/lib/helpers/redirects.js +80 -0
  440. package/lib/helpers/seo-fields.d.ts +13 -0
  441. package/lib/helpers/seo-fields.js +52 -0
  442. package/lib/helpers/session.d.ts +30 -0
  443. package/lib/helpers/session.js +27 -0
  444. package/lib/helpers/site-settings.d.ts +98 -0
  445. package/lib/helpers/site-settings.js +232 -0
  446. package/lib/helpers/site.d.ts +14 -0
  447. package/lib/helpers/site.js +23 -0
  448. package/lib/helpers/write-hooks.d.ts +33 -0
  449. package/lib/helpers/write-hooks.js +37 -0
  450. package/lib/hooks.d.ts +17 -0
  451. package/lib/hooks.js +101 -0
  452. package/lib/host/core-tasks.d.ts +4 -0
  453. package/lib/host/core-tasks.js +26 -0
  454. package/lib/host/cron.d.ts +39 -0
  455. package/lib/host/cron.js +85 -0
  456. package/lib/host/enabled.d.ts +4 -0
  457. package/lib/host/enabled.js +40 -0
  458. package/lib/host/index.d.ts +81 -0
  459. package/lib/host/index.js +87 -0
  460. package/lib/host/manifest.d.ts +34 -0
  461. package/lib/host/manifest.js +7 -0
  462. package/lib/host/menu.d.ts +18 -0
  463. package/lib/host/menu.js +15 -0
  464. package/lib/main.d.ts +1 -0
  465. package/lib/main.js +24 -0
  466. package/lib/middleware/api-auth.d.ts +59 -0
  467. package/lib/middleware/api-auth.js +164 -0
  468. package/lib/middleware/auth.d.ts +49 -0
  469. package/lib/middleware/auth.js +112 -0
  470. package/lib/middleware/cache.d.ts +17 -0
  471. package/lib/middleware/cache.js +52 -0
  472. package/lib/middleware/rate-limits.d.ts +199 -0
  473. package/lib/middleware/rate-limits.js +276 -0
  474. package/lib/middleware/viewer.d.ts +13 -0
  475. package/lib/middleware/viewer.js +16 -0
  476. package/lib/models/Category.d.ts +24 -0
  477. package/lib/models/Category.js +102 -0
  478. package/lib/models/Comment.d.ts +120 -0
  479. package/lib/models/Comment.js +283 -0
  480. package/lib/models/ContentType.d.ts +142 -0
  481. package/lib/models/ContentType.js +462 -0
  482. package/lib/models/Credential.d.ts +21 -0
  483. package/lib/models/Credential.js +31 -0
  484. package/lib/models/Media.d.ts +53 -0
  485. package/lib/models/Media.js +132 -0
  486. package/lib/models/Menu.d.ts +131 -0
  487. package/lib/models/Menu.js +312 -0
  488. package/lib/models/Page.d.ts +55 -0
  489. package/lib/models/Page.js +218 -0
  490. package/lib/models/Post.d.ts +136 -0
  491. package/lib/models/Post.js +406 -0
  492. package/lib/models/PostLock.d.ts +67 -0
  493. package/lib/models/PostLock.js +112 -0
  494. package/lib/models/PostRevision.d.ts +45 -0
  495. package/lib/models/PostRevision.js +82 -0
  496. package/lib/models/PublicContent.d.ts +283 -0
  497. package/lib/models/PublicContent.js +577 -0
  498. package/lib/models/Redirect.d.ts +123 -0
  499. package/lib/models/Redirect.js +225 -0
  500. package/lib/models/Settings.d.ts +61 -0
  501. package/lib/models/Settings.js +128 -0
  502. package/lib/models/Snippet.d.ts +36 -0
  503. package/lib/models/Snippet.js +64 -0
  504. package/lib/models/Tag.d.ts +23 -0
  505. package/lib/models/Tag.js +117 -0
  506. package/lib/models/Taxonomy.d.ts +127 -0
  507. package/lib/models/Taxonomy.js +321 -0
  508. package/lib/models/TwoFactor.d.ts +26 -0
  509. package/lib/models/TwoFactor.js +60 -0
  510. package/lib/models/User.d.ts +49 -0
  511. package/lib/models/User.js +128 -0
  512. package/lib/models/derive.d.ts +69 -0
  513. package/lib/models/derive.js +81 -0
  514. package/lib/models/pagination.d.ts +30 -0
  515. package/lib/models/pagination.js +36 -0
  516. package/lib/models/visibility.d.ts +31 -0
  517. package/lib/models/visibility.js +47 -0
  518. package/lib/routes/App.d.ts +2 -0
  519. package/lib/routes/App.js +146 -0
  520. package/lib/routes/api/admin.d.ts +6 -0
  521. package/lib/routes/api/admin.js +11 -0
  522. package/lib/routes/api/auth.d.ts +6 -0
  523. package/lib/routes/api/auth.js +24 -0
  524. package/lib/routes/api/authors.d.ts +5 -0
  525. package/lib/routes/api/authors.js +8 -0
  526. package/lib/routes/api/categories.d.ts +8 -0
  527. package/lib/routes/api/categories.js +15 -0
  528. package/lib/routes/api/comments.d.ts +8 -0
  529. package/lib/routes/api/comments.js +35 -0
  530. package/lib/routes/api/content-model.d.ts +17 -0
  531. package/lib/routes/api/content-model.js +67 -0
  532. package/lib/routes/api/cron.d.ts +6 -0
  533. package/lib/routes/api/cron.js +9 -0
  534. package/lib/routes/api/export.d.ts +5 -0
  535. package/lib/routes/api/export.js +11 -0
  536. package/lib/routes/api/feed.d.ts +5 -0
  537. package/lib/routes/api/feed.js +16 -0
  538. package/lib/routes/api/media.d.ts +8 -0
  539. package/lib/routes/api/media.js +25 -0
  540. package/lib/routes/api/navigation.d.ts +12 -0
  541. package/lib/routes/api/navigation.js +17 -0
  542. package/lib/routes/api/ops.d.ts +9 -0
  543. package/lib/routes/api/ops.js +19 -0
  544. package/lib/routes/api/pages.d.ts +8 -0
  545. package/lib/routes/api/pages.js +21 -0
  546. package/lib/routes/api/passkeys.d.ts +7 -0
  547. package/lib/routes/api/passkeys.js +13 -0
  548. package/lib/routes/api/posts.d.ts +8 -0
  549. package/lib/routes/api/posts.js +39 -0
  550. package/lib/routes/api/profile.d.ts +6 -0
  551. package/lib/routes/api/profile.js +8 -0
  552. package/lib/routes/api/redirects.d.ts +12 -0
  553. package/lib/routes/api/redirects.js +13 -0
  554. package/lib/routes/api/settings.d.ts +8 -0
  555. package/lib/routes/api/settings.js +15 -0
  556. package/lib/routes/api/snippets.d.ts +15 -0
  557. package/lib/routes/api/snippets.js +16 -0
  558. package/lib/routes/api/tags.d.ts +8 -0
  559. package/lib/routes/api/tags.js +14 -0
  560. package/lib/routes/api/tokens.d.ts +7 -0
  561. package/lib/routes/api/tokens.js +15 -0
  562. package/lib/routes/api/two-factor.d.ts +7 -0
  563. package/lib/routes/api/two-factor.js +15 -0
  564. package/lib/routes/api/users.d.ts +8 -0
  565. package/lib/routes/api/users.js +25 -0
  566. package/lib/routes/api/v1.d.ts +12 -0
  567. package/lib/routes/api/v1.js +55 -0
  568. package/lib/routes/api/verification.d.ts +6 -0
  569. package/lib/routes/api/verification.js +11 -0
  570. package/lib/server/index.d.ts +24 -0
  571. package/lib/server/index.js +110 -0
  572. package/lib/types/index.d.ts +298 -0
  573. package/lib/types/index.js +1 -0
  574. package/lib/vite.d.ts +2 -0
  575. package/lib/vite.js +101 -0
  576. package/mail/comment-moderation.html +27 -0
  577. package/mail/comment-moderation.txt +13 -0
  578. package/mail/comment-reply.html +28 -0
  579. package/mail/comment-reply.txt +14 -0
  580. package/mail/invitation.html +25 -0
  581. package/mail/invitation.txt +11 -0
  582. package/mail/member-magic-link.html +23 -0
  583. package/mail/member-magic-link.txt +10 -0
  584. package/mail/newsletter.html +26 -0
  585. package/mail/newsletter.txt +13 -0
  586. package/mail/password-reset.html +26 -0
  587. package/mail/password-reset.txt +10 -0
  588. package/mail/verify-email.html +25 -0
  589. package/mail/verify-email.txt +8 -0
  590. package/package.json +85 -4
@@ -0,0 +1,279 @@
1
+ /**
2
+ * Site health: is this deployment configured the way production needs?
3
+ *
4
+ * Two halves. `gatherFacts` reads the database and the filesystem; the
5
+ * `evaluateHealth` half is a pure function from those facts (and the
6
+ * environment) to a list of checks, each pass / warn / fail with a fix. The
7
+ * split is what lets every rule be tested with a plain object, and keeps the
8
+ * one rule that matters most — **never echo a secret** — in a single place:
9
+ * secrets reach `evaluateHealth` only as the environment, and every check
10
+ * about one reports presence and length, never the value. Connection strings
11
+ * are summarised to a driver name for the same reason: a DATABASE_URL carries
12
+ * its password.
13
+ *
14
+ * Imports nothing outside `node:` so the tests (and a future CLI) can load it
15
+ * directly.
16
+ */
17
+ import { readdirSync } from 'node:fs';
18
+ import { resolve } from 'node:path';
19
+ /** A serverless platform: read-only disk, no long-running process. */
20
+ export function isServerless(env) {
21
+ return Boolean(env.VERCEL || env.AWS_LAMBDA_FUNCTION_NAME || env.NETLIFY || env.K_SERVICE);
22
+ }
23
+ const MIN_APP_KEY = 32;
24
+ const DAY = 86_400_000;
25
+ export function check(id, label, status, message, hint = '') {
26
+ return { id, label, status, message, hint };
27
+ }
28
+ /** "3 minutes ago", for heartbeats. */
29
+ export function ago(iso, now) {
30
+ const ms = now.getTime() - new Date(iso).getTime();
31
+ if (!Number.isFinite(ms))
32
+ return 'at an unknown time';
33
+ if (ms < 90_000)
34
+ return 'just now';
35
+ const minutes = Math.round(ms / 60_000);
36
+ if (minutes < 90)
37
+ return `${minutes} minutes ago`;
38
+ const hours = Math.round(minutes / 60);
39
+ if (hours < 36)
40
+ return `${hours} hours ago`;
41
+ return `${Math.round(hours / 24)} days ago`;
42
+ }
43
+ /** Pending migrations: files present that `_migrations` has no row for. */
44
+ export function pendingMigrations(files, ran) {
45
+ const done = new Set(ran);
46
+ return files.filter((name) => !done.has(name));
47
+ }
48
+ /**
49
+ * Every check, worst first is the caller's business; this returns them in a
50
+ * fixed order so the page does not shuffle between loads.
51
+ */
52
+ export function evaluateHealth(env, facts, now = new Date()) {
53
+ const production = env.NODE_ENV === 'production';
54
+ const serverless = isServerless(env);
55
+ const checks = [];
56
+ // --- Secrets and environment -----------------------------------------------
57
+ const appKey = env.APP_KEY ?? '';
58
+ if (!appKey) {
59
+ checks.push(check('app_key', 'APP_KEY', 'fail', 'Not set.', 'Set APP_KEY to a random string of at least 32 characters: node -e "console.log(crypto.randomBytes(32).toString(\'hex\'))"'));
60
+ }
61
+ else if (appKey === 'your-secret-key-here') {
62
+ checks.push(check('app_key', 'APP_KEY', 'fail', 'Still the placeholder from .env.example.', 'Generate a real key. Changing it signs everyone out, which is the point if the placeholder was ever live.'));
63
+ }
64
+ else if (appKey.length < MIN_APP_KEY) {
65
+ checks.push(check('app_key', 'APP_KEY', production ? 'fail' : 'warn', `Set, ${appKey.length} characters (minimum ${MIN_APP_KEY}).`, 'A short key can be brute-forced offline from any session it signed. Generate a longer one.'));
66
+ }
67
+ else {
68
+ checks.push(check('app_key', 'APP_KEY', 'pass', `Set, ${appKey.length} characters.`));
69
+ }
70
+ checks.push(production
71
+ ? check('node_env', 'NODE_ENV', 'pass', 'production')
72
+ : check('node_env', 'NODE_ENV', serverless ? 'fail' : 'warn', `${env.NODE_ENV || 'unset'} — production safeguards are off.`, 'Set NODE_ENV=production on any deployment people use. It turns on the APP_KEY and URL checks and stops the dev-only fallbacks.'));
73
+ const [major] = facts.nodeVersion.split('.').map(Number);
74
+ checks.push(major >= 24
75
+ ? check('node_version', 'Node.js', 'pass', `v${facts.nodeVersion}`)
76
+ : check('node_version', 'Node.js', 'fail', `v${facts.nodeVersion}; 24 or newer is required.`, 'The SQLite driver and TypeScript stripping need Node 24. Upgrade the runtime (on Vercel: Project Settings → Node.js Version).'));
77
+ checks.push(check('framework_version', 'Framework', facts.frameworkVersion ? 'pass' : 'warn', facts.frameworkVersion ? `@basicbenframework/core ${facts.frameworkVersion}` : 'Could not read the installed version.', facts.frameworkVersion ? '' : 'Run npm ci; the framework package may be missing from this deployment.'));
78
+ // --- Database --------------------------------------------------------------
79
+ const driver = facts.dbDriver;
80
+ if (driver === 'sqlite' && serverless) {
81
+ checks.push(check('database', 'Database', 'fail', 'SQLite file on a serverless host.', 'The disk here is ephemeral: every cold start gets an empty database. Use Turso (TURSO_URL + TURSO_AUTH_TOKEN) or Postgres (DATABASE_URL).'));
82
+ }
83
+ else if (driver === 'sqlite' && production) {
84
+ checks.push(check('database', 'Database', 'warn', 'SQLite file.', 'Fine on one persistent server — make sure the file is on a volume that survives redeploys, and back it up (npm run backup).'));
85
+ }
86
+ else {
87
+ checks.push(check('database', 'Database', 'pass', `${driver}`));
88
+ }
89
+ if (facts.migrationFiles === null) {
90
+ checks.push(check('migrations', 'Migrations', 'warn', `${facts.migrationsRan.length} recorded as run; this deployment does not ship its migration files, so pending ones cannot be listed.`, 'Run `npm run migrate:status` from a checkout against the production database after each deploy.'));
91
+ }
92
+ else {
93
+ const pending = pendingMigrations(facts.migrationFiles, facts.migrationsRan);
94
+ checks.push(pending.length
95
+ ? check('migrations', 'Migrations', 'fail', `${pending.length} pending: ${pending.slice(0, 5).join(', ')}${pending.length > 5 ? ', …' : ''}`, 'Run `npm run migrate` against this database. Features whose tables are missing will error until you do.')
96
+ : check('migrations', 'Migrations', 'pass', `All ${facts.migrationFiles.length} applied.`));
97
+ }
98
+ // --- Storage and mail ------------------------------------------------------
99
+ if (facts.storageDriver === 'local') {
100
+ checks.push(serverless
101
+ ? check('storage', 'Media storage', 'fail', 'Local disk on a serverless host — uploads cannot work.', 'Configure object storage: S3_BUCKET, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_ENDPOINT, S3_PUBLIC_URL (R2, S3, B2, MinIO all work).')
102
+ : check('storage', 'Media storage', production ? 'warn' : 'pass', 'Local disk (public/uploads).', production ? 'Uploads live on this machine only and are not in the JSON backup. Use object storage, or back the directory up separately.' : ''));
103
+ }
104
+ else {
105
+ const publicUrl = Boolean(env.S3_PUBLIC_URL);
106
+ checks.push(check('storage', 'Media storage', publicUrl ? 'pass' : 'warn', `${facts.storageDriver} (bucket set, access key ${env.S3_ACCESS_KEY_ID ? 'set' : 'missing'}, secret ${env.S3_SECRET_ACCESS_KEY ? 'set' : 'missing'}${publicUrl ? ', public URL set' : ''}).`, publicUrl ? 'Use "Run storage probe" to confirm the credentials can write, read and delete.' : 'Set S3_PUBLIC_URL to the bucket\'s public or CDN address, or media URLs point at the private API host.'));
107
+ }
108
+ if (facts.mailTransport === 'console') {
109
+ checks.push(check('mail', 'Email', production ? 'warn' : 'pass', 'Console transport — mail is printed to the log, not sent.', production ? 'Set RESEND_API_KEY, or configure SMTP in basicben.config.js. Until then password resets, invitations and verification emails go nowhere.' : ''));
110
+ }
111
+ else {
112
+ const testSender = /onboarding@resend\.dev/i.test(facts.mailFrom ?? '');
113
+ checks.push(check('mail', 'Email', testSender && production ? 'warn' : 'pass', `${facts.mailTransport} transport${facts.mailFrom ? `, from ${facts.mailFrom}` : ''}.`, testSender && production ? "MAIL_FROM is Resend's test sender, which only delivers to your own Resend account. Set MAIL_FROM to an address on a verified domain." : 'Use "Send test email" to confirm delivery.'));
114
+ }
115
+ // --- URLs and proxies ------------------------------------------------------
116
+ const publicUrl = env.SITE_URL || env.APP_URL || '';
117
+ const which = env.SITE_URL ? 'SITE_URL' : 'APP_URL';
118
+ if (!publicUrl) {
119
+ checks.push(check('site_url', 'Site URL', production ? 'fail' : 'warn', 'Neither SITE_URL nor APP_URL is set.', 'Set APP_URL (this app) and SITE_URL (the public front end, if separate). Feeds, the sitemap and email links are built from them.'));
120
+ }
121
+ else {
122
+ let url = null;
123
+ try {
124
+ url = new URL(publicUrl);
125
+ }
126
+ catch { /* reported below */ }
127
+ if (!url) {
128
+ checks.push(check('site_url', 'Site URL', 'fail', `${which} is not a valid URL.`, 'Use a full origin such as https://example.com.'));
129
+ }
130
+ else if (production && url.protocol !== 'https:') {
131
+ checks.push(check('site_url', 'Site URL', 'fail', `${which} is ${url.origin} — not https.`, 'Serve the site over https and update the variable. Links in feeds and emails use it as written.'));
132
+ }
133
+ else if (production && /^(localhost|127\.|0\.0\.0\.0|\[::1\])/.test(url.hostname)) {
134
+ checks.push(check('site_url', 'Site URL', 'warn', `${which} points at ${url.hostname}.`, 'Set it to the public address.'));
135
+ }
136
+ else {
137
+ checks.push(check('site_url', 'Site URL', 'pass', `${which} = ${url.origin}`));
138
+ }
139
+ }
140
+ const trust = env.TRUST_PROXY ?? '';
141
+ const validTrust = trust === '' || trust === 'true' || trust === 'false' || /^\d+$/.test(trust);
142
+ if (!validTrust) {
143
+ checks.push(check('trust_proxy', 'TRUST_PROXY', 'warn', 'Set to a value it does not understand; treated as off.', 'Use `true` (one proxy) or the number of proxies in front of the app.'));
144
+ }
145
+ else if ((trust === '' || trust === 'false') && serverless) {
146
+ checks.push(check('trust_proxy', 'TRUST_PROXY', 'warn', 'Off, behind a platform proxy.', 'Every visitor appears to come from the platform\'s proxy, so they share one rate-limit bucket. Set TRUST_PROXY=1 on Vercel.'));
147
+ }
148
+ else if (/^\d+$/.test(trust) && Number(trust) > 3) {
149
+ checks.push(check('trust_proxy', 'TRUST_PROXY', 'warn', `Trusts ${trust} proxies.`, 'More hops than any real chain usually has. If too many are trusted, the client chooses its own address and walks past every rate limit.'));
150
+ }
151
+ else {
152
+ checks.push(check('trust_proxy', 'TRUST_PROXY', 'pass', trust && trust !== 'false' ? `Trusting ${trust === 'true' ? '1 proxy' : `${trust} proxies`}.` : 'Off (direct connections).', trust && trust !== 'false' ? 'Only correct when the app is reachable solely through that proxy.' : ''));
153
+ }
154
+ // --- Integrations ----------------------------------------------------------
155
+ const webhooks = (facts.settings.webhook_urls ?? '').split('\n').map((line) => line.trim()).filter(Boolean);
156
+ const webhookSecret = env.WEBHOOK_SECRET ?? '';
157
+ if (webhooks.length && !webhookSecret) {
158
+ checks.push(check('webhook_secret', 'Webhook secret', 'fail', `${webhooks.length} webhook URL(s) configured, WEBHOOK_SECRET not set — nothing is being sent.`, 'Set WEBHOOK_SECRET (32+ random characters) and share it with each receiver so they can verify deliveries.'));
159
+ }
160
+ else if (webhookSecret && webhookSecret.length < 32) {
161
+ checks.push(check('webhook_secret', 'Webhook secret', 'warn', `Set, ${webhookSecret.length} characters.`, 'Use at least 32 random characters.'));
162
+ }
163
+ else {
164
+ checks.push(check('webhook_secret', 'Webhook secret', 'pass', webhooks.length ? `Set, ${webhookSecret.length} characters; ${webhooks.length} receiver(s).` : `No webhooks configured${webhookSecret ? ' (secret set)' : ''}.`));
165
+ }
166
+ const cronSecret = env.CRON_SECRET ?? '';
167
+ if (!cronSecret && serverless) {
168
+ checks.push(check('cron_secret', 'CRON_SECRET', 'warn', 'Not set on a serverless host.', 'Without it GET /api/cron/tick is disabled, so scheduled work (announcing scheduled posts, sweeps, anything a feature schedules) waits for traffic. Set CRON_SECRET and schedule /api/cron/tick in vercel.json.'));
169
+ }
170
+ else if (cronSecret && cronSecret.length < 16) {
171
+ checks.push(check('cron_secret', 'CRON_SECRET', 'warn', `Set, ${cronSecret.length} characters.`, 'Use at least 16 random characters.'));
172
+ }
173
+ else {
174
+ checks.push(check('cron_secret', 'CRON_SECRET', 'pass', cronSecret ? `Set, ${cronSecret.length} characters.` : 'Not set (a long-running server runs its own interval).'));
175
+ }
176
+ checks.push(production && env.DISABLE_REGISTRATION !== 'true'
177
+ ? check('registration', 'Registration', 'warn', 'Open — anyone can create an account.', 'Set DISABLE_REGISTRATION=true and invite people from Users instead, unless open sign-up is the intent.')
178
+ : check('registration', 'Registration', 'pass', env.DISABLE_REGISTRATION === 'true' ? 'Disabled; accounts are by invitation.' : 'Open (fine outside production).'));
179
+ checks.push(facts.settings.public_api === 'true'
180
+ ? check('public_api', 'Public content API', 'pass', 'On — /api/v1 answers without a token.', 'Intended for a public site. Drafts and private content are never served either way.')
181
+ : check('public_api', 'Public content API', 'pass', 'Off — /api/v1 needs an API token or a session.', 'Turn it on in Settings if a browser-side front end reads the API directly.'));
182
+ // --- Jobs ------------------------------------------------------------------
183
+ const publish = facts.heartbeats.publish_due;
184
+ if (facts.dueUnannounced > 0 && (!publish || now.getTime() - new Date(publish.last_run_at).getTime() > 15 * 60_000)) {
185
+ checks.push(check('publish_due', 'Scheduled publishing', 'warn', `${facts.dueUnannounced} scheduled post(s) are live but not yet announced; last check ${publish ? ago(publish.last_run_at, now) : 'never'}.`, 'Webhooks and newsletters for them have not fired. Point a cron at GET /api/cron/publish-due with CRON_SECRET, or read /api/v1/posts once.'));
186
+ }
187
+ else {
188
+ checks.push(check('publish_due', 'Scheduled publishing', 'pass', publish ? `Last checked ${ago(publish.last_run_at, now)}.` : 'No run recorded yet; nothing is waiting.'));
189
+ }
190
+ const backup = facts.heartbeats.backup;
191
+ if (!backup) {
192
+ checks.push(check('backup', 'Backups', 'warn', 'No backup recorded by `npm run backup`.', 'Schedule `npm run backup -- --gzip --s3 --keep 14` (docs/backup.md). If you rely on your database host\'s point-in-time recovery instead, this can be ignored.'));
193
+ }
194
+ else {
195
+ const old = now.getTime() - new Date(backup.last_run_at).getTime() > 8 * DAY;
196
+ checks.push(check('backup', 'Backups', old ? 'warn' : 'pass', `Last backup ${ago(backup.last_run_at, now)}.`, old ? 'Backups seem to have stopped. Check the job that runs `npm run backup`.' : ''));
197
+ }
198
+ if (facts.rateLimitRows === null) {
199
+ checks.push(check('rate_limits', 'Rate-limit table', 'warn', 'Could not be read.', 'Run migrations.'));
200
+ }
201
+ else {
202
+ checks.push(facts.rateLimitRows > 50_000
203
+ ? check('rate_limits', 'Rate-limit table', 'warn', `${facts.rateLimitRows.toLocaleString('en')} rows.`, 'Stale entries are not being swept. Call GET /api/cron/tick from a cron (with CRON_SECRET).')
204
+ : check('rate_limits', 'Rate-limit table', 'pass', `${facts.rateLimitRows.toLocaleString('en')} rows.`));
205
+ }
206
+ checks.push(facts.adminsWithout2fa > 0
207
+ ? check('admin_2fa', 'Admin two-factor', 'warn', `${facts.adminsWithout2fa} of ${facts.adminsTotal} admin account(s) have no authenticator app set up.`, 'Ask each admin to enable two-factor on their Profile. An admin account can export every user\'s address.')
208
+ : check('admin_2fa', 'Admin two-factor', 'pass', `All ${facts.adminsTotal} admin account(s) use two-factor.`));
209
+ return checks;
210
+ }
211
+ /** The worst status in a list: what the page's banner shows. */
212
+ export function overallStatus(checks) {
213
+ if (checks.some((c) => c.status === 'fail'))
214
+ return 'fail';
215
+ if (checks.some((c) => c.status === 'warn'))
216
+ return 'warn';
217
+ return 'pass';
218
+ }
219
+ /**
220
+ * Migration names in the migrator's directories, as it names them: the
221
+ * config's `migrations` list (defineSite sets the CMS's, then the site's), or
222
+ * one directory. Null when none can be read, which is a deployment that does
223
+ * not ship them; a missing site directory alongside the CMS's is just empty.
224
+ */
225
+ export function migrationFilesIn(dirs) {
226
+ let found = false;
227
+ const names = [];
228
+ for (const dir of Array.isArray(dirs) ? dirs : [dirs]) {
229
+ try {
230
+ names.push(...readdirSync(resolve(process.cwd(), dir))
231
+ .filter((name) => /\.(m?[jt]s)$/.test(name) && !/\.(test|spec)\.(m?[jt]s)$/.test(name))
232
+ .map((name) => name.replace(/\.(m?[jt]s)$/, '')));
233
+ found = true;
234
+ }
235
+ catch {
236
+ // Not shipped, or a site with none of its own.
237
+ }
238
+ }
239
+ return found ? names.sort() : null;
240
+ }
241
+ const count = async (db, sql, params = []) => {
242
+ try {
243
+ const row = await db.get(sql, params);
244
+ return Number(row?.n ?? 0);
245
+ }
246
+ catch {
247
+ return null;
248
+ }
249
+ };
250
+ /**
251
+ * The database-side facts. Every query tolerates a missing table — a health
252
+ * page that 500s on an unmigrated database is no help diagnosing one.
253
+ */
254
+ export async function databaseFacts(db, now = new Date()) {
255
+ let migrationsRan = [];
256
+ try {
257
+ migrationsRan = (await db.all('SELECT migration FROM _migrations')).map((row) => row.migration);
258
+ }
259
+ catch {
260
+ migrationsRan = [];
261
+ }
262
+ let settings = {};
263
+ try {
264
+ const rows = (await db.all("SELECT key, value FROM settings WHERE key IN ('public_api', 'webhook_urls')"));
265
+ settings = Object.fromEntries(rows.map((row) => [row.key, row.value ?? '']));
266
+ }
267
+ catch {
268
+ settings = {};
269
+ }
270
+ const activeAdmin = "role = 'admin' AND disabled_at IS NULL";
271
+ return {
272
+ migrationsRan,
273
+ settings,
274
+ rateLimitRows: await count(db, 'SELECT COUNT(*) AS n FROM rate_limits'),
275
+ adminsTotal: (await count(db, `SELECT COUNT(*) AS n FROM users WHERE ${activeAdmin}`)) ?? 0,
276
+ adminsWithout2fa: (await count(db, `SELECT COUNT(*) AS n FROM users WHERE ${activeAdmin}
277
+ AND id NOT IN (SELECT user_id FROM user_two_factor WHERE totp_enabled_at IS NOT NULL)`)) ?? 0,
278
+ };
279
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Heartbeats for background jobs: "this ran, at this time, and found this".
3
+ *
4
+ * Read by the site health page; written by scheduled publishing, the
5
+ * analytics purge and `basicben-cms backup`. See migration 037 for why this is
6
+ * a table of its own.
7
+ *
8
+ * Imports nothing and takes the database handle as an argument, for the same
9
+ * reason as `export-data.ts`: the backup script loads it with plain Node, and
10
+ * recording a row should not load the app.
11
+ *
12
+ * Recording is best-effort everywhere it is called. A heartbeat is a report
13
+ * about a job, and a job must never fail because its report could not be
14
+ * written — on a database that has not run migration 037 yet, for one.
15
+ */
16
+ export interface HeartbeatDb {
17
+ driver?: string;
18
+ get: (sql: string, params?: unknown[]) => unknown;
19
+ all: (sql: string, params?: unknown[]) => unknown;
20
+ run: (sql: string, params?: unknown[]) => unknown;
21
+ }
22
+ export interface Heartbeat {
23
+ name: string;
24
+ last_run_at: string;
25
+ detail: Record<string, unknown> | null;
26
+ }
27
+ /** The jobs that report in. Named so the health page can say which never has. */
28
+ export declare const HEARTBEATS: {
29
+ readonly PUBLISH_DUE: "publish_due";
30
+ readonly BACKUP: "backup";
31
+ };
32
+ /** Upsert the job's row. Never throws. */
33
+ export declare function recordHeartbeat(db: HeartbeatDb, name: string, detail?: Record<string, unknown>, now?: Date): Promise<void>;
34
+ /** Every recorded heartbeat, keyed by name. Empty if the table is missing. */
35
+ export declare function readHeartbeats(db: HeartbeatDb): Promise<Record<string, Heartbeat>>;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Heartbeats for background jobs: "this ran, at this time, and found this".
3
+ *
4
+ * Read by the site health page; written by scheduled publishing, the
5
+ * analytics purge and `basicben-cms backup`. See migration 037 for why this is
6
+ * a table of its own.
7
+ *
8
+ * Imports nothing and takes the database handle as an argument, for the same
9
+ * reason as `export-data.ts`: the backup script loads it with plain Node, and
10
+ * recording a row should not load the app.
11
+ *
12
+ * Recording is best-effort everywhere it is called. A heartbeat is a report
13
+ * about a job, and a job must never fail because its report could not be
14
+ * written — on a database that has not run migration 037 yet, for one.
15
+ */
16
+ /** The jobs that report in. Named so the health page can say which never has. */
17
+ export const HEARTBEATS = {
18
+ PUBLISH_DUE: 'publish_due',
19
+ BACKUP: 'backup'
20
+ };
21
+ /** Upsert the job's row. Never throws. */
22
+ export async function recordHeartbeat(db, name, detail = {}, now = new Date()) {
23
+ try {
24
+ const at = now.toISOString();
25
+ const json = JSON.stringify(detail).slice(0, 1000);
26
+ await db.run(`INSERT INTO ops_heartbeats (name, last_run_at, detail) VALUES (?, ?, ?)
27
+ ON CONFLICT(name) DO UPDATE SET last_run_at = excluded.last_run_at, detail = excluded.detail`, [name, at, json]);
28
+ }
29
+ catch {
30
+ // See the file comment: best-effort by design.
31
+ }
32
+ }
33
+ /** Every recorded heartbeat, keyed by name. Empty if the table is missing. */
34
+ export async function readHeartbeats(db) {
35
+ try {
36
+ const rows = (await db.all('SELECT name, last_run_at, detail FROM ops_heartbeats'));
37
+ const out = {};
38
+ for (const row of rows) {
39
+ let detail = null;
40
+ try {
41
+ detail = row.detail ? JSON.parse(row.detail) : null;
42
+ }
43
+ catch {
44
+ detail = null;
45
+ }
46
+ // Postgres hands a TIMESTAMP back as a Date; SQLite as the text written.
47
+ const at = row.last_run_at instanceof Date ? row.last_run_at.toISOString() : String(row.last_run_at);
48
+ out[row.name] = { name: row.name, last_run_at: at, detail };
49
+ }
50
+ return out;
51
+ }
52
+ catch {
53
+ return {};
54
+ }
55
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Read an image's dimensions, and its real format, from its first bytes.
3
+ *
4
+ * Every format worth uploading puts its size in a fixed or near-fixed place in
5
+ * its header, so this needs no image library — only a few hundred bytes for
6
+ * PNG, GIF and WebP, and the marker segments before the first frame for JPEG.
7
+ * AVIF is ISOBMFF; its `ispe` box carries the size.
8
+ *
9
+ * The detected format also checks the upload: a file whose bytes are not the
10
+ * image type it was declared as is refused at confirm time, which is what
11
+ * stops an HTML or SVG document being stored behind an `image/png` label.
12
+ */
13
+ export interface ImageInfo {
14
+ type: 'image/png' | 'image/gif' | 'image/jpeg' | 'image/webp' | 'image/avif';
15
+ width: number;
16
+ height: number;
17
+ }
18
+ export declare function imageSize(bytes: Uint8Array): ImageInfo | null;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Read an image's dimensions, and its real format, from its first bytes.
3
+ *
4
+ * Every format worth uploading puts its size in a fixed or near-fixed place in
5
+ * its header, so this needs no image library — only a few hundred bytes for
6
+ * PNG, GIF and WebP, and the marker segments before the first frame for JPEG.
7
+ * AVIF is ISOBMFF; its `ispe` box carries the size.
8
+ *
9
+ * The detected format also checks the upload: a file whose bytes are not the
10
+ * image type it was declared as is refused at confirm time, which is what
11
+ * stops an HTML or SVG document being stored behind an `image/png` label.
12
+ */
13
+ export function imageSize(bytes) {
14
+ const b = bytes;
15
+ const view = new DataView(b.buffer, b.byteOffset, b.byteLength);
16
+ const ascii = (offset, length) => offset + length <= b.length ? String.fromCharCode(...b.subarray(offset, offset + length)) : '';
17
+ // PNG: signature, then IHDR with big-endian width and height.
18
+ if (b.length >= 24 && b[0] === 0x89 && ascii(1, 3) === 'PNG' && ascii(12, 4) === 'IHDR') {
19
+ return valid({ type: 'image/png', width: view.getUint32(16), height: view.getUint32(20) });
20
+ }
21
+ // GIF: logical screen size, little-endian.
22
+ if (b.length >= 10 && (ascii(0, 6) === 'GIF87a' || ascii(0, 6) === 'GIF89a')) {
23
+ return valid({ type: 'image/gif', width: view.getUint16(6, true), height: view.getUint16(8, true) });
24
+ }
25
+ // WebP: RIFF container, three chunk flavours.
26
+ if (b.length >= 30 && ascii(0, 4) === 'RIFF' && ascii(8, 4) === 'WEBP') {
27
+ const chunk = ascii(12, 4);
28
+ if (chunk === 'VP8 ') {
29
+ return valid({ type: 'image/webp', width: view.getUint16(26, true) & 0x3fff, height: view.getUint16(28, true) & 0x3fff });
30
+ }
31
+ if (chunk === 'VP8L') {
32
+ const bits = view.getUint32(21, true);
33
+ return valid({ type: 'image/webp', width: (bits & 0x3fff) + 1, height: ((bits >> 14) & 0x3fff) + 1 });
34
+ }
35
+ if (chunk === 'VP8X') {
36
+ const width = 1 + (b[24] | (b[25] << 8) | (b[26] << 16));
37
+ const height = 1 + (b[27] | (b[28] << 8) | (b[29] << 16));
38
+ return valid({ type: 'image/webp', width, height });
39
+ }
40
+ return null;
41
+ }
42
+ // JPEG: walk the marker segments to the first start-of-frame.
43
+ if (b.length >= 4 && b[0] === 0xff && b[1] === 0xd8) {
44
+ let offset = 2;
45
+ while (offset + 9 < b.length) {
46
+ if (b[offset] !== 0xff)
47
+ return null;
48
+ const marker = b[offset + 1];
49
+ // Fill bytes and standalone markers carry no length.
50
+ if (marker === 0xff) {
51
+ offset++;
52
+ continue;
53
+ }
54
+ if (marker === 0xd8 || marker === 0x01 || (marker >= 0xd0 && marker <= 0xd7)) {
55
+ offset += 2;
56
+ continue;
57
+ }
58
+ const length = view.getUint16(offset + 2);
59
+ const isFrame = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
60
+ if (isFrame) {
61
+ return valid({ type: 'image/jpeg', height: view.getUint16(offset + 5), width: view.getUint16(offset + 7) });
62
+ }
63
+ if (length < 2)
64
+ return null;
65
+ offset += 2 + length;
66
+ }
67
+ return null;
68
+ }
69
+ // AVIF: an `ftyp` brand of avif/avis, then an `ispe` box somewhere in meta.
70
+ if (b.length >= 12 && ascii(4, 4) === 'ftyp' && ['avif', 'avis'].includes(ascii(8, 4))) {
71
+ for (let i = 0; i + 20 <= b.length; i++) {
72
+ if (b[i] === 0x69 && ascii(i, 4) === 'ispe') {
73
+ return valid({ type: 'image/avif', width: view.getUint32(i + 8), height: view.getUint32(i + 12) });
74
+ }
75
+ }
76
+ return null;
77
+ }
78
+ return null;
79
+ }
80
+ function valid(info) {
81
+ const ok = (n) => Number.isInteger(n) && n > 0 && n <= 100_000;
82
+ return ok(info.width) && ok(info.height) ? info : null;
83
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Responsive image URLs, without resizing anything here.
3
+ *
4
+ * Making smaller copies of an image needs an image library — native (sharp) or
5
+ * WASM — and this project ships no runtime dependencies. Every CDN worth using
6
+ * already resizes on request, so instead of storing variants this builds URLs
7
+ * for one: set IMAGE_TRANSFORM_URL to a template and each image gets a srcset.
8
+ *
9
+ * Cloudflare https://example.com/cdn-cgi/image/width={width},format=auto/{url}
10
+ * imgix {url}?w={width}&auto=format
11
+ * Bunny {url}?width={width}
12
+ * imgproxy https://imgproxy.example.com/insecure/rs:fit:{width}/plain/{url}
13
+ *
14
+ * `{url}` is the original's absolute URL and `{width}` the target width; add
15
+ * `{url_encoded}` if the service wants it encoded. Unset, images get their
16
+ * dimensions and no srcset, which is still enough to stop layout shift.
17
+ */
18
+ export interface ResponsiveImage {
19
+ url: string;
20
+ width: number | null;
21
+ height: number | null;
22
+ alt: string | null;
23
+ srcset: string | null;
24
+ }
25
+ export declare function responsiveImage(url: string | null, meta?: {
26
+ width?: number | null;
27
+ height?: number | null;
28
+ alt?: string | null;
29
+ }): ResponsiveImage | null;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Responsive image URLs, without resizing anything here.
3
+ *
4
+ * Making smaller copies of an image needs an image library — native (sharp) or
5
+ * WASM — and this project ships no runtime dependencies. Every CDN worth using
6
+ * already resizes on request, so instead of storing variants this builds URLs
7
+ * for one: set IMAGE_TRANSFORM_URL to a template and each image gets a srcset.
8
+ *
9
+ * Cloudflare https://example.com/cdn-cgi/image/width={width},format=auto/{url}
10
+ * imgix {url}?w={width}&auto=format
11
+ * Bunny {url}?width={width}
12
+ * imgproxy https://imgproxy.example.com/insecure/rs:fit:{width}/plain/{url}
13
+ *
14
+ * `{url}` is the original's absolute URL and `{width}` the target width; add
15
+ * `{url_encoded}` if the service wants it encoded. Unset, images get their
16
+ * dimensions and no srcset, which is still enough to stop layout shift.
17
+ */
18
+ const WIDTHS = [320, 640, 960, 1280, 1920, 2560];
19
+ export function responsiveImage(url, meta = {}) {
20
+ if (!url)
21
+ return null;
22
+ const width = meta.width ? Number(meta.width) : null;
23
+ const height = meta.height ? Number(meta.height) : null;
24
+ const template = process.env.IMAGE_TRANSFORM_URL;
25
+ let srcset = null;
26
+ if (template && width) {
27
+ // Never upscale: offer the steps below the original, then the original.
28
+ const steps = WIDTHS.filter((w) => w < width);
29
+ srcset = [
30
+ ...steps.map((w) => `${transform(template, url, w)} ${w}w`),
31
+ `${transform(template, url, width)} ${width}w`
32
+ ].join(', ');
33
+ }
34
+ return { url, width, height, alt: meta.alt ?? null, srcset };
35
+ }
36
+ function transform(template, url, width) {
37
+ return template
38
+ .replaceAll('{url_encoded}', encodeURIComponent(url))
39
+ .replaceAll('{url}', url)
40
+ .replaceAll('{width}', String(width));
41
+ }
@@ -0,0 +1,11 @@
1
+ /** The CMS's templates. A URL Vercel's tracer follows into the function. */
2
+ export declare const CMS_MAIL: string;
3
+ /** The site's overrides, relative to where the site runs. */
4
+ export declare const SITE_MAIL = "mail";
5
+ type Parts = {
6
+ text?: string;
7
+ html?: string;
8
+ };
9
+ /** Render a template's text and HTML parts. Throws when neither directory has it. */
10
+ export declare function renderMail(name: string, data?: Record<string, unknown>): Parts;
11
+ export {};
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Mail templates: the site's own first, then the CMS's.
3
+ *
4
+ * A site overrides one template by putting a file of the same name in its
5
+ * mail/ directory. The lookup is per file, so it can replace the HTML part
6
+ * alone and keep the CMS's text part. Everything it does not override comes
7
+ * from the CMS's mail/, found beside src/ in the repository and beside lib/
8
+ * in the package.
9
+ *
10
+ * Core's renderMail reads one directory; this calls it for each.
11
+ */
12
+ import { existsSync } from 'node:fs';
13
+ import { resolve } from 'node:path';
14
+ import { fileURLToPath } from 'node:url';
15
+ import { renderMail as renderFrom } from '@basicbenframework/core/mail';
16
+ /** The CMS's templates. A URL Vercel's tracer follows into the function. */
17
+ export const CMS_MAIL = fileURLToPath(new URL('../../mail/', import.meta.url));
18
+ /** The site's overrides, relative to where the site runs. */
19
+ export const SITE_MAIL = 'mail';
20
+ function partsIn(dir, name, data) {
21
+ const has = (ext) => existsSync(resolve(process.cwd(), dir, `${name}.${ext}`));
22
+ if (!has('txt') && !has('html'))
23
+ return {};
24
+ return renderFrom(name, data, dir);
25
+ }
26
+ /** Render a template's text and HTML parts. Throws when neither directory has it. */
27
+ export function renderMail(name, data = {}) {
28
+ const site = resolve(process.cwd(), SITE_MAIL);
29
+ const own = site === resolve(CMS_MAIL) ? {} : partsIn(SITE_MAIL, name, data);
30
+ const cms = partsIn(CMS_MAIL, name, data);
31
+ const out = {};
32
+ const text = own.text ?? cms.text;
33
+ const html = own.html ?? cms.html;
34
+ if (text !== undefined)
35
+ out.text = text;
36
+ if (html !== undefined)
37
+ out.html = html;
38
+ if (!out.text && !out.html) {
39
+ throw new Error(`No mail template named "${name}" in the site's mail/ or the CMS's (expected ${name}.txt or ${name}.html)`);
40
+ }
41
+ return out;
42
+ }
@@ -0,0 +1,28 @@
1
+ import type { Request, Response } from '../types/index.ts';
2
+ /**
3
+ * Tell listeners about scheduled posts whose time has come.
4
+ *
5
+ * A scheduled post appears on the public site by itself — every read filters
6
+ * on `publish_at` — but nothing *happens* at that moment, so a webhook
7
+ * consumer rebuilding a static site would never hear about it. This finds the
8
+ * posts that have gone live since they were last announced, fires
9
+ * `post.updated` for each (the same event a manual publish fires, so existing
10
+ * consumers need no changes), and marks them announced.
11
+ *
12
+ * Three things call it, so it works on any host:
13
+ * - an interval on a long-running server (see `src/hooks.ts`);
14
+ * - `GET /api/cron/publish-due`, for a platform scheduler such as Vercel Cron;
15
+ * - the content API, at most once a minute, so a serverless deploy with no
16
+ * scheduler still announces a post the first time anyone reads the site.
17
+ */
18
+ export declare function publishDue(): Promise<number>;
19
+ /** Middleware: run `publishDue` if a minute has passed since it last ran. */
20
+ export declare function publishDueOpportunistically(_req: Request, _res: Response, next: () => void): Promise<void>;
21
+ /**
22
+ * `GET /api/cron/publish-due`, for a platform scheduler.
23
+ *
24
+ * Requires `Authorization: Bearer $CRON_SECRET` — the header Vercel Cron sends
25
+ * — so the endpoint cannot be used to make the server do work on demand. With
26
+ * no CRON_SECRET configured it is disabled.
27
+ */
28
+ export declare function publishDueEndpoint(req: Request, res: Response): Promise<void>;