import Fastify from 'fastify';
import cors from '@fastify/cors';
import websocket from '@fastify/websocket';
import rateLimit from '@fastify/rate-limit';
import { env } from './env.js';
import { logger } from './logger.js';
import { healthRoutes } from './routes/health.js';
import { wsRoutes } from './routes/ws.js';
import { buildDeviceGrantPlugin } from './device-grant/routes.js';
export async function buildApp(options = {}) {
    const app = Fastify({ logger });
    await app.register(cors, { origin: true });
    await app.register(rateLimit, { max: 100, timeWindow: '1 minute' });
    await app.register(websocket);
    await app.register(healthRoutes);
    await app.register(wsRoutes);
    await app.register(buildDeviceGrantPlugin({ store: options.deviceGrantStore }));
    return app;
}
export { env };
//# sourceMappingURL=app.js.map