@flavoai/fastfold
Version:
Flavo frontend package
83 lines • 2.13 kB
TypeScript
import { Express, Request, Response, NextFunction } from 'express';
import { TableDefinition, DatabaseProvider, FlavoAuthSettings, CustomAuthSettings } from '../types';
interface LegacyServerConfig {
database: {
provider: DatabaseProvider;
connection: any;
};
tables: {
[tableName: string]: TableDefinition;
};
auth?: {
providers?: {
flavo?: FlavoAuthSettings;
custom?: CustomAuthSettings;
};
};
port?: number;
/** Additional Express middleware to attach */
middleware?: Array<(req: Request, res: Response, next: NextFunction) => void>;
}
export declare class FastfoldServer {
private app;
private config;
private db;
private crudGenerator;
private docGenerator;
private apiExplorer;
constructor(config: LegacyServerConfig);
/**
* Initialize the server - connect to database and create tables
*/
initialize(): Promise<void>;
/**
* Start the server
*/
start(port?: number): Promise<void>;
/**
* Get the Express app instance
*/
getApp(): Express;
/**
* Setup middleware
*/
private setupMiddleware;
/**
* Flavo delegated auth: verify JWTs locally using the app's own public key.
*/
private setupFlavoAuth;
/**
* HS256 authentication middleware (original behavior)
*/
private authMiddleware;
/**
* Setup API routes for all tables
*/
private setupRoutes;
/**
* Setup CRUD routes for a specific table
*/
private setupTableRoutes;
/**
* Create request context for security checks
*/
private createRequestContext;
/**
* Parse ID parameter (handles both string and number IDs)
*/
private parseId;
/**
* Handle errors consistently
*/
private handleError;
/**
* Graceful shutdown
*/
shutdown(): Promise<void>;
}
/**
* Quick start function for Fastfold
*/
export declare function createFastfoldServer(config: LegacyServerConfig): FastfoldServer;
export {};
//# sourceMappingURL=index.d.ts.map