|
@@ -24,7 +24,7 @@ import { urlencoded, json, Request, Response, NextFunction } from 'express'
|
|
import * as winston from 'winston'
|
|
import * as winston from 'winston'
|
|
import * as dayjs from 'dayjs'
|
|
import * as dayjs from 'dayjs'
|
|
import * as utc from 'dayjs/plugin/utc'
|
|
import * as utc from 'dayjs/plugin/utc'
|
|
-import { express } from 'aws-xray-sdk'
|
|
|
|
|
|
+import * as AWSXRay from 'aws-xray-sdk'
|
|
|
|
|
|
import { InversifyExpressServer } from 'inversify-express-utils'
|
|
import { InversifyExpressServer } from 'inversify-express-utils'
|
|
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
|
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
|
@@ -42,11 +42,15 @@ void container.load().then((container) => {
|
|
const isConfiguredForAWSProduction =
|
|
const isConfiguredForAWSProduction =
|
|
env.get('MODE', true) !== 'home-server' && env.get('MODE', true) !== 'self-hosted'
|
|
env.get('MODE', true) !== 'home-server' && env.get('MODE', true) !== 'self-hosted'
|
|
|
|
|
|
|
|
+ if (isConfiguredForAWSProduction) {
|
|
|
|
+ AWSXRay.config([AWSXRay.plugins.EC2Plugin, AWSXRay.plugins.ECSPlugin])
|
|
|
|
+ }
|
|
|
|
+
|
|
const server = new InversifyExpressServer(container)
|
|
const server = new InversifyExpressServer(container)
|
|
|
|
|
|
server.setConfig((app) => {
|
|
server.setConfig((app) => {
|
|
if (isConfiguredForAWSProduction) {
|
|
if (isConfiguredForAWSProduction) {
|
|
- app.use(express.openSegment(ServiceIdentifier.NAMES.Auth))
|
|
|
|
|
|
+ app.use(AWSXRay.express.openSegment(ServiceIdentifier.NAMES.Auth))
|
|
}
|
|
}
|
|
|
|
|
|
app.use((_request: Request, response: Response, next: NextFunction) => {
|
|
app.use((_request: Request, response: Response, next: NextFunction) => {
|
|
@@ -76,7 +80,7 @@ void container.load().then((container) => {
|
|
const serverInstance = server.build()
|
|
const serverInstance = server.build()
|
|
|
|
|
|
if (isConfiguredForAWSProduction) {
|
|
if (isConfiguredForAWSProduction) {
|
|
- serverInstance.use(express.closeSegment())
|
|
|
|
|
|
+ serverInstance.use(AWSXRay.express.closeSegment())
|
|
}
|
|
}
|
|
|
|
|
|
serverInstance.listen(env.get('PORT'))
|
|
serverInstance.listen(env.get('PORT'))
|