(endpoint: ApiExtension)
| 739 | } |
| 740 | |
| 741 | private async registerEndpointExtension(endpoint: ApiExtension) { |
| 742 | try { |
| 743 | if (endpoint.sandbox?.enabled) { |
| 744 | await this.registerSandboxedApiExtension(endpoint); |
| 745 | } else { |
| 746 | const endpointPath = path.resolve(endpoint.path, endpoint.entrypoint); |
| 747 | |
| 748 | const endpointInstance: EndpointConfig | { default: EndpointConfig } = await importFileUrl( |
| 749 | endpointPath, |
| 750 | import.meta.url, |
| 751 | { |
| 752 | fresh: true, |
| 753 | }, |
| 754 | ); |
| 755 | |
| 756 | const config = getModuleDefault(endpointInstance); |
| 757 | |
| 758 | const unregister = this.registerEndpoint(config, endpoint.name); |
| 759 | |
| 760 | this.unregisterFunctionMap.set(endpoint.name, async () => { |
| 761 | await unregister(); |
| 762 | |
| 763 | deleteFromRequireCache(endpointPath); |
| 764 | }); |
| 765 | } |
| 766 | } catch (error) { |
| 767 | this.handleExtensionError({ error, reason: `Couldn't register endpoint "${endpoint.name}"` }); |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | private async registerOperationExtension(operation: HybridExtension) { |
| 772 | try { |
no test coverage detected