1
1
import express from 'express' ;
2
2
import cookieParser from 'cookie-parser' ;
3
3
import { setupProxies } from './proxy/proxy' ;
4
- import { routes_config } from './proxy/routes_config' ;
4
+ import { routes_config , ws_collab_proxy_config , ws_match_proxy_config } from './proxy/routes_config' ;
5
5
import { jwtCheck , onCredentialFailure } from './middleware/token_check' ;
6
6
import { setupLogging } from './middleware/logging' ;
7
7
import { isLocal } from './proxy/service_addresses' ;
8
+ import { createProxyMiddleware } from 'http-proxy-middleware' ;
8
9
9
- const app = express ( ) ;
10
- const port = process . env . PORT || 8000 ;
10
+ const httpApp = express ( ) ;
11
+ const httpProxyPort : number = parseInt ( process . env . PORT || " 8000" ) ;
11
12
12
- app . use ( cookieParser ( ) )
13
+ const wsMatchMakeApp = express ( ) ;
14
+ const wsMatchMakePort : number = parseInt ( process . env . PORT || "7999" ) ;
13
15
14
- setupLogging ( app ) ;
15
- app . use ( jwtCheck . unless ( { path : [ / \/ a u t h \/ / ] } ) ) ;
16
- app . use ( onCredentialFailure ) ;
16
+ const wsCollabApp = express ( ) ;
17
+ const wsCollabAppPort : number = parseInt ( process . env . PORT || "7998" ) ;
17
18
18
- setupProxies ( app , routes_config ) ;
19
19
20
- app . listen ( port , ( ) => {
20
+ httpApp . use ( cookieParser ( ) )
21
+
22
+ setupLogging ( httpApp ) ;
23
+ httpApp . use ( jwtCheck . unless ( { path : [ / \/ a u t h \/ / ] } ) ) ;
24
+ httpApp . use ( onCredentialFailure ) ;
25
+
26
+ setupProxies ( httpApp , routes_config ) ;
27
+ setupProxies ( wsMatchMakeApp , ws_match_proxy_config )
28
+ setupProxies ( wsCollabApp , ws_collab_proxy_config )
29
+
30
+
31
+
32
+
33
+ httpApp . listen ( httpProxyPort , ( ) => {
34
+ console . log ( `API Gateway running in ${ isLocal ? "local" : "docker" } mode` )
35
+ console . log ( `API Gateway listening at http://localhost:${ httpProxyPort } ` ) ;
36
+ } )
37
+
38
+ wsMatchMakeApp . listen ( wsMatchMakePort , ( ) => {
39
+ console . log ( `API Gateway running in ${ isLocal ? "local" : "docker" } mode` )
40
+ console . log ( `API Gateway listening at http://localhost:${ wsMatchMakePort } ` ) ;
41
+ } )
42
+
43
+ wsCollabApp . listen ( wsCollabAppPort , ( ) => {
21
44
console . log ( `API Gateway running in ${ isLocal ? "local" : "docker" } mode` )
22
- console . log ( `API Gateway listening at http://localhost:${ port } ` ) ;
45
+ console . log ( `API Gateway listening at http://localhost:${ wsCollabAppPort } ` ) ;
23
46
} )
0 commit comments