@momentumcms/server-express 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@momentumcms/server-express",
3
+ "version": "0.1.0",
4
+ "description": "Express adapter for Momentum CMS with Angular SSR support",
5
+ "license": "MIT",
6
+ "author": "Momentum CMS Contributors",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/momentum-cms/momentum-cms.git",
10
+ "directory": "libs/server-express"
11
+ },
12
+ "homepage": "https://github.com/momentum-cms/momentum-cms#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/momentum-cms/momentum-cms/issues"
15
+ },
16
+ "keywords": [
17
+ "cms",
18
+ "momentum-cms",
19
+ "express",
20
+ "ssr",
21
+ "angular",
22
+ "server"
23
+ ],
24
+ "engines": {
25
+ "node": ">=18"
26
+ },
27
+ "type": "commonjs",
28
+ "main": "./index.cjs",
29
+ "types": "./index.d.ts",
30
+ "peerDependencies": {
31
+ "@angular/core": "^19.0.0 || ^20.0.0 || ^21.0.0",
32
+ "@momentumcms/auth": ">=0.0.1",
33
+ "@momentumcms/core": ">=0.0.1",
34
+ "@momentumcms/logger": ">=0.0.1",
35
+ "@momentumcms/plugins-core": ">=0.0.1",
36
+ "@momentumcms/server-core": ">=0.0.1",
37
+ "better-auth": "^1.0.0",
38
+ "better-sqlite3": "^12.0.0",
39
+ "express": "^4.18.0 || ^5.0.0",
40
+ "multer": "^2.0.0",
41
+ "pg": "^8.0.0"
42
+ },
43
+ "dependencies": {
44
+ "@aws-sdk/client-s3": "^3.983.0",
45
+ "@aws-sdk/s3-request-presigner": "^3.983.0",
46
+ "graphql": "^16.12.0",
47
+ "nodemailer": "^8.0.0"
48
+ }
49
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './lib/server-express';
2
+ export { createAuthMiddleware, createProtectMiddleware, createSessionResolverMiddleware, createDeferredSessionResolver, type AuthenticatedRequest, type AuthMiddlewareOptions, } from './lib/auth-middleware';
3
+ export { createSetupMiddleware, type SetupStatus, type SetupMiddlewareConfig, } from './lib/setup-middleware';
4
+ export { createApiKeyResolverMiddleware, createApiKeyRoutes, type ApiKeyMiddlewareConfig, } from './lib/api-key-middleware';
5
+ export { initializeMomentum, createHealthMiddleware, type MomentumInitResult, type SeedingStatus, type InitializeMomentumOptions, type HealthMiddlewareOptions, type HealthResponse, } from './lib/init-helpers';
6
+ export { getPluginProviders } from './lib/plugin-middleware-registry';
7
+ export { createMomentumServer, type CreateMomentumServerOptions, type MomentumServer, } from './lib/create-momentum-server';
@@ -0,0 +1,43 @@
1
+ import type { Router, Response, NextFunction } from 'express';
2
+ import type { ApiKeyStore } from '@momentumcms/server-core';
3
+ import type { AuthenticatedRequest } from './auth-middleware';
4
+ /**
5
+ * Configuration for API key middleware.
6
+ */
7
+ export interface ApiKeyMiddlewareConfig {
8
+ /** The API key store for database operations */
9
+ store: ApiKeyStore;
10
+ }
11
+ /**
12
+ * Creates middleware that resolves API key from X-API-Key header.
13
+ *
14
+ * If a valid API key is found, sets req.user with the key's role.
15
+ * If no API key header is present, passes through (session auth may handle it).
16
+ * If an invalid/expired key is provided, returns 401.
17
+ *
18
+ * Should be placed BEFORE session resolver middleware so both auth methods work.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * app.use(createApiKeyResolverMiddleware({ store: apiKeyStore }));
23
+ * app.use(createSessionResolverMiddleware(auth));
24
+ * app.use('/api', momentumApiMiddleware(config));
25
+ * ```
26
+ */
27
+ export declare function createApiKeyResolverMiddleware(config: ApiKeyMiddlewareConfig): (req: AuthenticatedRequest, res: Response, next: NextFunction) => Promise<void>;
28
+ /**
29
+ * Creates Express router for API key management endpoints.
30
+ *
31
+ * All endpoints require authentication. Admin sees all keys, non-admin sees own.
32
+ *
33
+ * Endpoints:
34
+ * - GET /api-keys - List API keys (admin: all, others: own)
35
+ * - POST /api-keys - Create a new API key
36
+ * - DELETE /api-keys/:id - Delete an API key (admin: any, others: own)
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * app.use('/api', createApiKeyRoutes({ store: apiKeyStore }));
41
+ * ```
42
+ */
43
+ export declare function createApiKeyRoutes(config: ApiKeyMiddlewareConfig): Router;
@@ -0,0 +1,83 @@
1
+ import type { Router, Request, Response, NextFunction, RequestHandler } from 'express';
2
+ import type { MomentumAuth, MomentumAuthPlugin, OAuthProvidersConfig } from '@momentumcms/auth';
3
+ /**
4
+ * Extended Request type with auth session data.
5
+ */
6
+ export interface AuthenticatedRequest extends Request {
7
+ user?: unknown;
8
+ authSession?: unknown;
9
+ }
10
+ /**
11
+ * Creates Express middleware to handle Better Auth routes.
12
+ *
13
+ * Mounts Better Auth at /auth/* path. All auth endpoints like
14
+ * /auth/sign-in/email, /auth/sign-up/email, /auth/sign-out, /auth/get-session
15
+ * are automatically handled.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { createAuthMiddleware } from '@momentumcms/server-express';
20
+ * import { createMomentumAuth } from '@momentumcms/auth';
21
+ *
22
+ * const auth = createMomentumAuth({ database });
23
+ * app.use('/api', createAuthMiddleware(auth));
24
+ * // Auth endpoints available at /api/auth/*
25
+ * ```
26
+ */
27
+ /**
28
+ * Options for the auth middleware.
29
+ */
30
+ export interface AuthMiddlewareOptions {
31
+ /** OAuth providers config (used to expose enabled providers to the client) */
32
+ socialProviders?: OAuthProvidersConfig;
33
+ }
34
+ export declare function createAuthMiddleware(auth: MomentumAuth, options?: AuthMiddlewareOptions): Router;
35
+ /**
36
+ * Middleware to protect routes that require authentication.
37
+ *
38
+ * Validates the session and attaches the user to the request.
39
+ * Returns 401 if no valid session is found.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import { createProtectMiddleware } from '@momentumcms/server-express';
44
+ *
45
+ * // Protect all collection routes
46
+ * app.use('/api/collections', createProtectMiddleware(auth), collectionsRouter);
47
+ * ```
48
+ */
49
+ export declare function createProtectMiddleware(auth: MomentumAuth): (req: AuthenticatedRequest, res: Response, next: NextFunction) => Promise<void>;
50
+ /**
51
+ * Middleware to resolve session for all requests (including SSR).
52
+ *
53
+ * Unlike createProtectMiddleware, this does NOT block unauthenticated requests.
54
+ * It simply validates the session if cookies are present and attaches the user
55
+ * to the request for use by Angular SSR.
56
+ *
57
+ * Role is read directly from the Better Auth user table (single source of truth).
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * import { createSessionResolverMiddleware } from '@momentumcms/server-express';
62
+ *
63
+ * app.use(createSessionResolverMiddleware(auth));
64
+ * ```
65
+ */
66
+ export declare function createSessionResolverMiddleware(auth: MomentumAuth): (req: AuthenticatedRequest, res: Response, next: NextFunction) => Promise<void>;
67
+ /**
68
+ * Creates a deferred session resolver middleware for an auth plugin.
69
+ *
70
+ * This can be called at module scope before the auth plugin is initialized.
71
+ * The middleware passes through (calls next()) until the auth instance is ready,
72
+ * then resolves sessions normally.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * import { createDeferredSessionResolver } from '@momentumcms/server-express';
77
+ * import { momentumAuth } from '@momentumcms/auth';
78
+ *
79
+ * const authPlugin = momentumAuth({ ... });
80
+ * app.use(createDeferredSessionResolver(authPlugin));
81
+ * ```
82
+ */
83
+ export declare function createDeferredSessionResolver(plugin: MomentumAuthPlugin): RequestHandler;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Consolidated Momentum CMS server factory for Express.
3
+ *
4
+ * Replaces the manual orchestration of 12+ separate functions
5
+ * with a single `createMomentumServer()` call that handles:
6
+ * - Express app creation with JSON parsing
7
+ * - Plugin initialization (auth, analytics, event bus, etc.)
8
+ * - Database schema + API initialization
9
+ * - Seeding
10
+ * - Webhook hooks registration
11
+ * - Health endpoint
12
+ * - Session resolver middleware
13
+ * - OpenAPI docs endpoint
14
+ * - CMS API endpoints
15
+ * - Publish scheduler
16
+ * - SSR provider helpers
17
+ */
18
+ import { type Express, type RequestHandler } from 'express';
19
+ import type { MomentumConfig, ResolvedMomentumConfig } from '@momentumcms/core';
20
+ import type { Provider } from '@angular/core';
21
+ import { type MomentumInitResult } from './init-helpers';
22
+ import type { MomentumAuthPlugin } from '@momentumcms/auth';
23
+ /**
24
+ * Options for creating a consolidated Momentum CMS Express server.
25
+ */
26
+ export interface CreateMomentumServerOptions {
27
+ /** Fully resolved Momentum configuration */
28
+ config: MomentumConfig | ResolvedMomentumConfig;
29
+ /**
30
+ * Custom Express app instance.
31
+ * If not provided, a new Express app is created with `express.json()` body parser.
32
+ */
33
+ app?: Express;
34
+ /**
35
+ * Mount health endpoint at /api/health.
36
+ * @default true
37
+ */
38
+ health?: boolean;
39
+ /**
40
+ * Mount OpenAPI/Swagger docs at /api/docs.
41
+ * @default false
42
+ */
43
+ openapi?: boolean;
44
+ /**
45
+ * Start publish scheduler for scheduled content.
46
+ * Pass `true` for default interval (10s) or an object with custom intervalMs.
47
+ * @default false
48
+ */
49
+ publishScheduler?: boolean | {
50
+ intervalMs: number;
51
+ };
52
+ /**
53
+ * Register webhook hooks on collections.
54
+ * @default true (if any collection has webhook config)
55
+ */
56
+ webhooks?: boolean;
57
+ /**
58
+ * Auth plugin instance for session resolution.
59
+ * If not provided, auto-detected from config.plugins.
60
+ */
61
+ authPlugin?: MomentumAuthPlugin;
62
+ /**
63
+ * Factory to create SSR providers for the Momentum API.
64
+ * Receives the API singleton and user context; should return Angular Providers.
65
+ *
66
+ * Typically: `(api, ctx) => provideMomentumAPI(api, ctx)` from `@momentumcms/admin`.
67
+ * If not provided, `getSsrProviders()` returns only plugin providers.
68
+ */
69
+ providerFactory?: (api: unknown, context: {
70
+ user?: {
71
+ id: string;
72
+ email: string;
73
+ role: string;
74
+ };
75
+ }) => Provider[];
76
+ }
77
+ /**
78
+ * Result of creating a Momentum CMS server.
79
+ */
80
+ export interface MomentumServer {
81
+ /**
82
+ * Express app with all CMS middleware mounted.
83
+ * Mount additional routes (static files, SSR handler) on this app.
84
+ */
85
+ app: Express;
86
+ /**
87
+ * Initialization result with ready promise and seeding status.
88
+ */
89
+ init: MomentumInitResult;
90
+ /**
91
+ * Session resolver middleware.
92
+ * Mount this before your Angular/framework SSR handler so that
93
+ * `req.user` is populated for access-controlled SSR rendering.
94
+ */
95
+ sessionResolver: RequestHandler;
96
+ /**
97
+ * Get Angular SSR providers for the current request.
98
+ * Includes the Momentum API singleton and all plugin providers.
99
+ *
100
+ * @param user - The authenticated user from `req.user` (set by sessionResolver)
101
+ */
102
+ getSsrProviders(user?: {
103
+ id: string;
104
+ email: string;
105
+ role: string;
106
+ }): Provider[];
107
+ /**
108
+ * Graceful shutdown: stops publish scheduler and plugin runners.
109
+ */
110
+ shutdown(): Promise<void>;
111
+ }
112
+ /**
113
+ * Create a fully configured Momentum CMS Express server with a single function call.
114
+ *
115
+ * Consolidates initialization, middleware mounting, and plugin wiring that previously
116
+ * required 12+ separate function calls orchestrated in a specific order.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * import { createMomentumServer } from '@momentumcms/server-express';
121
+ * import config from './momentum.config';
122
+ *
123
+ * const server = await createMomentumServer({
124
+ * config,
125
+ * health: true,
126
+ * openapi: true,
127
+ * publishScheduler: { intervalMs: 2000 },
128
+ * });
129
+ *
130
+ * // Add app-specific routes (static files, SSR)
131
+ * server.app.use(express.static(browserDistFolder, { maxAge: '1y' }));
132
+ * server.app.use(server.sessionResolver);
133
+ * server.app.use('/**', (req, res, next) => {
134
+ * angularApp.handle(req, { providers: server.getSsrProviders(req.user) })...
135
+ * });
136
+ *
137
+ * server.app.listen(4000);
138
+ * ```
139
+ */
140
+ export declare function createMomentumServer(options: CreateMomentumServerOptions): Promise<MomentumServer>;
@@ -0,0 +1,138 @@
1
+ import type { Router } from 'express';
2
+ import { type SeedingResult, type MomentumAuthLike } from '@momentumcms/server-core';
3
+ import type { MomentumConfig, ResolvedMomentumConfig } from '@momentumcms/core';
4
+ /**
5
+ * Result of initializing Momentum CMS.
6
+ */
7
+ export interface MomentumInitResult {
8
+ /**
9
+ * Promise that resolves when initialization (including seeding) completes.
10
+ * Use this to wait for full initialization before accepting requests.
11
+ */
12
+ ready: Promise<void>;
13
+ /**
14
+ * Seeding result if seeding was run, null otherwise.
15
+ */
16
+ seedingResult: SeedingResult | null;
17
+ /**
18
+ * Whether initialization has completed.
19
+ */
20
+ isReady: () => boolean;
21
+ /**
22
+ * Get current seeding status for health checks.
23
+ */
24
+ getSeedingStatus: () => SeedingStatus;
25
+ /**
26
+ * Gracefully shut down all plugins.
27
+ * Call this when the server is stopping.
28
+ */
29
+ shutdown: () => Promise<void>;
30
+ }
31
+ /**
32
+ * Seeding status for health endpoint.
33
+ */
34
+ export interface SeedingStatus {
35
+ /** Number of seeds that were processed */
36
+ completed: number;
37
+ /** Total number of seeds expected */
38
+ expected: number;
39
+ /** Whether seeding has completed */
40
+ ready: boolean;
41
+ }
42
+ /**
43
+ * Options for initializeMomentum.
44
+ */
45
+ export interface InitializeMomentumOptions {
46
+ /**
47
+ * Whether to log initialization progress.
48
+ * @default true
49
+ */
50
+ logging?: boolean;
51
+ /**
52
+ * Custom logger function.
53
+ * @default console.log
54
+ */
55
+ logger?: (message: string) => void;
56
+ /**
57
+ * Auth instance for auth-aware user seeding.
58
+ * When provided, seeds created with `authUser()` will automatically
59
+ * create Better Auth users with hashed passwords.
60
+ */
61
+ auth?: MomentumAuthLike;
62
+ }
63
+ /**
64
+ * Initialize Momentum CMS with a single function call.
65
+ *
66
+ * Handles:
67
+ * - Database schema initialization (if adapter supports it)
68
+ * - Momentum API singleton initialization
69
+ * - Seeding (if configured in the config)
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * import { initializeMomentum } from '@momentumcms/server-express';
74
+ * import momentumConfig from './momentum.config';
75
+ *
76
+ * const { ready, getSeedingStatus } = initializeMomentum(momentumConfig);
77
+ *
78
+ * // Wait for initialization before accepting requests
79
+ * await ready;
80
+ *
81
+ * // Or use non-blocking initialization for faster dev startup
82
+ * ready.catch(console.error);
83
+ * ```
84
+ */
85
+ export declare function initializeMomentum(config: MomentumConfig | ResolvedMomentumConfig, options?: InitializeMomentumOptions): MomentumInitResult;
86
+ /**
87
+ * Options for createHealthMiddleware.
88
+ */
89
+ export interface HealthMiddlewareOptions {
90
+ /**
91
+ * Function to check if the server is ready.
92
+ */
93
+ isReady?: () => boolean;
94
+ /**
95
+ * Function to get seeding status.
96
+ */
97
+ getSeedingStatus?: () => SeedingStatus;
98
+ /**
99
+ * Promise to wait for when ?checkSeeds=true is requested.
100
+ */
101
+ waitForReady?: Promise<void>;
102
+ /**
103
+ * Additional health data to include in response.
104
+ */
105
+ additionalData?: () => Record<string, unknown>;
106
+ }
107
+ /**
108
+ * Health response structure.
109
+ */
110
+ export interface HealthResponse {
111
+ status: 'ok' | 'initializing' | 'error';
112
+ ready: boolean;
113
+ seeds?: SeedingStatus;
114
+ [key: string]: unknown;
115
+ }
116
+ /**
117
+ * Creates Express middleware for a health endpoint.
118
+ *
119
+ * Features:
120
+ * - Reports server ready status
121
+ * - Reports seeding status (if provided)
122
+ * - Can wait for initialization when ?checkSeeds=true
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * import { initializeMomentum, createHealthMiddleware } from '@momentumcms/server-express';
127
+ *
128
+ * const init = initializeMomentum(config);
129
+ *
130
+ * // Mount at /api/health
131
+ * app.use('/api/health', createHealthMiddleware({
132
+ * isReady: init.isReady,
133
+ * getSeedingStatus: init.getSeedingStatus,
134
+ * waitForReady: init.ready,
135
+ * }));
136
+ * ```
137
+ */
138
+ export declare function createHealthMiddleware(options?: HealthMiddlewareOptions): Router;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Plugin Middleware Registry
3
+ *
4
+ * Module-level singleton that bridges plugin initialization and middleware mounting.
5
+ * Same pattern as getMomentumAPI()/initializeMomentumAPI() in server-core.
6
+ *
7
+ * Flow:
8
+ * 1. initializeMomentum() runs pluginRunner.runInit() — plugins register middleware/providers
9
+ * 2. initializeMomentum() calls setPluginMiddleware/setPluginProviders to store them
10
+ * 3. momentumApiMiddleware() calls getPluginMiddleware() to auto-mount them
11
+ * 4. server.ts calls getPluginProviders() to spread into Angular SSR
12
+ */
13
+ import type { PluginMiddlewareDescriptor, PluginProviderDescriptor } from '@momentumcms/plugins/core';
14
+ /**
15
+ * Store plugin middleware descriptors collected during onInit.
16
+ * Called by initializeMomentum() after pluginRunner.runInit().
17
+ */
18
+ export declare function setPluginMiddleware(middleware: PluginMiddlewareDescriptor[]): void;
19
+ /**
20
+ * Get plugin middleware descriptors for auto-mounting.
21
+ * Called by momentumApiMiddleware() to mount plugin routes/middleware.
22
+ */
23
+ export declare function getPluginMiddleware(): PluginMiddlewareDescriptor[];
24
+ /**
25
+ * Store plugin provider descriptors collected during onInit.
26
+ * Called by initializeMomentum() after pluginRunner.runInit().
27
+ */
28
+ export declare function setPluginProviders(providers: PluginProviderDescriptor[]): void;
29
+ /**
30
+ * Get plugin provider descriptors for Angular SSR injection.
31
+ * Called by server.ts to spread into angularApp.handle() providers.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * import { getPluginProviders } from '@momentumcms/server-express';
36
+ *
37
+ * angularApp.handle(req, {
38
+ * providers: [
39
+ * ...provideMomentumAPI(api, { user }),
40
+ * ...getPluginProviders().map(p => ({ provide: p.token, useValue: p.value })),
41
+ * ],
42
+ * });
43
+ * ```
44
+ */
45
+ export declare function getPluginProviders(): PluginProviderDescriptor[];
@@ -0,0 +1,45 @@
1
+ import { Router } from 'express';
2
+ import { type OpenAPIGeneratorOptions } from '@momentumcms/server-core';
3
+ import type { MomentumConfig, ResolvedMomentumConfig } from '@momentumcms/core';
4
+ /**
5
+ * Creates Express middleware for Momentum CMS API.
6
+ *
7
+ * Usage:
8
+ * ```typescript
9
+ * import express from 'express';
10
+ * import { momentumApiMiddleware } from '@momentumcms/server-express';
11
+ * import momentumConfig from './momentum.config';
12
+ *
13
+ * const app = express();
14
+ * app.use('/api', momentumApiMiddleware(momentumConfig));
15
+ * ```
16
+ */
17
+ export declare function momentumApiMiddleware(config: MomentumConfig | ResolvedMomentumConfig): Router;
18
+ /**
19
+ * OpenAPI docs middleware configuration.
20
+ */
21
+ export interface OpenAPIDocsConfig {
22
+ /** Momentum config (used to generate the spec from collections) */
23
+ config: MomentumConfig | ResolvedMomentumConfig;
24
+ /** OpenAPI generator options (title, version, description, servers) */
25
+ openapi?: OpenAPIGeneratorOptions;
26
+ }
27
+ /**
28
+ * Creates Express middleware that serves OpenAPI docs.
29
+ *
30
+ * Provides two endpoints:
31
+ * - GET /openapi.json - the generated OpenAPI 3.0 spec
32
+ * - GET / - Swagger UI HTML page
33
+ *
34
+ * Mount this BEFORE the momentum API middleware to avoid route conflicts.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * app.use('/api/docs', createOpenAPIMiddleware({
39
+ * config: momentumConfig,
40
+ * openapi: { title: 'My API', version: '2.0.0' },
41
+ * }));
42
+ * app.use('/api', momentumApiMiddleware(momentumConfig));
43
+ * ```
44
+ */
45
+ export declare function createOpenAPIMiddleware(docsConfig: OpenAPIDocsConfig): Router;
@@ -0,0 +1,63 @@
1
+ import type { Router } from 'express';
2
+ import type { Pool } from 'pg';
3
+ import type { Database } from 'better-sqlite3';
4
+ import type { MomentumAuth } from '@momentumcms/auth';
5
+ /**
6
+ * Response type for the setup status endpoint.
7
+ */
8
+ export interface SetupStatus {
9
+ /** True if no users exist and setup is required */
10
+ needsSetup: boolean;
11
+ /** True if at least one user exists */
12
+ hasUsers: boolean;
13
+ }
14
+ /**
15
+ * Database configuration - supports both SQLite and PostgreSQL.
16
+ */
17
+ export type DatabaseConfig = {
18
+ type: 'sqlite';
19
+ database: Database;
20
+ } | {
21
+ type: 'postgres';
22
+ pool: Pool;
23
+ };
24
+ /**
25
+ * Configuration for the setup middleware.
26
+ */
27
+ export interface SetupMiddlewareConfig {
28
+ /** Database configuration - supports SQLite or PostgreSQL */
29
+ db: DatabaseConfig;
30
+ /** The Better Auth instance for user creation */
31
+ auth: MomentumAuth;
32
+ }
33
+ /**
34
+ * Legacy configuration for backwards compatibility.
35
+ */
36
+ export interface SetupMiddlewareConfigLegacy {
37
+ /** The SQLite database instance (deprecated, use db instead) */
38
+ database: Database;
39
+ /** The Better Auth instance for user creation */
40
+ auth: MomentumAuth;
41
+ }
42
+ /**
43
+ * Creates Express middleware for setup-related endpoints.
44
+ *
45
+ * Provides endpoints to:
46
+ * - Check if the application needs initial setup (no users exist)
47
+ * - Create the first admin user during setup
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * import { createSetupMiddleware } from '@momentumcms/server-express';
52
+ * import { createMomentumAuth } from '@momentumcms/auth';
53
+ *
54
+ * // With PostgreSQL
55
+ * const auth = createMomentumAuth({ db: { type: 'postgres', pool } });
56
+ * app.use('/api', createSetupMiddleware({ db: { type: 'postgres', pool }, auth }));
57
+ *
58
+ * // With SQLite (legacy)
59
+ * const auth = createMomentumAuth({ database: sqliteDb });
60
+ * app.use('/api', createSetupMiddleware({ database: sqliteDb, auth }));
61
+ * ```
62
+ */
63
+ export declare function createSetupMiddleware(config: SetupMiddlewareConfig | SetupMiddlewareConfigLegacy): Router;