Compare commits

..

3 Commits

Author SHA1 Message Date
standardci
3097f7f063 chore(release): publish new version
- @standardnotes/home-server@1.16.22
 - @standardnotes/revisions-server@1.39.0
2023-10-04 15:42:53 +00:00
Karol Sójko
126989df82 feat(revisions): add aws-xray-sdk 2023-10-04 17:22:40 +02:00
Karol Sójko
a25eb178c5 chore: fix env var replacement 2023-10-04 16:43:48 +02:00
10 changed files with 58 additions and 5 deletions

View File

@@ -40,7 +40,7 @@ jobs:
- name: Fill in the new package version in the Amazon ECS task definition
run: |
jq '(.containerDefinitions[] | select(.name=="${{ inputs.service_name }}-prod") | .environment[] | select(.name=="NPM_PACKAGE_VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
jq '(.containerDefinitions[] | select(.name=="${{ inputs.service_name }}-prod") | .environment[] | select(.name=="npm_package_version")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def-prod

1
.pnp.cjs generated
View File

@@ -6188,6 +6188,7 @@ const RAW_RUNTIME_STATE =
["@types/node", "npm:20.5.7"],\
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:6.5.0"],\
["@typescript-eslint/parser", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:6.5.0"],\
["aws-xray-sdk", "npm:3.5.2"],\
["cors", "npm:2.8.5"],\
["dotenv", "npm:16.1.3"],\
["eslint", "npm:8.41.0"],\

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.16.22](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.16.21...@standardnotes/home-server@1.16.22) (2023-10-04)
**Note:** Version bump only for package @standardnotes/home-server
## [1.16.21](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.16.20...@standardnotes/home-server@1.16.21) (2023-10-04)
**Note:** Version bump only for package @standardnotes/home-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/home-server",
"version": "1.16.21",
"version": "1.16.22",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.39.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.38.10...@standardnotes/revisions-server@1.39.0) (2023-10-04)
### Features
* **revisions:** add aws-xray-sdk ([126989d](https://github.com/standardnotes/server/commit/126989df82391ba2f29034d41897f437596269b7))
## [1.38.10](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.38.9...@standardnotes/revisions-server@1.38.10) (2023-10-04)
**Note:** Version bump only for package @standardnotes/revisions-server

View File

@@ -3,6 +3,7 @@ import 'reflect-metadata'
import * as cors from 'cors'
import { urlencoded, json, Request, Response, NextFunction } from 'express'
import * as winston from 'winston'
import * as AWSXRay from 'aws-xray-sdk'
import { InversifyExpressServer } from 'inversify-express-utils'
import TYPES from '../src/Bootstrap/Types'
@@ -11,14 +12,26 @@ import { ContainerConfigLoader } from '../src/Bootstrap/Container'
import '../src/Infra/InversifyExpress/AnnotatedRevisionsController'
import '../src/Infra/InversifyExpress/AnnotatedHealthCheckController'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const container = new ContainerConfigLoader()
void container.load().then((container) => {
const env: Env = container.get(TYPES.Revisions_Env)
const isConfiguredForAWSProduction =
env.get('MODE', true) !== 'home-server' && env.get('MODE', true) !== 'self-hosted'
if (isConfiguredForAWSProduction) {
AWSXRay.config([AWSXRay.plugins.ECSPlugin])
}
const server = new InversifyExpressServer(container)
server.setConfig((app) => {
if (isConfiguredForAWSProduction) {
app.use(AWSXRay.express.openSegment(ServiceIdentifier.NAMES.Revisions))
}
app.use((_request: Request, response: Response, next: NextFunction) => {
response.setHeader('X-Revisions-Version', container.get(TYPES.Revisions_VERSION))
next()
@@ -45,6 +58,10 @@ void container.load().then((container) => {
const serverInstance = server.build()
if (isConfiguredForAWSProduction) {
serverInstance.use(AWSXRay.express.closeSegment())
}
serverInstance.listen(env.get('PORT'))
logger.info(`Server started on port ${process.env.PORT}`)

View File

@@ -1,6 +1,7 @@
import 'reflect-metadata'
import { Logger } from 'winston'
import * as AWSXRay from 'aws-xray-sdk'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
@@ -12,6 +13,14 @@ void container.load().then((container) => {
const env: Env = new Env()
env.load()
const isConfiguredForAWSProduction =
env.get('MODE', true) !== 'home-server' && env.get('MODE', true) !== 'self-hosted'
if (isConfiguredForAWSProduction) {
AWSXRay.enableManualMode()
AWSXRay.config([AWSXRay.plugins.ECSPlugin])
}
const logger: Logger = container.get(TYPES.Revisions_Logger)
logger.info('Starting worker...')

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.38.10",
"version": "1.39.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -36,6 +36,7 @@
"@standardnotes/responses": "^1.13.27",
"@standardnotes/security": "workspace:^",
"@standardnotes/time": "workspace:^",
"aws-xray-sdk": "^3.5.2",
"cors": "2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.2",

View File

@@ -3,6 +3,7 @@ import Redis from 'ioredis'
import { Container, interfaces } from 'inversify'
import { MongoRepository, Repository } from 'typeorm'
import * as winston from 'winston'
import { captureAWSv3Client } from 'aws-xray-sdk'
import { SNSClient, SNSClientConfig } from '@aws-sdk/client-sns'
import { Revision } from '../Domain/Revision/Revision'
@@ -30,12 +31,12 @@ import {
DomainEventPublisherInterface,
} from '@standardnotes/domain-events'
import {
SQSNewRelicEventMessageHandler,
SQSEventMessageHandler,
SQSDomainEventSubscriberFactory,
DirectCallEventMessageHandler,
DirectCallDomainEventPublisher,
SNSDomainEventPublisher,
SQSXRayEventMessageHandler,
} from '@standardnotes/domain-events-infra'
import { DumpRepositoryInterface } from '../Domain/Dump/DumpRepositoryInterface'
import { AccountDeletionRequestedEventHandler } from '../Domain/Handler/AccountDeletionRequestedEventHandler'
@@ -90,6 +91,7 @@ export class ContainerConfigLoader {
const isConfiguredForHomeServer = env.get('MODE', true) === 'home-server'
const isConfiguredForSelfHosting = env.get('MODE', true) === 'self-hosted'
const isConfiguredForAWSProduction = !isConfiguredForHomeServer && !isConfiguredForSelfHosting
const isConfiguredForHomeServerOrSelfHosting = isConfiguredForHomeServer || isConfiguredForSelfHosting
const isSecondaryDatabaseEnabled = env.get('SECONDARY_DB_ENABLED', true) === 'true'
const isConfiguredForInMemoryCache = env.get('CACHE_TYPE', true) === 'memory'
@@ -173,6 +175,10 @@ export class ContainerConfigLoader {
}
}
if (isConfiguredForAWSProduction) {
return captureAWSv3Client(new SNSClient(snsConfig))
}
return new SNSClient(snsConfig)
})
@@ -201,6 +207,10 @@ export class ContainerConfigLoader {
}
}
if (isConfiguredForAWSProduction) {
return captureAWSv3Client(new SQSClient(sqsConfig))
}
return new SQSClient(sqsConfig)
})
@@ -213,6 +223,10 @@ export class ContainerConfigLoader {
apiVersion: 'latest',
region: env.get('S3_AWS_REGION', true),
})
if (isConfiguredForAWSProduction) {
return captureAWSv3Client(s3Client)
}
}
return s3Client
@@ -511,7 +525,7 @@ export class ContainerConfigLoader {
.bind<DomainEventMessageHandlerInterface>(TYPES.Revisions_DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Revisions_Logger))
? new SQSXRayEventMessageHandler(eventHandlers, container.get(TYPES.Revisions_Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Revisions_Logger)),
)

View File

@@ -5079,6 +5079,7 @@ __metadata:
"@types/node": "npm:^20.5.7"
"@typescript-eslint/eslint-plugin": "npm:^6.5.0"
"@typescript-eslint/parser": "npm:^6.5.0"
aws-xray-sdk: "npm:^3.5.2"
cors: "npm:2.8.5"
dotenv: "npm:^16.0.1"
eslint: "npm:^8.39.0"