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: {
|
30 | getServiceDefinition: GetServiceDefinition;
|
31 | getHandlers: GetHandlers;
|
32 | }[] = [];
|
33 |
|
34 | export function registerAdminService(
|
35 | getServiceDefinition: GetServiceDefinition,
|
36 | getHandlers: GetHandlers
|
37 | ) {
|
38 | registeredAdminServices.push({ getServiceDefinition, getHandlers });
|
39 | }
|
40 |
|
41 | export function addAdminServicesToServer(server: Server): void {
|
42 | for (const { getServiceDefinition, getHandlers } of registeredAdminServices) {
|
43 | server.addService(getServiceDefinition(), getHandlers());
|
44 | }
|
45 | }
|