forked from fonoster/fonoster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
services.ts
151 lines (144 loc) Β· 4.69 KB
/
services.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env node
/*
* Copyright (C) 2021 by Fonoster Inc (https://fonoster.com)
* https://github.com/fonoster/fonoster
*
* This file is part of Fonoster
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import dotenv from "dotenv";
import {join} from "path";
if (process.env.NODE_ENV === "dev") {
dotenv.config({path: join(__dirname, ".env")});
}
import MonitorServer from "./mods/monitor/src/service/monitor";
import UsersServer from "./mods/users/src/service/users";
import ProjectsServer from "./mods/projects/src/service/projects";
import AuthServer from "./mods/auth/src/service/auth";
import FuncsServer from "./mods/funcs/src/service/funcs";
import AgentsServer from "./mods/agents/src/service/agents";
import SecretServer from "./mods/secrets/src/service/secrets";
import DomainsServer from "./mods/domains/src/service/domains";
import NumbersServer from "./mods/numbers/src/service/numbers";
import ProvidersServer from "./mods/providers/src/service/providers";
import CallManagerServer from "./mods/callmanager/src/service/callmanager";
import StorageServer from "./mods/storage/src/service/storage";
import {MonitorService} from "./mods/monitor/src/service/protos/monitor_grpc_pb";
import {ProjectsService} from "./mods/projects/src/service/protos/projects_grpc_pb";
import {UsersService} from "./mods/users/src/service/protos/users_grpc_pb";
import {AuthService} from "./mods/auth/src/service/protos/auth_grpc_pb";
import {FuncsService} from "./mods/funcs/src/service/protos/funcs_grpc_pb";
import {AgentsService} from "./mods/agents/src/service/protos/agents_grpc_pb";
import {SecretsService} from "./mods/secrets/src/service/protos/secrets_grpc_pb";
import {DomainsService} from "./mods/domains/src/service/protos/domains_grpc_pb";
import {NumbersService} from "./mods/numbers/src/service/protos/numbers_grpc_pb";
import {ProvidersService} from "./mods/providers/src/service/protos/providers_grpc_pb";
import {CallManagerService} from "./mods/callmanager/src/service/protos/callmanager_grpc_pb";
import {StorageService} from "./mods/storage/src/service/protos/storage_grpc_pb";
import runServices from "./mods/common/src/service_runner";
import AuthMiddleware from "./mods/auth/src/auth_middleware";
import {getSalt} from "./mods/certs/src/certs";
const services = [
{
name: "monitor",
version: "v1beta1",
service: MonitorService,
server: new MonitorServer()
},
{
name: "users",
version: "v1beta1",
service: UsersService,
server: new UsersServer()
},
{
name: "projects",
version: "v1beta1",
service: ProjectsService,
server: new ProjectsServer()
},
{
name: "auth",
version: "v1beta1",
service: AuthService,
server: new AuthServer()
},
{
name: "funcs",
version: "v1beta1",
service: FuncsService,
server: new FuncsServer()
},
{
name: "agents",
version: "v1beta1",
service: AgentsService,
server: new AgentsServer()
},
{
name: "domains",
version: "v1beta1",
service: DomainsService,
server: new DomainsServer()
},
{
name: "numbers",
version: "v1beta1",
service: NumbersService,
server: new NumbersServer()
},
{
name: "providers",
version: "v1beta1",
service: ProvidersService,
server: new ProvidersServer()
},
{
name: "callmanager",
version: "v1beta1",
service: CallManagerService,
server: new CallManagerServer()
},
{
name: "storage",
version: "v1beta1",
service: StorageService,
server: new StorageServer()
},
{
name: "secrets",
version: "v1beta1",
service: SecretsService,
server: new SecretServer()
}
];
const whitelist = [
"/fonoster.monitor.v1beta1.Monitor/SearchEvents",
"/fonoster.users.v1beta1.Users/ListUsers",
"/fonoster.users.v1beta1.Users/CreateUser",
"/fonoster.users.v1beta1.Users/DeleteUser",
"/fonoster.users.v1beta1.Users/LoginUser",
"/fonoster.auth.v1beta1.Auth/GetRole",
"/fonoster.auth.v1beta1.Auth/CreateToken",
"/fonoster.auth.v1beta1.Auth/CreateNoAccessToken",
"/fonoster.auth.v1beta1.Secrets/GetSecret",
"/grpc.health.v1.Health/Check"
];
const middlewares = [
{
name: "authentication",
middlewareObj: new AuthMiddleware(getSalt(), whitelist).middleware
}
];
runServices(services, middlewares);