35 lines
868 B
TypeScript
35 lines
868 B
TypeScript
import { writeFile } from 'node:fs/promises';
|
|
import { resolve } from 'node:path';
|
|
import { getConfig } from '../src/config/config.js';
|
|
import { getServer } from '../src/server.js';
|
|
|
|
async function exportOpenAPI() {
|
|
console.log('Exporting OpenAPI spec...');
|
|
|
|
const config = getConfig();
|
|
const server = getServer(config);
|
|
|
|
await server.ready();
|
|
|
|
// Get the OpenAPI spec from Fastify swagger plugin
|
|
const spec = server.swagger();
|
|
|
|
// Write to packages/api-client-backend
|
|
const outputPath = resolve(
|
|
import.meta.dirname,
|
|
'../../../packages/api-client-backend/openapi.json'
|
|
);
|
|
|
|
await writeFile(outputPath, JSON.stringify(spec, null, 2));
|
|
|
|
console.log(`✓ OpenAPI spec exported to ${outputPath}`);
|
|
|
|
await server.close();
|
|
process.exit(0);
|
|
}
|
|
|
|
exportOpenAPI().catch((error) => {
|
|
console.error('Failed to export OpenAPI spec:', error);
|
|
process.exit(1);
|
|
});
|