mirror of
https://github.com/standardnotes/server
synced 2026-05-10 18:57:20 -04:00
Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e6d8e5c5f2 | |||
| c24353cc24 | |||
| 4855e1d5f5 | |||
| 5d3fb9a537 | |||
| b55d80a7cd | |||
| 16f92bdc99 | |||
| 4c5738416a | |||
| 45d4920e0f | |||
| 94e738532a | |||
| c4ae12d53f | |||
| 4ff78452f9 | |||
| 9465f2ecd8 | |||
| 93c2f1f12f | |||
| ca8a3fc77d | |||
| 00936e06bc | |||
| a6dea50d74 | |||
| 28b04e6a4a | |||
| d228a86f48 | |||
| 0cb234aa47 | |||
| 6b554c28b7 | |||
| 8a0accd8ea | |||
| d66ae62cf4 | |||
| b01d1c659d | |||
| 751f3b2547 | |||
| 11514e3836 | |||
| 71689c1497 | |||
| 2742075edc | |||
| 7f16232f8b | |||
| 0b0703e6d1 | |||
| 3e376c44e3 | |||
| bfe2d4bb4a | |||
| 7253a0a1d9 | |||
| f2c5810023 | |||
| 2e5b9105b8 | |||
| d14411d72e | |||
| 5226513b26 | |||
| 334449f8aa | |||
| 7f43d0c69d | |||
| 6f18276e7a | |||
| 9ff18a18a5 | |||
| 999e72fb1f | |||
| 4733e663a3 | |||
| b48eeb16c3 | |||
| 0aa2584e82 | |||
| eb8c704d84 | |||
| e93fa14703 | |||
| 16a6815b69 | |||
| b08e9731b8 | |||
| 9bd4fb2d79 | |||
| 647aeda1de | |||
| 78ff748d91 | |||
| 31f8cf1169 | |||
| 14bcf7b6c9 | |||
| 74adddd1e7 | |||
| 0e43bc0042 | |||
| b40d539611 | |||
| 654663d17f | |||
| 75830c3a98 | |||
| 1b5078eb96 | |||
| a5e019e290 | |||
| a812f3400a | |||
| 15af5635f0 | |||
| cee6d62791 | |||
| 6aee51bd45 | |||
| 599a84e634 | |||
| 1c3d19cca4 | |||
| 9986e8e7ce | |||
| e19f7a7b7f | |||
| d570146378 | |||
| 8a9e4370e5 | |||
| ce357679e9 | |||
| acab402747 | |||
| e385926046 | |||
| e9b8d0ceb7 | |||
| a2c1ebe675 | |||
| 3ef8e9ea24 |
@@ -26,3 +26,5 @@ MYSQL_ROOT_PASSWORD=changeme123
|
|||||||
AUTH_JWT_SECRET=f95259c5e441f5a4646d76422cfb3df4c4488842901aa50b6c51b8be2e0040e9
|
AUTH_JWT_SECRET=f95259c5e441f5a4646d76422cfb3df4c4488842901aa50b6c51b8be2e0040e9
|
||||||
AUTH_SERVER_ENCRYPTION_SERVER_KEY=1087415dfde3093797f9a7ca93a49e7d7aa1861735eb0d32aae9c303b8c3d060
|
AUTH_SERVER_ENCRYPTION_SERVER_KEY=1087415dfde3093797f9a7ca93a49e7d7aa1861735eb0d32aae9c303b8c3d060
|
||||||
VALET_TOKEN_SECRET=4b886819ebe1e908077c6cae96311b48a8416bd60cc91c03060e15bdf6b30d1f
|
VALET_TOKEN_SECRET=4b886819ebe1e908077c6cae96311b48a8416bd60cc91c03060e15bdf6b30d1f
|
||||||
|
|
||||||
|
SYNCING_SERVER_CONTENT_SIZE_TRANSFER_LIMIT=1000000
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ jobs:
|
|||||||
run: yarn build
|
run: yarn build
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
@@ -69,7 +69,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Login to Amazon ECR
|
- name: Login to Amazon ECR
|
||||||
id: login-ecr
|
id: login-ecr
|
||||||
uses: aws-actions/amazon-ecr-login@v1
|
uses: aws-actions/amazon-ecr-login@v2
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@master
|
uses: docker/setup-qemu-action@master
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ jobs:
|
|||||||
echo "ACCESS_TOKEN_AGE=4" >> packages/home-server/.env
|
echo "ACCESS_TOKEN_AGE=4" >> packages/home-server/.env
|
||||||
echo "REFRESH_TOKEN_AGE=10" >> packages/home-server/.env
|
echo "REFRESH_TOKEN_AGE=10" >> packages/home-server/.env
|
||||||
echo "REVISIONS_FREQUENCY=2" >> packages/home-server/.env
|
echo "REVISIONS_FREQUENCY=2" >> packages/home-server/.env
|
||||||
|
echo "CONTENT_SIZE_TRANSFER_LIMIT=1000000" >> packages/home-server/.env
|
||||||
echo "DB_HOST=localhost" >> packages/home-server/.env
|
echo "DB_HOST=localhost" >> packages/home-server/.env
|
||||||
echo "DB_PORT=3306" >> packages/home-server/.env
|
echo "DB_PORT=3306" >> packages/home-server/.env
|
||||||
echo "DB_DATABASE=standardnotes" >> packages/home-server/.env
|
echo "DB_DATABASE=standardnotes" >> packages/home-server/.env
|
||||||
|
|||||||
@@ -103,10 +103,10 @@ jobs:
|
|||||||
snjs_image_tag: 'latest'
|
snjs_image_tag: 'latest'
|
||||||
suite: 'base'
|
suite: 'base'
|
||||||
|
|
||||||
# e2e-vaults:
|
e2e-vaults:
|
||||||
# needs: build
|
needs: build
|
||||||
# name: E2E Vaults Suite
|
name: E2E Vaults Suite
|
||||||
# uses: standardnotes/server/.github/workflows/common-e2e.yml@main
|
uses: standardnotes/server/.github/workflows/common-e2e.yml@main
|
||||||
# with:
|
with:
|
||||||
# snjs_image_tag: 'latest'
|
snjs_image_tag: 'latest'
|
||||||
# suite: 'vaults'
|
suite: 'vaults'
|
||||||
|
|||||||
@@ -103,22 +103,22 @@ jobs:
|
|||||||
snjs_image_tag: 'latest'
|
snjs_image_tag: 'latest'
|
||||||
suite: 'base'
|
suite: 'base'
|
||||||
|
|
||||||
# e2e-vaults:
|
e2e-vaults:
|
||||||
# needs: build
|
needs: build
|
||||||
# name: E2E Vaults Suite
|
name: E2E Vaults Suite
|
||||||
# uses: standardnotes/server/.github/workflows/common-e2e.yml@main
|
uses: standardnotes/server/.github/workflows/common-e2e.yml@main
|
||||||
# with:
|
with:
|
||||||
# snjs_image_tag: 'latest'
|
snjs_image_tag: 'latest'
|
||||||
# suite: 'vaults'
|
suite: 'vaults'
|
||||||
|
|
||||||
publish-self-hosting:
|
publish-self-hosting:
|
||||||
needs: [ test, lint, e2e-base ]
|
needs: [ test, lint, e2e-base, e2e-vaults ]
|
||||||
name: Publish Self Hosting Docker Image
|
name: Publish Self Hosting Docker Image
|
||||||
uses: standardnotes/server/.github/workflows/common-self-hosting.yml@main
|
uses: standardnotes/server/.github/workflows/common-self-hosting.yml@main
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
publish-services:
|
publish-services:
|
||||||
needs: [ test, lint, e2e-base ]
|
needs: [ test, lint, e2e-base, e2e-vaults ]
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ jobs:
|
|||||||
git config --global user.email "ci@standardnotes.com"
|
git config --global user.email "ci@standardnotes.com"
|
||||||
|
|
||||||
- name: Import GPG key
|
- name: Import GPG key
|
||||||
uses: crazy-max/ghaction-import-gpg@v5
|
uses: crazy-max/ghaction-import-gpg@v6
|
||||||
with:
|
with:
|
||||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
passphrase: ${{ secrets.PASSPHRASE }}
|
passphrase: ${{ secrets.PASSPHRASE }}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,6 +3,8 @@ FROM node:20.6.1-alpine
|
|||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
|
||||||
RUN apk add --update --no-cache \
|
RUN apk add --update --no-cache \
|
||||||
|
g++ \
|
||||||
|
make \
|
||||||
openssl \
|
openssl \
|
||||||
curl \
|
curl \
|
||||||
bash \
|
bash \
|
||||||
|
|||||||
@@ -57,9 +57,6 @@ fi
|
|||||||
if [ -z "$CACHE_TYPE" ]; then
|
if [ -z "$CACHE_TYPE" ]; then
|
||||||
export CACHE_TYPE="redis"
|
export CACHE_TYPE="redis"
|
||||||
fi
|
fi
|
||||||
if [ -z "$SECONDARY_DB_ENABLED" ]; then
|
|
||||||
export SECONDARY_DB_ENABLED=false
|
|
||||||
fi
|
|
||||||
export DB_MIGRATIONS_PATH="dist/migrations/*.js"
|
export DB_MIGRATIONS_PATH="dist/migrations/*.js"
|
||||||
|
|
||||||
#########
|
#########
|
||||||
|
|||||||
@@ -3,6 +3,34 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [2.33.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.32.6...@standardnotes/analytics@2.33.0) (2023-11-10)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add graceful shutdown procedures upon SIGTERM ([#923](https://github.com/standardnotes/server/issues/923)) ([c24353c](https://github.com/standardnotes/server/commit/c24353cc24ebf4b40ff9a2cec8e37cfdef109e37))
|
||||||
|
|
||||||
|
## [2.32.6](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.32.5...@standardnotes/analytics@2.32.6) (2023-11-07)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.32.5](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.32.4...@standardnotes/analytics@2.32.5) (2023-11-07)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove open telemetry from code ([#903](https://github.com/standardnotes/server/issues/903)) ([751f3b2](https://github.com/standardnotes/server/commit/751f3b25476c5be3d663ad8540c43266acd39493))
|
||||||
|
|
||||||
|
## [2.32.4](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.32.3...@standardnotes/analytics@2.32.4) (2023-10-26)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.32.3](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.32.2...@standardnotes/analytics@2.32.3) (2023-10-26)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.32.2](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.32.1...@standardnotes/analytics@2.32.2) (2023-10-19)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
## [2.32.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.32.0...@standardnotes/analytics@2.32.1) (2023-10-18)
|
## [2.32.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.32.0...@standardnotes/analytics@2.32.1) (2023-10-18)
|
||||||
|
|
||||||
**Note:** Version bump only for package @standardnotes/analytics
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
import 'reflect-metadata'
|
import 'reflect-metadata'
|
||||||
|
|
||||||
import { OpenTelemetrySDK, OpenTelemetryTracer } from '@standardnotes/domain-events-infra'
|
|
||||||
import { EmailLevel, ServiceIdentifier } from '@standardnotes/domain-core'
|
|
||||||
|
|
||||||
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.AnalyticsScheduledTask })
|
|
||||||
sdk.start()
|
|
||||||
|
|
||||||
import { Logger } from 'winston'
|
import { Logger } from 'winston'
|
||||||
|
|
||||||
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
||||||
@@ -22,6 +16,7 @@ import { CalculateMonthlyRecurringRevenue } from '../src/Domain/UseCase/Calculat
|
|||||||
import { getBody, getSubject } from '../src/Domain/Email/DailyAnalyticsReport'
|
import { getBody, getSubject } from '../src/Domain/Email/DailyAnalyticsReport'
|
||||||
import { TimerInterface } from '@standardnotes/time'
|
import { TimerInterface } from '@standardnotes/time'
|
||||||
import { StatisticMeasureName } from '../src/Domain/Statistics/StatisticMeasureName'
|
import { StatisticMeasureName } from '../src/Domain/Statistics/StatisticMeasureName'
|
||||||
|
import { EmailLevel } from '@standardnotes/domain-core'
|
||||||
|
|
||||||
const requestReport = async (
|
const requestReport = async (
|
||||||
analyticsStore: AnalyticsStoreInterface,
|
analyticsStore: AnalyticsStoreInterface,
|
||||||
@@ -275,9 +270,6 @@ void container.load().then((container) => {
|
|||||||
|
|
||||||
logger.info(`Sending report to following admins: ${adminEmails}`)
|
logger.info(`Sending report to following admins: ${adminEmails}`)
|
||||||
|
|
||||||
const tracer = new OpenTelemetryTracer()
|
|
||||||
tracer.startSpan(ServiceIdentifier.NAMES.AnalyticsScheduledTask, 'report')
|
|
||||||
|
|
||||||
Promise.resolve(
|
Promise.resolve(
|
||||||
requestReport(
|
requestReport(
|
||||||
analyticsStore,
|
analyticsStore,
|
||||||
@@ -293,15 +285,11 @@ void container.load().then((container) => {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
logger.info('Usage report generation complete')
|
logger.info('Usage report generation complete')
|
||||||
|
|
||||||
tracer.stopSpan()
|
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
logger.error(`Could not finish usage report generation: ${error.message}`)
|
logger.error(`Could not finish usage report generation: ${error.message}`)
|
||||||
|
|
||||||
tracer.stopSpanWithError(error)
|
|
||||||
|
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
import 'reflect-metadata'
|
import 'reflect-metadata'
|
||||||
|
|
||||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
|
||||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
|
||||||
|
|
||||||
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.AnalyticsWorker })
|
|
||||||
sdk.start()
|
|
||||||
|
|
||||||
import { Logger } from 'winston'
|
import { Logger } from 'winston'
|
||||||
import { DomainEventSubscriberInterface } from '@standardnotes/domain-events'
|
import { DomainEventSubscriberInterface } from '@standardnotes/domain-events'
|
||||||
import * as dayjs from 'dayjs'
|
import * as dayjs from 'dayjs'
|
||||||
@@ -28,5 +22,11 @@ void container.load().then((container) => {
|
|||||||
|
|
||||||
const subscriber = container.get<DomainEventSubscriberInterface>(TYPES.DomainEventSubscriber)
|
const subscriber = container.get<DomainEventSubscriberInterface>(TYPES.DomainEventSubscriber)
|
||||||
|
|
||||||
|
process.on('SIGTERM', () => {
|
||||||
|
logger.info('SIGTERM received. Stopping worker...')
|
||||||
|
subscriber.stop()
|
||||||
|
logger.info('Worker stopped.')
|
||||||
|
})
|
||||||
|
|
||||||
subscriber.start()
|
subscriber.start()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ COMMAND=$1 && shift 1
|
|||||||
case "$COMMAND" in
|
case "$COMMAND" in
|
||||||
'start-worker' )
|
'start-worker' )
|
||||||
echo "[Docker] Starting Worker..."
|
echo "[Docker] Starting Worker..."
|
||||||
node docker/entrypoint-worker.js
|
exec node docker/entrypoint-worker.js
|
||||||
;;
|
;;
|
||||||
|
|
||||||
'report' )
|
'report' )
|
||||||
echo "[Docker] Starting Usage Report Generation..."
|
echo "[Docker] Starting Usage Report Generation..."
|
||||||
node docker/entrypoint-report.js
|
exec node docker/entrypoint-report.js
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
* )
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/analytics",
|
"name": "@standardnotes/analytics",
|
||||||
"version": "2.32.1",
|
"version": "2.33.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
DomainEventPublisherInterface,
|
DomainEventPublisherInterface,
|
||||||
DomainEventSubscriberInterface,
|
DomainEventSubscriberInterface,
|
||||||
} from '@standardnotes/domain-events'
|
} from '@standardnotes/domain-events'
|
||||||
import { MapperInterface, ServiceIdentifier } from '@standardnotes/domain-core'
|
import { MapperInterface } from '@standardnotes/domain-core'
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const Mixpanel = require('mixpanel')
|
const Mixpanel = require('mixpanel')
|
||||||
|
|
||||||
@@ -16,9 +16,9 @@ import TYPES from './Types'
|
|||||||
import { AppDataSource } from './DataSource'
|
import { AppDataSource } from './DataSource'
|
||||||
import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
|
import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
|
||||||
import {
|
import {
|
||||||
SNSOpenTelemetryDomainEventPublisher,
|
SNSDomainEventPublisher,
|
||||||
|
SQSDomainEventSubscriber,
|
||||||
SQSEventMessageHandler,
|
SQSEventMessageHandler,
|
||||||
SQSOpenTelemetryDomainEventSubscriber,
|
|
||||||
} from '@standardnotes/domain-events-infra'
|
} from '@standardnotes/domain-events-infra'
|
||||||
import { Timer, TimerInterface } from '@standardnotes/time'
|
import { Timer, TimerInterface } from '@standardnotes/time'
|
||||||
import { PeriodKeyGeneratorInterface } from '../Domain/Time/PeriodKeyGeneratorInterface'
|
import { PeriodKeyGeneratorInterface } from '../Domain/Time/PeriodKeyGeneratorInterface'
|
||||||
@@ -139,9 +139,7 @@ export class ContainerConfigLoader {
|
|||||||
|
|
||||||
container
|
container
|
||||||
.bind<DomainEventPublisherInterface>(TYPES.DomainEventPublisher)
|
.bind<DomainEventPublisherInterface>(TYPES.DomainEventPublisher)
|
||||||
.toConstantValue(
|
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
|
||||||
new SNSOpenTelemetryDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)),
|
|
||||||
)
|
|
||||||
if (env.get('MIXPANEL_TOKEN', true)) {
|
if (env.get('MIXPANEL_TOKEN', true)) {
|
||||||
container.bind<Mixpanel>(TYPES.MixpanelClient).toConstantValue(Mixpanel.init(env.get('MIXPANEL_TOKEN', true)))
|
container.bind<Mixpanel>(TYPES.MixpanelClient).toConstantValue(Mixpanel.init(env.get('MIXPANEL_TOKEN', true)))
|
||||||
}
|
}
|
||||||
@@ -242,8 +240,7 @@ export class ContainerConfigLoader {
|
|||||||
container
|
container
|
||||||
.bind<DomainEventSubscriberInterface>(TYPES.DomainEventSubscriber)
|
.bind<DomainEventSubscriberInterface>(TYPES.DomainEventSubscriber)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new SQSOpenTelemetryDomainEventSubscriber(
|
new SQSDomainEventSubscriber(
|
||||||
ServiceIdentifier.NAMES.AnalyticsWorker,
|
|
||||||
container.get<SQSClient>(TYPES.SQS),
|
container.get<SQSClient>(TYPES.SQS),
|
||||||
container.get<string>(TYPES.SQS_QUEUE_URL),
|
container.get<string>(TYPES.SQS_QUEUE_URL),
|
||||||
container.get<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler),
|
container.get<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler),
|
||||||
|
|||||||
@@ -3,6 +3,108 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [1.82.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.14...@standardnotes/api-gateway@1.82.0) (2023-11-10)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add graceful shutdown procedures upon SIGTERM ([#923](https://github.com/standardnotes/api-gateway/issues/923)) ([c24353c](https://github.com/standardnotes/api-gateway/commit/c24353cc24ebf4b40ff9a2cec8e37cfdef109e37))
|
||||||
|
|
||||||
|
## [1.81.14](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.13...@standardnotes/api-gateway@1.81.14) (2023-11-10)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **api-gateway:** add logs about calling web sockets with minimal format ([5d3fb9a](https://github.com/standardnotes/api-gateway/commit/5d3fb9a537f6971cfe8ae3c5ea449806cc4de8a0))
|
||||||
|
|
||||||
|
## [1.81.13](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.12...@standardnotes/api-gateway@1.81.13) (2023-11-09)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **api-gateway:** add possibility to configure keep-alive timeout ([#920](https://github.com/standardnotes/api-gateway/issues/920)) ([16f92bd](https://github.com/standardnotes/api-gateway/commit/16f92bdc990ded5c3f1fe5af1e6e4a113a9954de))
|
||||||
|
|
||||||
|
## [1.81.12](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.11...@standardnotes/api-gateway@1.81.12) (2023-11-09)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* reduce websockets api communication data ([#919](https://github.com/standardnotes/api-gateway/issues/919)) ([c4ae12d](https://github.com/standardnotes/api-gateway/commit/c4ae12d53fc166879f90a4c5dbad1ab1cb4797e2))
|
||||||
|
|
||||||
|
## [1.81.11](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.10...@standardnotes/api-gateway@1.81.11) (2023-11-07)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **api-gateway:** remove calling both auth and payments on account deletion request ([6b554c2](https://github.com/standardnotes/api-gateway/commit/6b554c28b731a9080d7ad2942d3fa05c01dcabf2))
|
||||||
|
|
||||||
|
## [1.81.10](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.9...@standardnotes/api-gateway@1.81.10) (2023-11-07)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.81.9](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.8...@standardnotes/api-gateway@1.81.9) (2023-11-07)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove open telemetry from code ([#903](https://github.com/standardnotes/api-gateway/issues/903)) ([751f3b2](https://github.com/standardnotes/api-gateway/commit/751f3b25476c5be3d663ad8540c43266acd39493))
|
||||||
|
|
||||||
|
## [1.81.8](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.7...@standardnotes/api-gateway@1.81.8) (2023-11-03)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* retry attempts on session validation and more verbose logs ([#898](https://github.com/standardnotes/api-gateway/issues/898)) ([3e376c4](https://github.com/standardnotes/api-gateway/commit/3e376c44e3a6c336dcff3d8ef5eb3ab040d9a561))
|
||||||
|
|
||||||
|
## [1.81.7](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.6...@standardnotes/api-gateway@1.81.7) (2023-10-31)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add fallback methods for 404 requests ([#893](https://github.com/standardnotes/api-gateway/issues/893)) ([16a6815](https://github.com/standardnotes/api-gateway/commit/16a6815b69e344573ae07682f3bac1d44d715d79))
|
||||||
|
|
||||||
|
## [1.81.6](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.5...@standardnotes/api-gateway@1.81.6) (2023-10-27)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **api-gateway:** logs for errors reaching service ([14bcf7b](https://github.com/standardnotes/api-gateway/commit/14bcf7b6c9403c3413e7579f58ea17168d14dce7))
|
||||||
|
|
||||||
|
## [1.81.5](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.4...@standardnotes/api-gateway@1.81.5) (2023-10-26)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.81.4](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.3...@standardnotes/api-gateway@1.81.4) (2023-10-26)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **api-gateway:** retry attempts and logs ([654663d](https://github.com/standardnotes/api-gateway/commit/654663d17f6eee15f7bf2bc7f40e6c37a3d8e53c))
|
||||||
|
|
||||||
|
## [1.81.3](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.2...@standardnotes/api-gateway@1.81.3) (2023-10-26)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.81.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.1...@standardnotes/api-gateway@1.81.2) (2023-10-20)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **api-gateway:** add session validation retry attempts on timedout requests ([6aee51b](https://github.com/standardnotes/api-gateway/commit/6aee51bd45c25e85d01075a9c8d2854b32dd6e3c))
|
||||||
|
|
||||||
|
## [1.81.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.0...@standardnotes/api-gateway@1.81.1) (2023-10-20)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **api-gateway:** logs severity on retry attempts ([1c3d19c](https://github.com/standardnotes/api-gateway/commit/1c3d19cca43a7a3eba2b0d05c820de5112edf89e))
|
||||||
|
|
||||||
|
# [1.81.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.80.1...@standardnotes/api-gateway@1.81.0) (2023-10-20)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **api-gateway:** add retry attempts on timedout requests ([#885](https://github.com/standardnotes/api-gateway/issues/885)) ([ce35767](https://github.com/standardnotes/api-gateway/commit/ce357679e9bc704ab562e9d6ca192f49a794a664))
|
||||||
|
|
||||||
|
## [1.80.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.80.0...@standardnotes/api-gateway@1.80.1) (2023-10-19)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **api-gateway:** stringify error in service proxy ([e385926](https://github.com/standardnotes/api-gateway/commit/e38592604644e0f52df0865ffae5b7e79d1d3d07))
|
||||||
|
|
||||||
|
# [1.80.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.14...@standardnotes/api-gateway@1.80.0) (2023-10-19)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* remove transition state ([#882](https://github.com/standardnotes/api-gateway/issues/882)) ([a2c1ebe](https://github.com/standardnotes/api-gateway/commit/a2c1ebe675cd5678c923715056a6966f465a15d6))
|
||||||
|
|
||||||
## [1.79.14](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.13...@standardnotes/api-gateway@1.79.14) (2023-10-18)
|
## [1.79.14](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.13...@standardnotes/api-gateway@1.79.14) (2023-10-18)
|
||||||
|
|
||||||
**Note:** Version bump only for package @standardnotes/api-gateway
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
import 'reflect-metadata'
|
import 'reflect-metadata'
|
||||||
|
|
||||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
|
||||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
|
||||||
|
|
||||||
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.ApiGateway })
|
|
||||||
sdk.start()
|
|
||||||
|
|
||||||
import '../src/Controller/LegacyController'
|
import '../src/Controller/LegacyController'
|
||||||
import '../src/Controller/HealthCheckController'
|
import '../src/Controller/HealthCheckController'
|
||||||
|
|
||||||
@@ -108,9 +102,18 @@ void container.load().then((container) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const serverInstance = server.build()
|
const serverInstance = server.build().listen(env.get('PORT'))
|
||||||
|
|
||||||
serverInstance.listen(env.get('PORT'))
|
const keepAliveTimeout = env.get('KEEP_ALIVE_TIMEOUT', true) ? +env.get('KEEP_ALIVE_TIMEOUT', true) : 5000
|
||||||
|
|
||||||
|
serverInstance.keepAliveTimeout = keepAliveTimeout
|
||||||
|
|
||||||
|
process.on('SIGTERM', () => {
|
||||||
|
logger.info('SIGTERM signal received: closing HTTP server')
|
||||||
|
serverInstance.close(() => {
|
||||||
|
logger.info('HTTP server closed')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
logger.info(`Server started on port ${process.env.PORT}`)
|
logger.info(`Server started on port ${process.env.PORT}`)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ COMMAND=$1 && shift 1
|
|||||||
case "$COMMAND" in
|
case "$COMMAND" in
|
||||||
'start-web' )
|
'start-web' )
|
||||||
echo "Starting Web..."
|
echo "Starting Web..."
|
||||||
node docker/entrypoint-server.js
|
exec node docker/entrypoint-server.js
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
* )
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/api-gateway",
|
"name": "@standardnotes/api-gateway",
|
||||||
"version": "1.79.14",
|
"version": "1.82.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ export class ContainerConfigLoader {
|
|||||||
.to(SubscriptionTokenAuthMiddleware)
|
.to(SubscriptionTokenAuthMiddleware)
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
|
container.bind<TimerInterface>(TYPES.ApiGateway_Timer).toConstantValue(new Timer())
|
||||||
|
|
||||||
if (isConfiguredForHomeServer) {
|
if (isConfiguredForHomeServer) {
|
||||||
if (!configuration?.serviceContainer) {
|
if (!configuration?.serviceContainer) {
|
||||||
throw new Error('Service container is required when configured for home server')
|
throw new Error('Service container is required when configured for home server')
|
||||||
@@ -115,7 +117,6 @@ export class ContainerConfigLoader {
|
|||||||
} else {
|
} else {
|
||||||
container.bind<ServiceProxyInterface>(TYPES.ApiGateway_ServiceProxy).to(HttpServiceProxy)
|
container.bind<ServiceProxyInterface>(TYPES.ApiGateway_ServiceProxy).to(HttpServiceProxy)
|
||||||
}
|
}
|
||||||
container.bind<TimerInterface>(TYPES.ApiGateway_Timer).toConstantValue(new Timer())
|
|
||||||
|
|
||||||
if (isConfiguredForHomeServer) {
|
if (isConfiguredForHomeServer) {
|
||||||
container
|
container
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export abstract class AuthMiddleware extends BaseMiddleware {
|
|||||||
crossServiceToken = await this.crossServiceTokenCache.get(cacheKey)
|
crossServiceToken = await this.crossServiceTokenCache.get(cacheKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.crossServiceTokenIsEmptyOrRequiresRevalidation(crossServiceToken)) {
|
if (crossServiceToken === null) {
|
||||||
const authResponse = await this.serviceProxy.validateSession({
|
const authResponse = await this.serviceProxy.validateSession({
|
||||||
authorization: authHeaderValue,
|
authorization: authHeaderValue,
|
||||||
sharedVaultOwnerContext: sharedVaultOwnerContextHeaderValue,
|
sharedVaultOwnerContext: sharedVaultOwnerContextHeaderValue,
|
||||||
@@ -74,13 +74,16 @@ export abstract class AuthMiddleware extends BaseMiddleware {
|
|||||||
response.locals.sharedVaultOwnerContext = decodedToken.shared_vault_owner_context
|
response.locals.sharedVaultOwnerContext = decodedToken.shared_vault_owner_context
|
||||||
response.locals.belongsToSharedVaults = decodedToken.belongs_to_shared_vaults ?? []
|
response.locals.belongsToSharedVaults = decodedToken.belongs_to_shared_vaults ?? []
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = (error as AxiosError).isAxiosError
|
let detailedErrorMessage = (error as Error).message
|
||||||
? JSON.stringify((error as AxiosError).response?.data)
|
if (error instanceof AxiosError) {
|
||||||
: (error as Error).message
|
detailedErrorMessage = `Status: ${error.status}, code: ${error.code}, message: ${error.message}`
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.error(`Could not pass the request to sessions/validate on underlying service: ${errorMessage}`)
|
this.logger.error(
|
||||||
|
`Could not pass the request to sessions/validate on underlying service: ${detailedErrorMessage}`,
|
||||||
|
)
|
||||||
|
|
||||||
this.logger.debug('Response error: %O', (error as AxiosError).response ?? error)
|
this.logger.debug(`Response error: ${JSON.stringify(error)}`)
|
||||||
|
|
||||||
if ((error as AxiosError).response?.headers['content-type']) {
|
if ((error as AxiosError).response?.headers['content-type']) {
|
||||||
response.setHeader('content-type', (error as AxiosError).response?.headers['content-type'] as string)
|
response.setHeader('content-type', (error as AxiosError).response?.headers['content-type'] as string)
|
||||||
@@ -91,7 +94,14 @@ export abstract class AuthMiddleware extends BaseMiddleware {
|
|||||||
? +((error as AxiosError).code as string)
|
? +((error as AxiosError).code as string)
|
||||||
: 500
|
: 500
|
||||||
|
|
||||||
response.status(errorCode).send(errorMessage)
|
const responseErrorMessage = (error as AxiosError).response?.data
|
||||||
|
|
||||||
|
response
|
||||||
|
.status(errorCode)
|
||||||
|
.send(
|
||||||
|
responseErrorMessage ??
|
||||||
|
"Unfortunately, we couldn't handle your request. Please try again or contact our support if the error persists.",
|
||||||
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -129,14 +139,4 @@ export abstract class AuthMiddleware extends BaseMiddleware {
|
|||||||
|
|
||||||
return Math.min(crossServiceTokenDefaultCacheExpiration, sessionAccessExpiration, sessionRefreshExpiration)
|
return Math.min(crossServiceTokenDefaultCacheExpiration, sessionAccessExpiration, sessionRefreshExpiration)
|
||||||
}
|
}
|
||||||
|
|
||||||
private crossServiceTokenIsEmptyOrRequiresRevalidation(crossServiceToken: string | null) {
|
|
||||||
if (crossServiceToken === null) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
const decodedToken = <CrossServiceTokenData>verify(crossServiceToken, this.jwtSecret, { algorithms: ['HS256'] })
|
|
||||||
|
|
||||||
return decodedToken.ongoing_transition === true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user