smartswagger/scripts/startdemoserver.ts

24 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-11-19 19:05:52 +00:00
import * as smartexpress from '@pushrocks/smartexpress';
import * as smartswagger from '../ts';
const run = async () => {
const smartswaggerInstance = await smartswagger.Smartswagger.createNew('A new OpenAPI Doc');
await smartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/ReceiptAPI/openApi.json', '', 'Yes1');
await smartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/ContactAPI/openApi.json', '', 'Yes2');
await smartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/InvoiceAPI/openApi.json', '', 'Yes3');
await smartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/OrderAPI/openApi.json', '', 'Yes4');
await smartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/InventoryAPI/openApi.json', '', 'Yes5');
2021-11-19 19:05:52 +00:00
// express stuff
const expressServer = new smartexpress.Server({
cors: true,
});
expressServer.addRoute('/apiui', new smartexpress.Handler('ALL', smartswaggerInstance.getSlashApiUiMiddleware()));
expressServer.addRoute('/apiredoc', new smartexpress.Handler('ALL', smartswaggerInstance.getSlashRedocMiddleware()))
expressServer.addRoute('/apischema', new smartexpress.Handler('ALL', smartswaggerInstance.getSlashApiSchemaMiddleware()));
await expressServer.start(3000);
}
run();