1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import { ServiceDefinition } from "./make-client";
|
19 | import { Server, UntypedServiceImplementation } from "./server";
|
20 |
|
21 | interface GetServiceDefinition {
|
22 | (): ServiceDefinition;
|
23 | }
|
24 |
|
25 | interface GetHandlers {
|
26 | (): UntypedServiceImplementation;
|
27 | }
|
28 |
|
29 | const registeredAdminServices: {getServiceDefinition: GetServiceDefinition, getHandlers: GetHandlers}[] = [];
|
30 |
|
31 | export function registerAdminService(getServiceDefinition: GetServiceDefinition, getHandlers: GetHandlers) {
|
32 | registeredAdminServices.push({getServiceDefinition, getHandlers});
|
33 | }
|
34 |
|
35 | export function addAdminServicesToServer(server: Server): void {
|
36 | for (const {getServiceDefinition, getHandlers} of registeredAdminServices) {
|
37 | server.addService(getServiceDefinition(), getHandlers());
|
38 | }
|
39 | } |
\ | No newline at end of file |