Compare commits

..

32 Commits

Author SHA1 Message Date
standardci
787eedc8af chore(release): publish new version
- @standardnotes/analytics@2.19.16
 - @standardnotes/api-gateway@1.46.11
 - @standardnotes/auth-server@1.87.12
 - @standardnotes/files-server@1.9.15
 - @standardnotes/revisions-server@1.10.28
 - @standardnotes/scheduler-server@1.16.19
 - @standardnotes/syncing-server@1.29.14
 - @standardnotes/websockets-server@1.5.20
 - @standardnotes/workspace-server@1.19.23
2023-02-06 14:37:52 +00:00
Karol Sójko
040a2b5e5f chore: fix e2e workflow 2023-02-06 15:35:49 +01:00
Karol Sójko
347ee275fa Merge pull request #437 from standardnotes/supervisor
feat: self-hosted setup with one container
2023-02-06 15:34:44 +01:00
Karol Sójko
1c0a9e6726 fix: e2e test suite 2023-02-06 15:34:26 +01:00
Karol Sójko
c4f038ab9a remove @ from common 2023-02-06 15:29:50 +01:00
Karol Sójko
3746ac5fc1 change branch 2023-02-06 15:29:18 +01:00
Karol Sójko
5c4353dd0c extract e2e suite 2023-02-06 15:28:14 +01:00
Karol Sójko
f64caed220 fix: remove login docker from pr 2023-02-06 15:10:51 +01:00
Karol Sójko
863d590292 fix: dockerfile build output 2023-02-06 15:08:03 +01:00
Karol Sójko
0dcf64c82b fix: using mocha 2023-02-06 14:59:24 +01:00
Karol Sójko
48fd5c5ff6 fix: remove command from workflow services 2023-02-06 14:53:16 +01:00
Karol Sójko
84fa374072 fix: workflow env vars 2023-02-06 14:52:28 +01:00
Karol Sójko
2313b0b450 fix: eof empty line 2023-02-06 14:51:18 +01:00
Karol Sójko
4fa6f579af run e2e tests on pr 2023-02-06 14:48:26 +01:00
Karol Sójko
08c1328932 add publishing self hosting image 2023-02-06 13:49:18 +01:00
Karol Sójko
4586308210 add missing depepndabot checks 2023-02-06 13:38:18 +01:00
Karol Sójko
5aa561dcb2 add localstack 2023-02-06 13:35:58 +01:00
Karol Sójko
e07612fe24 remove redis events channels 2023-02-06 11:31:47 +01:00
Karol Sójko
c9289204c4 revisions setup 2023-02-06 11:20:11 +01:00
Karol Sójko
51bb1081a6 files setup 2023-02-06 07:33:16 +01:00
Karol Sójko
25066bb33c syncing server setup 2023-02-06 07:12:25 +01:00
Karol Sójko
bfdb176445 running auth setup 2023-02-06 06:52:11 +01:00
Karol Sójko
42233fa756 auth & auth-worker wip 2023-02-03 17:44:30 +01:00
Karol Sójko
55de4319ed feat: add initial supervisor setup 2023-02-03 11:26:06 +01:00
standardci
306f6edd4e chore(release): publish new version
- @standardnotes/auth-server@1.87.11
2023-02-02 13:52:33 +00:00
Karol Sójko
bf55bbccd9 Revert "fix(auth): disallow adding u2f devices if a user does not have 2fa enabled"
This reverts commit 11bcd318ab.
2023-02-02 14:50:41 +01:00
standardci
6e26c0a0be chore(release): publish new version
- @standardnotes/auth-server@1.87.10
2023-02-02 12:59:22 +00:00
Karol Sójko
11bcd318ab fix(auth): disallow adding u2f devices if a user does not have 2fa enabled 2023-02-02 13:57:27 +01:00
standardci
2f6d19dc91 chore(release): publish new version
- @standardnotes/auth-server@1.87.9
2023-02-02 10:33:14 +00:00
Karol Sójko
989e1ce175 fix(auth): verification rpid options 2023-02-02 11:31:31 +01:00
standardci
1c2fd46401 chore(release): publish new version
- @standardnotes/auth-server@1.87.8
2023-02-02 08:23:06 +00:00
Karol Sójko
b7967b34d1 fix(auth): allow defining multiple expected origins upon u2f registration and verification 2023-02-02 09:21:11 +01:00
67 changed files with 1251 additions and 530 deletions

13
.dockerignore Normal file
View File

@@ -0,0 +1,13 @@
dist
coverage
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/unplugged
!.yarn/sdks
!.yarn/versions
data/*

View File

@@ -1,6 +1,29 @@
###########
# General #
###########
EXPOSED_PORT=3000
#########
# FILES #
#########
EXPOSED_FILES_SERVER_PORT=3042
PUBLIC_FILES_SERVER_URL=http://localhost:3042
######
# DB #
######
DB_HOST=db
DB_PORT=3306
DB_USERNAME=std_notes_user
DB_PASSWORD=changeme123
DB_DATABASE=standard_notes_db
DB_DEBUG_LEVEL=all
DB_MIGRATIONS_PATH=dist/migrations/*.js
#########
# CACHE #
#########
REDIS_PORT=6379
REDIS_HOST=cache

View File

@@ -55,6 +55,11 @@ updates:
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/packages/revisions"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/packages/scheduler"
schedule:
@@ -85,6 +90,11 @@ updates:
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/packages/websockets"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/packages/workspace"
schedule:

101
.github/workflows/common-e2e.yml vendored Normal file
View File

@@ -0,0 +1,101 @@
name: Reusable Run E2E Test Suite Workflow
on:
workflow_call:
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
jobs:
e2e:
runs-on: ubuntu-latest
services:
snjs:
image: standardnotes/snjs
ports:
- 9001:9001
db:
image: mysql:8
env:
MYSQL_DATABASE: standard_notes_db
MYSQL_USER: std_notes_user
MYSQL_PASSWORD: changeme123
MYSQL_ROOT_PASSWORD: changeme123
ports:
- 3306:3306
cache:
image: redis:6.0-alpine
ports:
- 6379:6379
mock-event-publisher:
image: standardnotes/mock-event-publisher
ports:
- 3124:3000
env:
LOG_LEVEL: debug
NODE_ENV: production
VERSION: snjs-test
SNS_TOPIC_ARN: arn:aws:sns:us-east-1:000000000000:payments-local-topic
SNS_ENDPOINT: http://localstack:4566
SNS_DISABLE_SSL: true
SNS_SECRET_ACCESS_KEY: x
SNS_ACCESS_KEY_ID: x
SNS_AWS_REGION: us-east-1
NEW_RELIC_ENABLED: false
options: >-
--name "mock-event-publisher"
steps:
- uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version-file: '.nvmrc'
- name: Build Docker image for E2E testing
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: standardnotes/server:${{ github.sha }}
- name: Run Server
run: docker run -d standardnotes/server:${{ github.sha }}
env:
EXPOSED_PORT: 3123
EXPOSED_FILES_SERVER_PORT: 3125
PUBLIC_FILES_SERVER_URL: http://localhost:3125
DB_HOST: localhost
DB_PORT: 3306
DB_USERNAME: std_notes_user
DB_PASSWORD: changeme123
DB_DATABASE: standard_notes_db
REDIS_PORT: 6379
REDIS_HOST: localhost
AUTH_SERVER_ACCESS_TOKEN_AGE: 4
AUTH_SERVER_REFRESH_TOKEN_AGE: 10
AUTH_SERVER_EPHEMERAL_SESSION_AGE: 300
SYNCING_SERVER_REVISIONS_FREQUENCY: 5
AUTH_SERVER_LOG_LEVEL: debug
SYNCING_SERVER_LOG_LEVEL: debug
FILES_SERVER_LOG_LEVEL: debug
REVISIONS_SERVER_LOG_LEVEL: debug
API_GATEWAY_LOG_LEVEL: debug
- name: Wait for server to start
run: docker/wait-for.sh localhost 3123
- name: Run E2E Test Suite
run: yarn dlx mocha-headless-chrome --timeout 1200000 -f http://localhost:9001/mocha/test.html

View File

@@ -0,0 +1,54 @@
name: Reusable Publish Docker Self Hosting Image Workflow
on:
workflow_call:
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
jobs:
e2e:
name: E2E
uses: standardnotes/server/.github/workflows/common-e2e.yml@main
secrets: inherit
publish:
runs-on: ubuntu-latest
needs: e2e
steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Publish Docker image
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
standardnotes/server:latest
standardnotes/server:${{ github.sha }}

View File

@@ -89,81 +89,8 @@ jobs:
run: yarn test
e2e:
strategy:
matrix:
application:
- { "service_name": "api-gateway", "workspace_name": "@standardnotes/api-gateway", "e2e_tag_parameter_name": "api_gateway_image_tag", "package_path": "packages/api-gateway" }
- { "service_name": "auth", "workspace_name": "@standardnotes/auth-server", "e2e_tag_parameter_name": "auth_image_tag", "package_path": "packages/auth" }
- { "service_name": "files", "workspace_name": "@standardnotes/files-server", "e2e_tag_parameter_name": "files_image_tag", "package_path": "packages/files" }
- { "service_name": "revisions", "workspace_name": "@standardnotes/revisions-server", "e2e_tag_parameter_name": "revisions_image_tag", "package_path": "packages/revisions"}
- { "service_name": "syncing-server-js", "workspace_name": "@standardnotes/syncing-server", "e2e_tag_parameter_name": "syncing_server_js_image_tag", "package_path": "packages/syncing-server" }
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Create Bundle Dir
id: bundle-dir
run: echo "temp_dir=$(mktemp -d -t ${{ matrix.application.service_name }}-${{ github.sha }}-XXXXXXX)" >> $GITHUB_OUTPUT
- name: Cache build
id: cache-build
uses: actions/cache@v3
with:
path: |
packages/**/dist
${{ needs.e2e.outputs.temp_dir }}
key: ${{ runner.os }}-build-${{ github.sha }}
- name: Set up Node
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version-file: '.nvmrc'
- name: Build
if: steps.cache-build.outputs.cache-hit != 'true'
run: yarn build
- name: Bundle
run: yarn workspace ${{ matrix.application.workspace_name }} bundle --no-compress --output-directory ${{ steps.bundle-dir.outputs.temp_dir }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Publish Docker image for E2E testing
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: ${{ steps.bundle-dir.outputs.temp_dir }}
file: ${{ steps.bundle-dir.outputs.temp_dir }}/${{ matrix.application.package_path }}/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: standardnotes/${{ matrix.application.service_name }}:${{ github.sha }}
- name: Run E2E test suite
uses: convictional/trigger-workflow-and-wait@master
with:
owner: standardnotes
repo: self-hosted
github_token: ${{ secrets.CI_PAT_TOKEN }}
workflow_file_name: testing-with-updating-client-and-server.yml
wait_interval: 30
client_payload: '{"${{ matrix.application.e2e_tag_parameter_name }}": "${{ github.sha }}"}'
propagate_failure: true
trigger_workflow: true
wait_workflow: true
name: E2E
uses: standardnotes/server/.github/workflows/common-e2e.yml@main
secrets: inherit

View File

@@ -45,3 +45,10 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_TOKEN }}
publish-self-hosting:
needs: release_and_publish
name: Publish Self Hosting Docker Image
uses: standardnotes/server/.github/workflows/common-self-hosting.yml@main
secrets: inherit

3
.gitignore vendored
View File

@@ -20,3 +20,6 @@ packages/files/uploads/*
data/*
!data/.gitkeep
logs/*
!logs/.gitkeep

29
Dockerfile Normal file
View File

@@ -0,0 +1,29 @@
FROM node:18.13.0-alpine
ENV NODE_ENV production
RUN apk add --update --no-cache \
openssl \
curl \
bash \
py3-pip
RUN pip install --no-cache-dir --upgrade supervisor
RUN mkdir -p /var/lib/server/logs
COPY docker/supervisord.conf /etc/supervisord.conf
COPY docker/docker-entrypoint.sh /usr/local/bin/
COPY . /opt/server
WORKDIR /opt/server
RUN corepack enable
RUN yarn install --immutable
RUN CI=true yarn build
ENTRYPOINT ["docker-entrypoint.sh"]

View File

@@ -1,14 +1,38 @@
version: '3.8'
services:
server:
build: .
env_file: .env
container_name: server-self-hosted
ports:
- ${EXPOSED_PORT}:3000
volumes:
- ./logs:/var/lib/server/logs
localstack:
image: localstack/localstack:1.3
container_name: localstack-self-hosted
expose:
- 4566
restart: unless-stopped
environment:
- SERVICES=sns,sqs
- DOCKER_HOST=unix:///var/run/docker.sock
- HOSTNAME_EXTERNAL=localstack
- LS_LOG=warn
volumes:
- ./docker/localstack_bootstrap.sh:/etc/localstack/init/ready.d/localstack_bootstrap.sh
- /var/run/docker.sock:/var/run/docker.sock
db:
image: mysql:5.6
image: mysql:8
container_name: db-self-hosted
environment:
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
expose:
- ${DB_PORT}:3306
- 3306
restart: unless-stopped
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8 --collation-server=utf8_general_ci
volumes:
@@ -17,8 +41,9 @@ services:
cache:
image: redis:6.0-alpine
container_name: cache-self-hosted
volumes:
- ./data/redis/:/data
expose:
- ${REDIS_PORT}:6379
- 6379
restart: unless-stopped

374
docker/docker-entrypoint.sh Executable file
View File

@@ -0,0 +1,374 @@
#!/bin/bash
# Setup environment variables
#########
# PORTS #
#########
export API_GATEWAY_PORT=3000
if [ -z "$SYNCING_SERVER_PORT" ]; then
export SYNCING_SERVER_PORT=3101
fi
if [ -z "$AUTH_SERVER_PORT" ]; then
export AUTH_SERVER_PORT=3103
fi
if [ -z "$EXPOSED_FILES_SERVER_PORT" ]; then
export FILES_SERVER_PORT=3104
else
export FILES_SERVER_PORT=$EXPOSED_FILES_SERVER_PORT
fi
if [ -z "$REVISIONS_SERVER_PORT" ]; then
export REVISIONS_SERVER_PORT=3105
fi
######
# DB #
######
if [ -z "$DB_HOST" ]; then
export DB_HOST="db"
fi
if [ -z "$DB_PORT" ]; then
export DB_PORT="3306"
fi
if [ -z "$DB_USERNAME" ]; then
export DB_USERNAME="std_notes_user"
fi
if [ -z "$DB_PASSWORD" ]; then
export DB_PASSWORD=$(openssl rand -hex 32)
fi
if [ -z "$DB_DATABASE" ]; then
export DB_DATABASE="standard_notes_db"
fi
if [ -z "$DB_DEBUG_LEVEL" ]; then
export DB_DEBUG_LEVEL="all"
fi
if [ -z "$DB_MIGRATIONS_PATH" ]; then
export DB_MIGRATIONS_PATH="dist/migrations/*.js"
fi
#########
# CACHE #
#########
if [ -z "$REDIS_PORT" ]; then
export REDIS_PORT=6379
fi
if [ -z "$REDIS_HOST" ]; then
export REDIS_URL="redis://cache"
else
export REDIS_URL="redis://$REDIS_HOST"
fi
##########
# SHARED #
##########
if [ -z "$AUTH_JWT_SECRET" ]; then
export AUTH_JWT_SECRET=$(openssl rand -hex 32)
fi
if [ -z "$VALET_TOKEN_SECRET" ]; then
export VALET_TOKEN_SECRET=$(openssl rand -base64 32)
fi
########
# AUTH #
########
if [ -z "$AUTH_SERVER_LOG_LEVEL" ]; then
export AUTH_SERVER_LOG_LEVEL="info"
fi
export AUTH_SERVER_NODE_ENV="production"
export AUTH_SERVER_VERSION="local"
if [ -z "$AUTH_SERVER_AUTH_JWT_TTL" ]; then
export AUTH_SERVER_AUTH_JWT_TTL=60000
fi
export AUTH_SERVER_JWT_SECRET=$AUTH_JWT_SECRET
export AUTH_SERVER_LEGACY_JWT_SECRET=$(openssl rand -hex 32)
export AUTH_SERVER_NEW_RELIC_ENABLED=false
export AUTH_SERVER_NEW_RELIC_APP_NAME=Auth
export AUTH_SERVER_NEW_RELIC_NO_CONFIG_FILE=true
if [ -z "$AUTH_SERVER_DISABLE_USER_REGISTRATION" ]; then
export AUTH_SERVER_DISABLE_USER_REGISTRATION=false
fi
if [ -z "$AUTH_SERVER_PSEUDO_KEY_PARAMS_KEY" ]; then
export AUTH_SERVER_PSEUDO_KEY_PARAMS_KEY=$(openssl rand -hex 32)
fi
if [ -z "$AUTH_SERVER_ACCESS_TOKEN_AGE" ]; then
export AUTH_SERVER_ACCESS_TOKEN_AGE=5184000
fi
if [ -z "$AUTH_SERVER_REFRESH_TOKEN_AGE" ]; then
export AUTH_SERVER_REFRESH_TOKEN_AGE=31556926
fi
if [ -z "$AUTH_SERVER_MAX_LOGIN_ATTEMPTS" ]; then
export AUTH_SERVER_MAX_LOGIN_ATTEMPTS=6
fi
if [ -z "$AUTH_SERVER_FAILED_LOGIN_LOCKOUT" ]; then
export AUTH_SERVER_FAILED_LOGIN_LOCKOUT=3600
fi
if [ -z "$AUTH_SERVER_EPHEMERAL_SESSION_AGE" ]; then
export AUTH_SERVER_EPHEMERAL_SESSION_AGE=259200
fi
if [ -z "$AUTH_SERVER_ENCRYPTION_SERVER_KEY" ]; then
export AUTH_SERVER_ENCRYPTION_SERVER_KEY=$(openssl rand -hex 32)
fi
export AUTH_SERVER_SYNCING_SERVER_URL=http://localhost:$SYNCING_SERVER_PORT
# File Uploads
if [ -z "$AUTH_SERVER_VALET_TOKEN_TTL" ]; then
export AUTH_SERVER_VALET_TOKEN_TTL=7200
fi
# Localstack Setup
if [ -z "$AUTH_SERVER_SNS_TOPIC_ARN" ]; then
export AUTH_SERVER_SNS_TOPIC_ARN="arn:aws:sns:us-east-1:000000000000:auth-local-topic"
fi
if [ -z "$AUTH_SERVER_SNS_ENDPOINT" ]; then
export AUTH_SERVER_SNS_ENDPOINT="http://localstack:4566"
fi
if [ -z "$AUTH_SERVER_SNS_SECRET_ACCESS_KEY" ]; then
export AUTH_SERVER_SNS_SECRET_ACCESS_KEY="x"
fi
if [ -z "$AUTH_SERVER_SNS_ACCESS_KEY_ID" ]; then
export AUTH_SERVER_SNS_ACCESS_KEY_ID="x"
fi
if [ -z "$AUTH_SERVER_SNS_AWS_REGION" ]; then
export AUTH_SERVER_SNS_AWS_REGION="us-east-1"
fi
if [ -z "$AUTH_SERVER_SQS_QUEUE_URL" ]; then
export AUTH_SERVER_SQS_QUEUE_URL="http://localstack:4566/000000000000/auth-local-queue"
fi
if [ -z "$AUTH_SERVER_SQS_AWS_REGION" ]; then
export AUTH_SERVER_SQS_AWS_REGION="us-east-1"
fi
if [ -z "$AUTH_SERVER_SQS_ACCESS_KEY_ID" ]; then
export AUTH_SERVER_SQS_ACCESS_KEY_ID="x"
fi
if [ -z "$AUTH_SERVER_SQS_SECRET_ACCESS_KEY" ]; then
export AUTH_SERVER_SQS_SECRET_ACCESS_KEY="x"
fi
if [ -z "$AUTH_SERVER_SQS_ENDPOINT" ]; then
export AUTH_SERVER_SQS_ENDPOINT="http://localstack:4566"
fi
# U2F Setup
if [ -z "$AUTH_SERVER_U2F_RELYING_PARTY_ID" ]; then
export AUTH_SERVER_U2F_RELYING_PARTY_ID="localhost"
fi
if [ -z "$AUTH_SERVER_U2F_RELYING_PARTY_NAME" ]; then
export AUTH_SERVER_U2F_RELYING_PARTY_NAME="Standard Notes"
fi
if [ -z "$AUTH_SERVER_U2F_EXPECTED_ORIGIN" ]; then
export AUTH_SERVER_U2F_EXPECTED_ORIGIN="http://localhost,http://localhost:3001"
fi
if [ -z "$AUTH_SERVER_U2F_REQUIRE_USER_VERIFICATION" ]; then
export AUTH_SERVER_U2F_REQUIRE_USER_VERIFICATION=false
fi
printenv | grep AUTH_SERVER_ | sed 's/AUTH_SERVER_//g' > /opt/server/packages/auth/.env
##################
# SYNCING SERVER #
##################
if [ -z "$SYNCING_SERVER_LOG_LEVEL" ]; then
export SYNCING_SERVER_LOG_LEVEL="info"
fi
export SYNCING_SERVER_NODE_ENV=production
export SYNCING_SERVER_VERSION=local
if [ -z "$SYNCING_SERVER_SNS_TOPIC_ARN" ]; then
export SYNCING_SERVER_SNS_TOPIC_ARN="arn:aws:sns:us-east-1:000000000000:syncing-server-local-topic"
fi
if [ -z "$SYNCING_SERVER_SNS_ENDPOINT" ]; then
export SYNCING_SERVER_SNS_ENDPOINT="http://localstack:4566"
fi
if [ -z "$SYNCING_SERVER_SNS_SECRET_ACCESS_KEY" ]; then
export SYNCING_SERVER_SNS_SECRET_ACCESS_KEY="x"
fi
if [ -z "$SYNCING_SERVER_SNS_ACCESS_KEY_ID" ]; then
export SYNCING_SERVER_SNS_ACCESS_KEY_ID="x"
fi
if [ -z "$SYNCING_SERVER_SNS_AWS_REGION" ]; then
export SYNCING_SERVER_SNS_AWS_REGION="us-east-1"
fi
if [ -z "$SYNCING_SERVER_SQS_QUEUE_URL" ]; then
export SYNCING_SERVER_SQS_QUEUE_URL="http://localstack:4566/000000000000/syncing-server-local-queue"
fi
if [ -z "$SYNCING_SERVER_SQS_AWS_REGION" ]; then
export SYNCING_SERVER_SQS_AWS_REGION="us-east-1"
fi
if [ -z "$SYNCING_SERVER_SQS_ACCESS_KEY_ID" ]; then
export SYNCING_SERVER_SQS_ACCESS_KEY_ID="x"
fi
if [ -z "$SYNCING_SERVER_SQS_SECRET_ACCESS_KEY" ]; then
export SYNCING_SERVER_SQS_SECRET_ACCESS_KEY="x"
fi
if [ -z "$SYNCING_SERVER_SQS_ENDPOINT" ]; then
export SYNCING_SERVER_SQS_ENDPOINT="http://localstack:4566"
fi
export SYNCING_SERVER_AUTH_SERVER_URL=http://localhost:$AUTH_SERVER_PORT
if [ -z "$SYNCING_SERVER_EMAIL_ATTACHMENT_MAX_BYTE_SIZE" ]; then
export SYNCING_SERVER_EMAIL_ATTACHMENT_MAX_BYTE_SIZE=10485760
fi
if [ -z "$SYNCING_SERVER_REVISIONS_FREQUENCY" ]; then
export SYNCING_SERVER_REVISIONS_FREQUENCY=300
fi
export SYNCING_SERVER_NEW_RELIC_ENABLED=false
export SYNCING_SERVER_NEW_RELIC_APP_NAME="Syncing Server JS"
export SYNCING_SERVER_NEW_RELIC_NO_CONFIG_FILE=true
if [ -z "$SYNCING_SERVER_FILE_UPLOAD_PATH" ]; then
export SYNCING_SERVER_FILE_UPLOAD_PATH="data/uploads"
fi
printenv | grep SYNCING_SERVER_ | sed 's/SYNCING_SERVER_//g' > /opt/server/packages/syncing-server/.env
################
# FILES SERVER #
################
if [ -z "$FILES_SERVER_LOG_LEVEL" ]; then
export FILES_SERVER_LOG_LEVEL="info"
fi
export FILES_SERVER_NODE_ENV="production"
export FILES_SERVER_VERSION="local"
if [ -z "$FILES_SERVER_MAX_CHUNK_BYTES" ]; then
export FILES_SERVER_MAX_CHUNK_BYTES=100000000
fi
export FILES_SERVER_NEW_RELIC_ENABLED=false
if [ -z "$FILES_SERVER_SNS_TOPIC_ARN" ]; then
export FILES_SERVER_SNS_TOPIC_ARN="arn:aws:sns:us-east-1:000000000000:files-local-topic"
fi
if [ -z "$FILES_SERVER_SNS_ENDPOINT" ]; then
export FILES_SERVER_SNS_ENDPOINT="http://localstack:4566"
fi
if [ -z "$FILES_SERVER_SNS_SECRET_ACCESS_KEY" ]; then
export FILES_SERVER_SNS_SECRET_ACCESS_KEY="x"
fi
if [ -z "$FILES_SERVER_SNS_ACCESS_KEY_ID" ]; then
export FILES_SERVER_SNS_ACCESS_KEY_ID="x"
fi
if [ -z "$FILES_SERVER_SNS_AWS_REGION" ]; then
export FILES_SERVER_SNS_AWS_REGION="us-east-1"
fi
if [ -z "$FILES_SERVER_SQS_QUEUE_URL" ]; then
export FILES_SERVER_SQS_QUEUE_URL="http://localstack:4566/000000000000/files-local-queue"
fi
if [ -z "$FILES_SERVER_SQS_AWS_REGION" ]; then
export FILES_SERVER_SQS_AWS_REGION="us-east-1"
fi
if [ -z "$FILES_SERVER_SQS_ACCESS_KEY_ID" ]; then
export FILES_SERVER_SQS_ACCESS_KEY_ID="x"
fi
if [ -z "$FILES_SERVER_SQS_SECRET_ACCESS_KEY" ]; then
export FILES_SERVER_SQS_SECRET_ACCESS_KEY="x"
fi
if [ -z "$FILES_SERVER_SQS_ENDPOINT" ]; then
export FILES_SERVER_SQS_ENDPOINT="http://localstack:4566"
fi
printenv | grep FILES_SERVER_ | sed 's/FILES_SERVER_//g' > /opt/server/packages/files/.env
#############
# REVISIONS #
#############
if [ -z "$REVISIONS_SERVER_LOG_LEVEL" ]; then
export REVISIONS_SERVER_LOG_LEVEL="info"
fi
export REVISIONS_SERVER_NODE_ENV="production"
export REVISIONS_SERVER_VERSION="local"
export REVISIONS_SERVER_NEW_RELIC_ENABLED=false
if [ -z "$REVISIONS_SERVER_SNS_TOPIC_ARN" ]; then
export REVISIONS_SERVER_SNS_TOPIC_ARN="arn:aws:sns:us-east-1:000000000000:revisions-server-local-topic"
fi
if [ -z "$REVISIONS_SERVER_SNS_ENDPOINT" ]; then
export REVISIONS_SERVER_SNS_ENDPOINT="http://localstack:4566"
fi
if [ -z "$REVISIONS_SERVER_SNS_SECRET_ACCESS_KEY" ]; then
export REVISIONS_SERVER_SNS_SECRET_ACCESS_KEY="x"
fi
if [ -z "$REVISIONS_SERVER_SNS_ACCESS_KEY_ID" ]; then
export REVISIONS_SERVER_SNS_ACCESS_KEY_ID="x"
fi
if [ -z "$REVISIONS_SERVER_SNS_AWS_REGION" ]; then
export REVISIONS_SERVER_SNS_AWS_REGION="us-east-1"
fi
if [ -z "$REVISIONS_SERVER_SQS_QUEUE_URL" ]; then
export REVISIONS_SERVER_SQS_QUEUE_URL="http://localstack:4566/000000000000/revisions-server-local-queue"
fi
if [ -z "$REVISIONS_SERVER_SQS_AWS_REGION" ]; then
export REVISIONS_SERVER_SQS_AWS_REGION="us-east-1"
fi
if [ -z "$REVISIONS_SERVER_SQS_ACCESS_KEY_ID" ]; then
export REVISIONS_SERVER_SQS_ACCESS_KEY_ID="x"
fi
if [ -z "$REVISIONS_SERVER_SQS_SECRET_ACCESS_KEY" ]; then
export REVISIONS_SERVER_SQS_SECRET_ACCESS_KEY="x"
fi
if [ -z "$REVISIONS_SERVER_SQS_ENDPOINT" ]; then
export REVISIONS_SERVER_SQS_ENDPOINT="http://localstack:4566"
fi
printenv | grep REVISIONS_SERVER_ | sed 's/REVISIONS_SERVER_//g' > /opt/server/packages/revisions/.env
###############
# API GATEWAY #
###############
if [ -z "$API_GATEWAY_LOG_LEVEL" ]; then
export API_GATEWAY_LOG_LEVEL="info"
fi
export API_GATEWAY_NODE_ENV=production
export API_GATEWAY_VERSION=local
export API_GATEWAY_NEW_RELIC_ENABLED=false
export API_GATEWAY_NEW_RELIC_APP_NAME="API Gateway"
export API_GATEWAY_NEW_RELIC_NO_CONFIG_FILE=true
export API_GATEWAY_SYNCING_SERVER_JS_URL=http://localhost:$SYNCING_SERVER_PORT
export API_GATEWAY_AUTH_SERVER_URL=http://localhost:$AUTH_SERVER_PORT
export API_GATEWAY_WORKSPACE_SERVER_URL=http://localhost:3004
export API_GATEWAY_REVISIONS_SERVER_URL=http://localhost:3005
if [ -z "$PUBLIC_FILES_SERVER_URL" ]; then
export API_GATEWAY_FILES_SERVER_URL=http://localhost:$FILES_SERVER_PORT
else
export API_GATEWAY_FILES_SERVER_URL=$PUBLIC_FILES_SERVER_URL
fi
printenv | grep API_GATEWAY_ | sed 's/API_GATEWAY_//g' > /opt/server/packages/api-gateway/.env
# Run supervisor
supervisord -c /etc/supervisord.conf
exec "$@"

196
docker/localstack_bootstrap.sh Executable file
View File

@@ -0,0 +1,196 @@
#!/usr/bin/env bash
set -euo pipefail
echo "configuring sns/sqs"
echo "==================="
LOCALSTACK_HOST=localhost
AWS_REGION=us-east-1
LOCALSTACK_DUMMY_ID=000000000000
get_all_queues() {
awslocal --endpoint-url=http://${LOCALSTACK_HOST}:4566 sqs list-queues
}
create_queue() {
local QUEUE_NAME_TO_CREATE=$1
awslocal --endpoint-url=http://${LOCALSTACK_HOST}:4566 sqs create-queue --queue-name ${QUEUE_NAME_TO_CREATE}
}
get_all_topics() {
awslocal --endpoint-url=http://${LOCALSTACK_HOST}:4566 sns list-topics
}
create_topic() {
local TOPIC_NAME_TO_CREATE=$1
awslocal --endpoint-url=http://${LOCALSTACK_HOST}:4566 sns create-topic --name ${TOPIC_NAME_TO_CREATE}
}
link_queue_and_topic() {
local TOPIC_ARN_TO_LINK=$1
local QUEUE_ARN_TO_LINK=$2
awslocal --endpoint-url=http://${LOCALSTACK_HOST}:4566 sns subscribe --topic-arn ${TOPIC_ARN_TO_LINK} --protocol sqs --notification-endpoint ${QUEUE_ARN_TO_LINK}
}
get_queue_arn_from_name() {
local QUEUE_NAME=$1
echo "arn:aws:sns:${AWS_REGION}:${LOCALSTACK_DUMMY_ID}:$QUEUE_NAME"
}
get_topic_arn_from_name() {
local TOPIC_NAME=$1
echo "arn:aws:sns:${AWS_REGION}:${LOCALSTACK_DUMMY_ID}:$TOPIC_NAME"
}
PAYMENTS_TOPIC_NAME="payments-local-topic"
echo "creating topic $PAYMENTS_TOPIC_NAME"
TOPIC_CREATED_RESULT=$(create_topic ${PAYMENTS_TOPIC_NAME})
echo "created topic: $TOPIC_CREATED_RESULT"
PAYMENTS_TOPIC_ARN=$(get_topic_arn_from_name $PAYMENTS_TOPIC_NAME)
SYNCING_SERVER_TOPIC_NAME="syncing-server-local-topic"
echo "creating topic $SYNCING_SERVER_TOPIC_NAME"
TOPIC_CREATED_RESULT=$(create_topic ${SYNCING_SERVER_TOPIC_NAME})
echo "created topic: $TOPIC_CREATED_RESULT"
SYNCING_SERVER_TOPIC_ARN=$(get_topic_arn_from_name $SYNCING_SERVER_TOPIC_NAME)
AUTH_TOPIC_NAME="auth-local-topic"
echo "creating topic $AUTH_TOPIC_NAME"
TOPIC_CREATED_RESULT=$(create_topic ${AUTH_TOPIC_NAME})
echo "created topic: $TOPIC_CREATED_RESULT"
AUTH_TOPIC_ARN=$(get_topic_arn_from_name $AUTH_TOPIC_NAME)
FILES_TOPIC_NAME="files-local-topic"
echo "creating topic $FILES_TOPIC_NAME"
TOPIC_CREATED_RESULT=$(create_topic ${FILES_TOPIC_NAME})
echo "created topic: $TOPIC_CREATED_RESULT"
FILES_TOPIC_ARN=$(get_topic_arn_from_name $FILES_TOPIC_NAME)
ANALYTICS_TOPIC_NAME="analytics-local-topic"
echo "creating topic $ANALYTICS_TOPIC_NAME"
TOPIC_CREATED_RESULT=$(create_topic ${ANALYTICS_TOPIC_NAME})
echo "created topic: $TOPIC_CREATED_RESULT"
ANALYTICS_TOPIC_ARN=$(get_topic_arn_from_name $ANALYTICS_TOPIC_NAME)
REVISIONS_TOPIC_NAME="revisions-server-local-topic"
echo "creating topic $REVISIONS_TOPIC_NAME"
TOPIC_CREATED_RESULT=$(create_topic ${REVISIONS_TOPIC_NAME})
echo "created topic: $TOPIC_CREATED_RESULT"
REVISIONS_TOPIC_ARN=$(get_topic_arn_from_name $REVISIONS_TOPIC_NAME)
SCHEDULER_TOPIC_NAME="scheduler-local-topic"
echo "creating topic $SCHEDULER_TOPIC_NAME"
TOPIC_CREATED_RESULT=$(create_topic ${SCHEDULER_TOPIC_NAME})
echo "created topic: $TOPIC_CREATED_RESULT"
SCHEDULER_TOPIC_ARN=$(get_topic_arn_from_name $SCHEDULER_TOPIC_NAME)
WORKSPACE_TOPIC_NAME="workspace-local-topic"
echo "creating topic $WORKSPACE_TOPIC_NAME"
TOPIC_CREATED_RESULT=$(create_topic ${WORKSPACE_TOPIC_NAME})
echo "created topic: $TOPIC_CREATED_RESULT"
WORKSPACE_TOPIC_ARN=$(get_topic_arn_from_name $WORKSPACE_TOPIC_NAME)
QUEUE_NAME="analytics-local-queue"
echo "creating queue $QUEUE_NAME"
QUEUE_URL=$(create_queue ${QUEUE_NAME})
echo "created queue: $QUEUE_URL"
ANALYTICS_QUEUE_ARN=$(get_queue_arn_from_name $QUEUE_NAME)
echo "linking topic $PAYMENTS_TOPIC_ARN to queue $ANALYTICS_QUEUE_ARN"
LINKING_RESULT=$(link_queue_and_topic $PAYMENTS_TOPIC_ARN $ANALYTICS_QUEUE_ARN)
echo "linking done:"
echo "$LINKING_RESULT"
QUEUE_NAME="auth-local-queue"
echo "creating queue $QUEUE_NAME"
QUEUE_URL=$(create_queue ${QUEUE_NAME})
echo "created queue: $QUEUE_URL"
AUTH_QUEUE_ARN=$(get_queue_arn_from_name $QUEUE_NAME)
echo "linking topic $PAYMENTS_TOPIC_ARN to queue $AUTH_QUEUE_ARN"
LINKING_RESULT=$(link_queue_and_topic $PAYMENTS_TOPIC_ARN $AUTH_QUEUE_ARN)
echo "linking done:"
echo "$LINKING_RESULT"
echo "linking topic $AUTH_TOPIC_ARN to queue $AUTH_QUEUE_ARN"
LINKING_RESULT=$(link_queue_and_topic $AUTH_TOPIC_ARN $AUTH_QUEUE_ARN)
echo "linking done:"
echo "$LINKING_RESULT"
echo "linking topic $FILES_TOPIC_ARN to queue $AUTH_QUEUE_ARN"
LINKING_RESULT=$(link_queue_and_topic $FILES_TOPIC_ARN $AUTH_QUEUE_ARN)
echo "linking done:"
echo "$LINKING_RESULT"
QUEUE_NAME="files-local-queue"
echo "creating queue $QUEUE_NAME"
QUEUE_URL=$(create_queue ${QUEUE_NAME})
echo "created queue: $QUEUE_URL"
FILES_QUEUE_ARN=$(get_queue_arn_from_name $QUEUE_NAME)
echo "linking topic $AUTH_TOPIC_ARN to queue $FILES_QUEUE_ARN"
LINKING_RESULT=$(link_queue_and_topic $AUTH_TOPIC_ARN $FILES_QUEUE_ARN)
echo "linking done:"
echo "$LINKING_RESULT"
QUEUE_NAME="syncing-server-local-queue"
echo "creating queue $QUEUE_NAME"
QUEUE_URL=$(create_queue ${QUEUE_NAME})
echo "created queue: $QUEUE_URL"
SYNCING_SERVER_QUEUE_ARN=$(get_queue_arn_from_name $QUEUE_NAME)
echo "linking topic $SYNCING_SERVER_TOPIC_ARN to queue $SYNCING_SERVER_QUEUE_ARN"
LINKING_RESULT=$(link_queue_and_topic $SYNCING_SERVER_TOPIC_ARN $SYNCING_SERVER_QUEUE_ARN)
echo "linking done:"
echo "$LINKING_RESULT"
echo "linking topic $SYNCING_SERVER_TOPIC_ARN to queue $SYNCING_SERVER_QUEUE_ARN"
LINKING_RESULT=$(link_queue_and_topic $SYNCING_SERVER_TOPIC_ARN $SYNCING_SERVER_QUEUE_ARN)
echo "linking done:"
echo "$LINKING_RESULT"
echo "linking topic $AUTH_TOPIC_ARN to queue $SYNCING_SERVER_QUEUE_ARN"
LINKING_RESULT=$(link_queue_and_topic $AUTH_TOPIC_ARN $SYNCING_SERVER_QUEUE_ARN)
echo "linking done:"
echo "$LINKING_RESULT"
QUEUE_NAME="revisions-server-local-queue"
echo "creating queue $QUEUE_NAME"
QUEUE_URL=$(create_queue ${QUEUE_NAME})
echo "created queue: $QUEUE_URL"
REVISIONS_QUEUE_ARN=$(get_queue_arn_from_name $QUEUE_NAME)
echo "linking topic $SYNCING_SERVER_TOPIC_ARN to queue $REVISIONS_QUEUE_ARN"
LINKING_RESULT=$(link_queue_and_topic $SYNCING_SERVER_TOPIC_ARN $REVISIONS_QUEUE_ARN)
echo "linking done:"
echo "$LINKING_RESULT"
QUEUE_NAME="scheduler-local-queue"
echo "creating queue $QUEUE_NAME"
QUEUE_URL=$(create_queue ${QUEUE_NAME})
echo "created queue: $QUEUE_URL"
SCHEDULER_QUEUE_ARN=$(get_queue_arn_from_name $QUEUE_NAME)
QUEUE_NAME="workspace-local-queue"
echo "creating queue $QUEUE_NAME"
QUEUE_URL=$(create_queue ${QUEUE_NAME})
echo "created queue: $QUEUE_URL"
WORKSPACE_QUEUE_ARN=$(get_queue_arn_from_name $QUEUE_NAME)
echo "all topics are:"
echo "$(get_all_topics)"
echo "all queues are:"
echo "$(get_all_queues)"

75
docker/supervisord.conf Normal file
View File

@@ -0,0 +1,75 @@
[supervisord]
nodaemon=true
logfile=/tmp/supervisord.log
[program:api-gateway]
directory=/opt/server
command=yarn start:api-gateway
autostart=true
autorestart=true
stdout_logfile=/var/lib/server/logs/api-gateway.log
stderr_logfile=/var/lib/server/logs/api-gateway.err
[program:auth]
directory=/opt/server
command=yarn start:auth
autostart=true
autorestart=true
stdout_logfile=/var/lib/server/logs/auth.log
stderr_logfile=/var/lib/server/logs/auth.err
[program:auth-worker]
directory=/opt/server
command=yarn start:auth-worker
autostart=true
autorestart=true
stdout_logfile=/var/lib/server/logs/auth-worker.log
stderr_logfile=/var/lib/server/logs/auth-worker.err
[program:syncing-server]
directory=/opt/server
command=yarn start:syncing-server
autostart=true
autorestart=true
stdout_logfile=/var/lib/server/logs/syncing-server.log
stderr_logfile=/var/lib/server/logs/syncing-server.err
[program:syncing-server-worker]
directory=/opt/server
command=yarn start:syncing-server-worker
autostart=true
autorestart=true
stdout_logfile=/var/lib/server/logs/syncing-server-worker.log
stderr_logfile=/var/lib/server/logs/syncing-server-worker.err
[program:files]
directory=/opt/server
command=yarn start:files
autostart=true
autorestart=true
stdout_logfile=/var/lib/server/logs/files.log
stderr_logfile=/var/lib/server/logs/files.err
[program:files-worker]
directory=/opt/server
command=yarn start:files-worker
autostart=true
autorestart=true
stdout_logfile=/var/lib/server/logs/files-worker.log
stderr_logfile=/var/lib/server/logs/files-worker.err
[program:revisions]
directory=/opt/server
command=yarn start:revisions
autostart=true
autorestart=true
stdout_logfile=/var/lib/server/logs/revisions.log
stderr_logfile=/var/lib/server/logs/revisions.err
[program:revisions-worker]
directory=/opt/server
command=yarn start:revisions-worker
autostart=true
autorestart=true
stdout_logfile=/var/lib/server/logs/revisions-worker.log
stderr_logfile=/var/lib/server/logs/revisions-worker.err

13
docker/wait-for.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
WAIT_FOR_HOST="$1"
shift
WAIT_FOR_PORT="$1"
shift
while ! nc -vz $WAIT_FOR_HOST $WAIT_FOR_PORT; do
echo "$WAIT_FOR_HOST:$WAIT_FOR_PORT is unavailable yet - waiting for it to start"
sleep 10
done
echo "$WAIT_FOR_HOST:$WAIT_FOR_PORT is up. Proceeding to startup."

0
logs/.gitkeep Normal file
View File

View File

@@ -24,18 +24,26 @@
"lint:revisions": "yarn workspace @standardnotes/revisions-server lint",
"clean": "yarn workspaces foreach -p --verbose run clean",
"setup:env": "cp .env.sample .env && yarn workspaces foreach -p --verbose run setup:env",
"start:auth": "yarn workspace @standardnotes/auth-server start",
"start:auth-worker": "yarn workspace @standardnotes/auth-server worker",
"wait-for:cache": "docker/wait-for.sh $REDIS_HOST $REDIS_PORT",
"wait-for:db": "docker/wait-for.sh $DB_HOST $DB_PORT",
"wait-for:infra": "yarn wait-for:db && yarn wait-for:cache",
"wait-for:auth": "docker/wait-for.sh localhost $AUTH_SERVER_PORT",
"wait-for:syncing-server": "docker/wait-for.sh localhost $SYNCING_SERVER_PORT",
"wait-for:files": "docker/wait-for.sh localhost $FILES_SERVER_PORT",
"wait-for:revisions": "docker/wait-for.sh localhost $REVISIONS_SERVER_PORT",
"start:auth": "yarn wait-for:infra && yarn workspace @standardnotes/auth-server start",
"start:auth-worker": "yarn wait-for:infra && yarn workspace @standardnotes/auth-server worker",
"start:scheduler": "yarn workspace @standardnotes/scheduler-server worker",
"start:syncing-server": "yarn workspace @standardnotes/syncing-server start",
"start:syncing-server-worker": "yarn workspace @standardnotes/syncing-server worker",
"start:files": "yarn workspace @standardnotes/files-server start",
"start:files-worker": "yarn workspace @standardnotes/files-server worker",
"start:api-gateway": "yarn workspace @standardnotes/api-gateway start",
"start:syncing-server": "yarn wait-for:infra && yarn workspace @standardnotes/syncing-server start",
"start:syncing-server-worker": "yarn wait-for:infra && yarn workspace @standardnotes/syncing-server worker",
"start:files": "yarn wait-for:infra && yarn workspace @standardnotes/files-server start",
"start:files-worker": "yarn wait-for:infra && yarn workspace @standardnotes/files-server worker",
"start:api-gateway": "yarn wait-for:auth && yarn wait-for:syncing-server && yarn wait-for:files && yarn wait-for:revisions && yarn workspace @standardnotes/api-gateway start",
"start:websockets": "yarn workspace @standardnotes/websockets-server start",
"start:workspace": "yarn workspace @standardnotes/workspace-server start",
"start:analytics": "yarn workspace @standardnotes/analytics worker",
"start:revisions": "yarn workspace @standardnotes/revisions-server start",
"start:revisions": "yarn wait-for:infra && yarn workspace @standardnotes/revisions-server start",
"start:revisions-worker": "yarn wait-for:infra && yarn workspace @standardnotes/revisions-server worker",
"release": "lerna version --conventional-graduate --conventional-commits --yes -m \"chore(release): publish new version\"",
"publish": "lerna publish from-git --yes --no-verify-access --loglevel verbose",
"postversion": "./scripts/push-tags-one-by-one.sh",

View File

@@ -13,7 +13,6 @@ DB_MIGRATIONS_PATH=dist/migrations/*.js
ADMIN_EMAILS=test@standardnotes.com
REDIS_URL=redis://cache
REDIS_EVENTS_CHANNEL=events
SNS_TOPIC_ARN=
SNS_AWS_REGION=

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.
## [2.19.16](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.19.15...@standardnotes/analytics@2.19.16) (2023-02-06)
**Note:** Version bump only for package @standardnotes/analytics
## [2.19.15](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.19.14...@standardnotes/analytics@2.19.15) (2023-01-30)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.19.15",
"version": "2.19.16",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -15,9 +15,6 @@ import TYPES from './Types'
import { AppDataSource } from './DataSource'
import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
import {
RedisDomainEventPublisher,
RedisDomainEventSubscriberFactory,
RedisEventMessageHandler,
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
@@ -95,22 +92,20 @@ export class ContainerConfigLoader {
})
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
if (env.get('SNS_TOPIC_ARN', true)) {
const snsConfig: SNSClientConfig = {
apiVersion: 'latest',
region: env.get('SNS_AWS_REGION', true),
}
if (env.get('SNS_ENDPOINT', true)) {
snsConfig.endpoint = env.get('SNS_ENDPOINT', true)
}
if (env.get('SNS_ACCESS_KEY_ID', true) && env.get('SNS_SECRET_ACCESS_KEY', true)) {
snsConfig.credentials = {
accessKeyId: env.get('SNS_ACCESS_KEY_ID', true),
secretAccessKey: env.get('SNS_SECRET_ACCESS_KEY', true),
}
}
container.bind<SNSClient>(TYPES.SNS).toConstantValue(new SNSClient(snsConfig))
const snsConfig: SNSClientConfig = {
apiVersion: 'latest',
region: env.get('SNS_AWS_REGION', true),
}
if (env.get('SNS_ENDPOINT', true)) {
snsConfig.endpoint = env.get('SNS_ENDPOINT', true)
}
if (env.get('SNS_ACCESS_KEY_ID', true) && env.get('SNS_SECRET_ACCESS_KEY', true)) {
snsConfig.credentials = {
accessKeyId: env.get('SNS_ACCESS_KEY_ID', true),
secretAccessKey: env.get('SNS_SECRET_ACCESS_KEY', true),
}
}
container.bind<SNSClient>(TYPES.SNS).toConstantValue(new SNSClient(snsConfig))
if (env.get('SQS_QUEUE_URL', true)) {
const sqsConfig: SQSClientConfig = {
@@ -130,10 +125,9 @@ export class ContainerConfigLoader {
// env vars
container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL'))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN'))
container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true))
container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL'))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true))
container.bind(TYPES.ADMIN_EMAILS).toConstantValue(env.get('ADMIN_EMAILS').split(','))
container.bind(TYPES.MIXPANEL_TOKEN).toConstantValue(env.get('MIXPANEL_TOKEN', true))
@@ -149,17 +143,9 @@ export class ContainerConfigLoader {
.toConstantValue(new RedisStatisticsStore(container.get(TYPES.PeriodKeyGenerator), container.get(TYPES.Redis)))
container.bind<TimerInterface>(TYPES.Timer).toConstantValue(new Timer())
if (env.get('SNS_TOPIC_ARN', true)) {
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
} else {
container
.bind<RedisDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(
new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)),
)
}
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
if (env.get('MIXPANEL_TOKEN', true)) {
container.bind<Mixpanel>(TYPES.MixpanelClient).toConstantValue(Mixpanel.init(env.get('MIXPANEL_TOKEN', true)))
}
@@ -250,37 +236,22 @@ export class ContainerConfigLoader {
['STATISTIC_PERSISTENCE_REQUESTED', container.get(TYPES.StatisticPersistenceRequestedEventHandler)],
])
if (env.get('SQS_QUEUE_URL', true)) {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new RedisDomainEventSubscriberFactory(
container.get(TYPES.Redis),
container.get(TYPES.DomainEventMessageHandler),
container.get(TYPES.REDIS_EVENTS_CHANNEL),
),
)
}
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
return container
}

View File

@@ -9,7 +9,6 @@ const TYPES = {
SNS_AWS_REGION: Symbol.for('SNS_AWS_REGION'),
SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'),
SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'),
REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'),
NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'),
ADMIN_EMAILS: Symbol.for('ADMIN_EMAILS'),
MIXPANEL_TOKEN: Symbol.for('MIXPANEL_TOKEN'),

View File

@@ -27,7 +27,6 @@ NEW_RELIC_LOG_ENABLED=false
NEW_RELIC_LOG_LEVEL=info
REDIS_URL=redis://cache
REDIS_EVENTS_CHANNEL=events
# (Optional) Caching Cross Service Tokens
CROSS_SERVICE_TOKEN_CACHE_TTL=

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.46.11](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.46.10...@standardnotes/api-gateway@1.46.11) (2023-02-06)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.46.10](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.46.9...@standardnotes/api-gateway@1.46.10) (2023-01-30)
**Note:** Version bump only for package @standardnotes/api-gateway

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.46.10",
"version": "1.46.11",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -65,7 +65,6 @@ export class ContainerConfigLoader {
.bind(TYPES.HTTP_CALL_TIMEOUT)
.toConstantValue(env.get('HTTP_CALL_TIMEOUT', true) ? +env.get('HTTP_CALL_TIMEOUT', true) : 60_000)
container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION'))
container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL'))
container.bind(TYPES.CROSS_SERVICE_TOKEN_CACHE_TTL).toConstantValue(+env.get('CROSS_SERVICE_TOKEN_CACHE_TTL', true))
// Middleware

View File

@@ -14,7 +14,6 @@ const TYPES = {
AUTH_JWT_SECRET: Symbol.for('AUTH_JWT_SECRET'),
HTTP_CALL_TIMEOUT: Symbol.for('HTTP_CALL_TIMEOUT'),
VERSION: Symbol.for('VERSION'),
REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'),
CROSS_SERVICE_TOKEN_CACHE_TTL: Symbol.for('CROSS_SERVICE_TOKEN_CACHE_TTL'),
// Middleware
AuthMiddleware: Symbol.for('AuthMiddleware'),

View File

@@ -43,8 +43,6 @@ SQS_AWS_REGION=
SYNCING_SERVER_URL=http://syncing-server-js:3000
REDIS_EVENTS_CHANNEL=events
# (Optional) New Relic Setup
NEW_RELIC_ENABLED=false
NEW_RELIC_APP_NAME=Auth

View File

@@ -3,6 +3,34 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.87.12](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.87.11...@standardnotes/auth-server@1.87.12) (2023-02-06)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.87.11](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.87.10...@standardnotes/auth-server@1.87.11) (2023-02-02)
### Reverts
* Revert "fix(auth): disallow adding u2f devices if a user does not have 2fa enabled" ([bf55bbc](https://github.com/standardnotes/server/commit/bf55bbccd9ab1704671fa3980ede3bd0cc909833))
## [1.87.10](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.87.9...@standardnotes/auth-server@1.87.10) (2023-02-02)
### Bug Fixes
* **auth:** disallow adding u2f devices if a user does not have 2fa enabled ([11bcd31](https://github.com/standardnotes/server/commit/11bcd318abc71d5a1fa80b8beda109076e3b6dad))
## [1.87.9](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.87.8...@standardnotes/auth-server@1.87.9) (2023-02-02)
### Bug Fixes
* **auth:** verification rpid options ([989e1ce](https://github.com/standardnotes/server/commit/989e1ce175cf70718304dd2d2463949147bcc084))
## [1.87.8](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.87.7...@standardnotes/auth-server@1.87.8) (2023-02-02)
### Bug Fixes
* **auth:** allow defining multiple expected origins upon u2f registration and verification ([b7967b3](https://github.com/standardnotes/server/commit/b7967b34d1118534644a3e464e9e43267455519d))
## [1.87.7](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.87.6...@standardnotes/auth-server@1.87.7) (2023-01-30)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.87.7",
"version": "1.87.12",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -90,9 +90,6 @@ import { FeatureService } from '../Domain/Feature/FeatureService'
import { SettingServiceInterface } from '../Domain/Setting/SettingServiceInterface'
import { ExtensionKeyGrantedEventHandler } from '../Domain/Handler/ExtensionKeyGrantedEventHandler'
import {
RedisDomainEventPublisher,
RedisDomainEventSubscriberFactory,
RedisEventMessageHandler,
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
@@ -258,37 +255,33 @@ export class ContainerConfigLoader {
container.bind<TimerInterface>(TYPES.Timer).toConstantValue(new Timer())
if (env.get('SNS_TOPIC_ARN', true)) {
const snsConfig: SNSClientConfig = {
region: env.get('SNS_AWS_REGION', true),
}
if (env.get('SNS_ENDPOINT', true)) {
snsConfig.endpoint = env.get('SNS_ENDPOINT', true)
}
if (env.get('SNS_ACCESS_KEY_ID', true) && env.get('SNS_SECRET_ACCESS_KEY', true)) {
snsConfig.credentials = {
accessKeyId: env.get('SNS_ACCESS_KEY_ID', true),
secretAccessKey: env.get('SNS_SECRET_ACCESS_KEY', true),
}
}
container.bind<SNSClient>(TYPES.SNS).toConstantValue(new SNSClient(snsConfig))
const snsConfig: SNSClientConfig = {
region: env.get('SNS_AWS_REGION', true),
}
if (env.get('SNS_ENDPOINT', true)) {
snsConfig.endpoint = env.get('SNS_ENDPOINT', true)
}
if (env.get('SNS_ACCESS_KEY_ID', true) && env.get('SNS_SECRET_ACCESS_KEY', true)) {
snsConfig.credentials = {
accessKeyId: env.get('SNS_ACCESS_KEY_ID', true),
secretAccessKey: env.get('SNS_SECRET_ACCESS_KEY', true),
}
}
container.bind<SNSClient>(TYPES.SNS).toConstantValue(new SNSClient(snsConfig))
if (env.get('SQS_QUEUE_URL', true)) {
const sqsConfig: SQSClientConfig = {
region: env.get('SQS_AWS_REGION', true),
}
if (env.get('SQS_ENDPOINT', true)) {
sqsConfig.endpoint = env.get('SQS_ENDPOINT', true)
}
if (env.get('SQS_ACCESS_KEY_ID', true) && env.get('SQS_SECRET_ACCESS_KEY', true)) {
sqsConfig.credentials = {
accessKeyId: env.get('SQS_ACCESS_KEY_ID', true),
secretAccessKey: env.get('SQS_SECRET_ACCESS_KEY', true),
}
}
container.bind<SQSClient>(TYPES.SQS).toConstantValue(new SQSClient(sqsConfig))
const sqsConfig: SQSClientConfig = {
region: env.get('SQS_AWS_REGION', true),
}
if (env.get('SQS_ENDPOINT', true)) {
sqsConfig.endpoint = env.get('SQS_ENDPOINT', true)
}
if (env.get('SQS_ACCESS_KEY_ID', true) && env.get('SQS_SECRET_ACCESS_KEY', true)) {
sqsConfig.credentials = {
accessKeyId: env.get('SQS_ACCESS_KEY_ID', true),
secretAccessKey: env.get('SQS_SECRET_ACCESS_KEY', true),
}
}
container.bind<SQSClient>(TYPES.SQS).toConstantValue(new SQSClient(sqsConfig))
// Mapping
container
@@ -441,13 +434,12 @@ export class ContainerConfigLoader {
container
.bind(TYPES.DISABLE_USER_REGISTRATION)
.toConstantValue(env.get('DISABLE_USER_REGISTRATION', true) === 'true')
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN'))
container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
container.bind(TYPES.USER_SERVER_REGISTRATION_URL).toConstantValue(env.get('USER_SERVER_REGISTRATION_URL', true))
container.bind(TYPES.USER_SERVER_AUTH_KEY).toConstantValue(env.get('USER_SERVER_AUTH_KEY', true))
container.bind(TYPES.USER_SERVER_CHANGE_EMAIL_URL).toConstantValue(env.get('USER_SERVER_CHANGE_EMAIL_URL', true))
container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL'))
container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true))
container.bind(TYPES.SYNCING_SERVER_URL).toConstantValue(env.get('SYNCING_SERVER_URL'))
container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION'))
@@ -463,7 +455,11 @@ export class ContainerConfigLoader {
.toConstantValue(env.get('U2F_RELYING_PARTY_ID', true) ?? 'standardnotes.com')
container
.bind(TYPES.U2F_EXPECTED_ORIGIN)
.toConstantValue(env.get('U2F_EXPECTED_ORIGIN', true) ?? 'https://app.standardnotes.com')
.toConstantValue(
env.get('U2F_EXPECTED_ORIGIN', true)
? env.get('U2F_EXPECTED_ORIGIN', true).split(',')
: ['https://app.standardnotes.com'],
)
container
.bind(TYPES.U2F_REQUIRE_USER_VERIFICATION)
.toConstantValue(env.get('U2F_REQUIRE_USER_VERIFICATION', true) === 'true')
@@ -531,17 +527,9 @@ export class ContainerConfigLoader {
.toConstantValue(new DeterministicSelector<boolean>())
container.bind<UserSubscriptionServiceInterface>(TYPES.UserSubscriptionService).to(UserSubscriptionService)
if (env.get('SNS_TOPIC_ARN', true)) {
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
} else {
container
.bind<RedisDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(
new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)),
)
}
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
// use cases
container
@@ -799,37 +787,22 @@ export class ContainerConfigLoader {
['EMAIL_SUBSCRIPTION_UNSUBSCRIBED', container.get(TYPES.EmailSubscriptionUnsubscribedEventHandler)],
])
if (env.get('SQS_QUEUE_URL', true)) {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new RedisDomainEventSubscriberFactory(
container.get(TYPES.Redis),
container.get(TYPES.DomainEventMessageHandler),
container.get(TYPES.REDIS_EVENTS_CHANNEL),
),
)
}
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
return container
}

View File

@@ -88,7 +88,6 @@ const TYPES = {
USER_SERVER_REGISTRATION_URL: Symbol.for('USER_SERVER_REGISTRATION_URL'),
USER_SERVER_AUTH_KEY: Symbol.for('USER_SERVER_AUTH_KEY'),
USER_SERVER_CHANGE_EMAIL_URL: Symbol.for('USER_SERVER_CHANGE_EMAIL_URL'),
REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'),
NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'),
SYNCING_SERVER_URL: Symbol.for('SYNCING_SERVER_URL'),
VERSION: Symbol.for('VERSION'),

View File

@@ -17,7 +17,7 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
authenticatorRepository,
authenticatorChallengeRepository,
'standardnotes.com',
'https://app.standardnotes.com',
['localhost', 'https://app.standardnotes.com'],
true,
)

View File

@@ -11,7 +11,7 @@ export class VerifyAuthenticatorAuthenticationResponse implements UseCaseInterfa
private authenticatorRepository: AuthenticatorRepositoryInterface,
private authenticatorChallengeRepository: AuthenticatorChallengeRepositoryInterface,
private relyingPartyId: string,
private expectedOrigin: string,
private expectedOrigin: string[],
private requireUserVerification: boolean,
) {}

View File

@@ -17,7 +17,7 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
authenticatorRepository,
authenticatorChallengeRepository,
'standardnotes.com',
'https://app.standardnotes.com',
['localhost', 'https://app.standardnotes.com'],
true,
)

View File

@@ -11,7 +11,7 @@ export class VerifyAuthenticatorRegistrationResponse implements UseCaseInterface
private authenticatorRepository: AuthenticatorRepositoryInterface,
private authenticatorChallengeRepository: AuthenticatorChallengeRepositoryInterface,
private relyingPartyId: string,
private expectedOrigin: string,
private expectedOrigin: string[],
private requireUserVerification: boolean,
) {}

View File

@@ -5,7 +5,6 @@ VERSION=development
PORT=3000
REDIS_URL=redis://cache
REDIS_EVENTS_CHANNEL=events
VALET_TOKEN_SECRET=change-me-!

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.9.15](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.9.14...@standardnotes/files-server@1.9.15) (2023-02-06)
**Note:** Version bump only for package @standardnotes/files-server
## [1.9.14](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.9.13...@standardnotes/files-server@1.9.14) (2023-01-30)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files-server",
"version": "1.9.14",
"version": "1.9.15",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -14,9 +14,6 @@ import { Timer, TimerInterface } from '@standardnotes/time'
import { DomainEventFactoryInterface } from '../Domain/Event/DomainEventFactoryInterface'
import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
import {
RedisDomainEventPublisher,
RedisDomainEventSubscriberFactory,
RedisEventMessageHandler,
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
@@ -61,13 +58,12 @@ export class ContainerConfigLoader {
container.bind(TYPES.S3_BUCKET_NAME).toConstantValue(env.get('S3_BUCKET_NAME', true))
container.bind(TYPES.S3_AWS_REGION).toConstantValue(env.get('S3_AWS_REGION', true))
container.bind(TYPES.VALET_TOKEN_SECRET).toConstantValue(env.get('VALET_TOKEN_SECRET'))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN'))
container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true))
container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL'))
container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL'))
container.bind(TYPES.MAX_CHUNK_BYTES).toConstantValue(+env.get('MAX_CHUNK_BYTES'))
container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION'))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
container
.bind(TYPES.FILE_UPLOAD_PATH)
.toConstantValue(env.get('FILE_UPLOAD_PATH', true) ?? `${__dirname}/../../uploads`)
@@ -161,17 +157,9 @@ export class ContainerConfigLoader {
// repositories
container.bind<UploadRepositoryInterface>(TYPES.UploadRepository).to(RedisUploadRepository)
if (env.get('SNS_TOPIC_ARN', true)) {
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
} else {
container
.bind<RedisDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(
new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)),
)
}
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
// Handlers
container
@@ -189,37 +177,22 @@ export class ContainerConfigLoader {
],
])
if (env.get('SQS_QUEUE_URL', true)) {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new RedisDomainEventSubscriberFactory(
container.get(TYPES.Redis),
container.get(TYPES.DomainEventMessageHandler),
container.get(TYPES.REDIS_EVENTS_CHANNEL),
),
)
}
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
return container
}

View File

@@ -40,7 +40,6 @@ const TYPES = {
SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'),
VALET_TOKEN_SECRET: Symbol.for('VALET_TOKEN_SECRET'),
REDIS_URL: Symbol.for('REDIS_URL'),
REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'),
MAX_CHUNK_BYTES: Symbol.for('MAX_CHUNK_BYTES'),
VERSION: Symbol.for('VERSION'),
NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'),

View File

@@ -22,8 +22,6 @@ SQS_AWS_REGION=
S3_AWS_REGION=
S3_BACKUP_BUCKET_NAME=
REDIS_EVENTS_CHANNEL=revisions
# (Optional) New Relic Setup
NEW_RELIC_ENABLED=false
NEW_RELIC_APP_NAME="Revisions Server"

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.10.28](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.10.27...@standardnotes/revisions-server@1.10.28) (2023-02-06)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.10.27](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.10.26...@standardnotes/revisions-server@1.10.27) (2023-01-30)
### Bug Fixes

View File

@@ -4,8 +4,10 @@ export class init1669113322388 implements MigrationInterface {
name = 'init1669113322388'
public async up(queryRunner: QueryRunner): Promise<void> {
await this.syncSchemaBetweenLegacyRevisions(queryRunner)
await queryRunner.query(
'CREATE TABLE `revisions` (`uuid` varchar(36) NOT NULL, `item_uuid` varchar(36) NOT NULL, `user_uuid` varchar(36) NOT NULL, `content` mediumtext NULL, `content_type` varchar(255) NULL, `items_key_id` varchar(255) NULL, `enc_item_key` text NULL, `auth_hash` varchar(255) NULL, `creation_date` date NULL, `created_at` datetime(6) NULL, `updated_at` datetime(6) NULL, INDEX `item_uuid` (`item_uuid`), INDEX `user_uuid` (`user_uuid`), INDEX `creation_date` (`creation_date`), INDEX `created_at` (`created_at`), PRIMARY KEY (`uuid`)) ENGINE=InnoDB',
'CREATE TABLE IF NOT EXISTS `revisions` (`uuid` varchar(36) NOT NULL, `item_uuid` varchar(36) NOT NULL, `user_uuid` varchar(36) NOT NULL, `content` mediumtext NULL, `content_type` varchar(255) NULL, `items_key_id` varchar(255) NULL, `enc_item_key` text NULL, `auth_hash` varchar(255) NULL, `creation_date` date NULL, `created_at` datetime(6) NULL, `updated_at` datetime(6) NULL, INDEX `item_uuid` (`item_uuid`), INDEX `user_uuid` (`user_uuid`), INDEX `creation_date` (`creation_date`), INDEX `created_at` (`created_at`), PRIMARY KEY (`uuid`)) ENGINE=InnoDB',
)
}
@@ -16,4 +18,16 @@ export class init1669113322388 implements MigrationInterface {
await queryRunner.query('DROP INDEX `item_uuid` ON `revisions`')
await queryRunner.query('DROP TABLE `revisions`')
}
private async syncSchemaBetweenLegacyRevisions(queryRunner: QueryRunner): Promise<void> {
const revisionsTableExistsQueryResult = await queryRunner.manager.query(
'SELECT COUNT(*) as count FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = "revisions"',
)
const revisionsTableExists = revisionsTableExistsQueryResult[0].count === 1
if (!revisionsTableExists) {
return
}
await queryRunner.query('ALTER TABLE `revisions` ADD COLUMN `user_uuid` varchar(36) NULL')
}
}

View File

@@ -4,8 +4,21 @@ export class removeDateIndexes1669636497932 implements MigrationInterface {
name = 'removeDateIndexes1669636497932'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('DROP INDEX `created_at` ON `revisions`')
await queryRunner.query('DROP INDEX `creation_date` ON `revisions`')
const indexRevisionsOnCreatedAt = await queryRunner.manager.query(
'SHOW INDEX FROM `revisions` where `key_name` = "created_at"',
)
const indexRevisionsOnCreatedAtExist = indexRevisionsOnCreatedAt && indexRevisionsOnCreatedAt.length > 0
if (indexRevisionsOnCreatedAtExist) {
await queryRunner.query('DROP INDEX `created_at` ON `revisions`')
}
const indexRevisionsOnCreationDate = await queryRunner.manager.query(
'SHOW INDEX FROM `revisions` where `key_name` = "creation_date"',
)
const indexRevisionsOnCreationDateAtExist = indexRevisionsOnCreationDate && indexRevisionsOnCreationDate.length > 0
if (indexRevisionsOnCreationDateAtExist) {
await queryRunner.query('DROP INDEX `creation_date` ON `revisions`')
}
}
public async down(queryRunner: QueryRunner): Promise<void> {

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.10.27",
"version": "1.10.28",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -12,8 +12,6 @@ import {
} from '@standardnotes/domain-events'
import { TokenDecoderInterface, CrossServiceTokenData, TokenDecoder } from '@standardnotes/security'
import {
RedisDomainEventSubscriberFactory,
RedisEventMessageHandler,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
SQSNewRelicEventMessageHandler,
@@ -164,8 +162,7 @@ export class ContainerConfigLoader {
// env vars
container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL'))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true))
container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL'))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
container.bind(TYPES.AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET'))
container.bind(TYPES.S3_AWS_REGION).toConstantValue(env.get('S3_AWS_REGION', true))
container.bind(TYPES.S3_BACKUP_BUCKET_NAME).toConstantValue(env.get('S3_BACKUP_BUCKET_NAME', true))
@@ -264,37 +261,22 @@ export class ContainerConfigLoader {
['REVISIONS_OWNERSHIP_UPDATE_REQUESTED', container.get(TYPES.RevisionsOwnershipUpdateRequestedEventHandler)],
])
if (env.get('SQS_QUEUE_URL', true)) {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new RedisDomainEventSubscriberFactory(
container.get(TYPES.Redis),
container.get(TYPES.DomainEventMessageHandler),
container.get(TYPES.REDIS_EVENTS_CHANNEL),
),
)
}
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
return container
}

View File

@@ -19,7 +19,6 @@ const TYPES = {
REDIS_URL: Symbol.for('REDIS_URL'),
SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'),
SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'),
REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'),
AUTH_JWT_SECRET: Symbol.for('AUTH_JWT_SECRET'),
S3_AWS_REGION: Symbol.for('S3_AWS_REGION'),
S3_BACKUP_BUCKET_NAME: Symbol.for('S3_BACKUP_BUCKET_NAME'),

View File

@@ -11,7 +11,6 @@ DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "l
DB_MIGRATIONS_PATH=dist/migrations/*.js
REDIS_URL=redis://cache
REDIS_EVENTS_CHANNEL=events
SNS_TOPIC_ARN=
SNS_AWS_REGION=

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.19](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.16.18...@standardnotes/scheduler-server@1.16.19) (2023-02-06)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.16.18](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.16.17...@standardnotes/scheduler-server@1.16.18) (2023-01-30)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/scheduler-server",
"version": "1.16.18",
"version": "1.16.19",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -14,9 +14,6 @@ import TYPES from './Types'
import { AppDataSource } from './DataSource'
import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
import {
RedisDomainEventPublisher,
RedisDomainEventSubscriberFactory,
RedisEventMessageHandler,
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
@@ -110,10 +107,9 @@ export class ContainerConfigLoader {
// env vars
container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL'))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN'))
container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true))
container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL'))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true))
// Repositories
@@ -145,17 +141,9 @@ export class ContainerConfigLoader {
container.bind<TimerInterface>(TYPES.Timer).toConstantValue(new Timer())
container.bind<JobDoneInterpreterInterface>(TYPES.JobDoneInterpreter).to(JobDoneInterpreter)
if (env.get('SNS_TOPIC_ARN', true)) {
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
} else {
container
.bind<RedisDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(
new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)),
)
}
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
['PREDICATE_VERIFIED', container.get(TYPES.PredicateVerifiedEventHandler)],
@@ -164,37 +152,22 @@ export class ContainerConfigLoader {
['EXIT_DISCOUNT_APPLIED', container.get(TYPES.ExitDiscountAppliedEventHandler)],
])
if (env.get('SQS_QUEUE_URL', true)) {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new RedisDomainEventSubscriberFactory(
container.get(TYPES.Redis),
container.get(TYPES.DomainEventMessageHandler),
container.get(TYPES.REDIS_EVENTS_CHANNEL),
),
)
}
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
return container
}

View File

@@ -9,7 +9,6 @@ const TYPES = {
SNS_AWS_REGION: Symbol.for('SNS_AWS_REGION'),
SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'),
SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'),
REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'),
NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'),
// Repositories
PredicateRepository: Symbol.for('PredicateRepository'),

View File

@@ -24,8 +24,6 @@ SQS_AWS_REGION=
S3_AWS_REGION=
S3_BACKUP_BUCKET_NAME=
REDIS_EVENTS_CHANNEL=events
INTERNAL_DNS_REROUTE_ENABLED=false
EXTENSIONS_SERVER_URL=http://extensions-server:3004
AUTH_SERVER_URL=http://auth:3000

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.29.14](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.29.13...@standardnotes/syncing-server@1.29.14) (2023-02-06)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.29.13](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.29.12...@standardnotes/syncing-server@1.29.13) (2023-01-30)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.29.13",
"version": "1.29.14",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -54,9 +54,6 @@ import { UuidFilter } from '../Domain/Item/SaveRule/UuidFilter'
import { ContentTypeFilter } from '../Domain/Item/SaveRule/ContentTypeFilter'
import { ContentFilter } from '../Domain/Item/SaveRule/ContentFilter'
import {
RedisDomainEventPublisher,
RedisDomainEventSubscriberFactory,
RedisEventMessageHandler,
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
@@ -192,10 +189,9 @@ export class ContainerConfigLoader {
// env vars
container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL'))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN'))
container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true))
container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL'))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
container.bind(TYPES.AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET'))
container
.bind(TYPES.INTERNAL_DNS_REROUTE_ENABLED)
@@ -277,17 +273,9 @@ export class ContainerConfigLoader {
}
container.bind<RevisionServiceInterface>(TYPES.RevisionService).to(RevisionService)
if (env.get('SNS_TOPIC_ARN', true)) {
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
} else {
container
.bind<RedisDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(
new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)),
)
}
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
['DUPLICATE_ITEM_SYNCED', container.get(TYPES.DuplicateItemSyncedEventHandler)],
@@ -301,37 +289,22 @@ export class ContainerConfigLoader {
['ITEM_REVISION_CREATION_REQUESTED', container.get(TYPES.ItemRevisionCreationRequestedEventHandler)],
])
if (env.get('SQS_QUEUE_URL', true)) {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new RedisDomainEventSubscriberFactory(
container.get(TYPES.Redis),
container.get(TYPES.DomainEventMessageHandler),
container.get(TYPES.REDIS_EVENTS_CHANNEL),
),
)
}
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
container.bind<ItemFactoryInterface>(TYPES.ItemFactory).to(ItemFactory)

View File

@@ -24,7 +24,6 @@ const TYPES = {
SNS_AWS_REGION: Symbol.for('SNS_AWS_REGION'),
SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'),
SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'),
REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'),
AUTH_JWT_SECRET: Symbol.for('AUTH_JWT_SECRET'),
INTERNAL_DNS_REROUTE_ENABLED: Symbol.for('INTERNAL_DNS_REROUTE_ENABLED'),
EXTENSIONS_SERVER_URL: Symbol.for('EXTENSIONS_SERVER_URL'),

View File

@@ -13,8 +13,6 @@ SNS_AWS_REGION=
SQS_QUEUE_URL=
SQS_AWS_REGION=
REDIS_EVENTS_CHANNEL=events
WEB_SOCKET_CONNECTION_TOKEN_SECRET=
WEB_SOCKET_CONNECTION_TOKEN_TTL=

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.5.20](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.5.19...@standardnotes/websockets-server@1.5.20) (2023-02-06)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.5.19](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.5.18...@standardnotes/websockets-server@1.5.19) (2023-01-30)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/websockets-server",
"version": "1.5.19",
"version": "1.5.20",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -18,8 +18,6 @@ import { AddWebSocketsConnection } from '../Domain/UseCase/AddWebSocketsConnecti
import { RemoveWebSocketsConnection } from '../Domain/UseCase/RemoveWebSocketsConnection/RemoveWebSocketsConnection'
import { WebSocketsClientMessenger } from '../Infra/WebSockets/WebSocketsClientMessenger'
import {
RedisDomainEventSubscriberFactory,
RedisEventMessageHandler,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
SQSNewRelicEventMessageHandler,
@@ -110,8 +108,7 @@ export class ContainerConfigLoader {
.bind(TYPES.WEB_SOCKET_CONNECTION_TOKEN_TTL)
.toConstantValue(+env.get('WEB_SOCKET_CONNECTION_TOKEN_TTL', true))
container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL'))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true))
container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL'))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true))
container.bind(TYPES.WEBSOCKETS_API_URL).toConstantValue(env.get('WEBSOCKETS_API_URL', true))
container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION'))
@@ -144,37 +141,22 @@ export class ContainerConfigLoader {
['WEB_SOCKET_MESSAGE_REQUESTED', container.get(TYPES.WebSocketMessageRequestedEventHandler)],
])
if (env.get('SQS_QUEUE_URL', true)) {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new RedisDomainEventSubscriberFactory(
container.get(TYPES.Redis),
container.get(TYPES.DomainEventMessageHandler),
container.get(TYPES.REDIS_EVENTS_CHANNEL),
),
)
}
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
return container
}

View File

@@ -15,7 +15,6 @@ const TYPES = {
REDIS_URL: Symbol.for('REDIS_URL'),
SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'),
SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'),
REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'),
NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'),
WEBSOCKETS_API_URL: Symbol.for('WEBSOCKETS_API_URL'),
VERSION: Symbol.for('VERSION'),

View File

@@ -22,8 +22,6 @@ SNS_AWS_REGION=
SQS_QUEUE_URL=
SQS_AWS_REGION=
REDIS_EVENTS_CHANNEL=events
# (Optional) New Relic Setup
NEW_RELIC_ENABLED=false
NEW_RELIC_APP_NAME=Workspace

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.19.23](https://github.com/standardnotes/server/compare/@standardnotes/workspace-server@1.19.22...@standardnotes/workspace-server@1.19.23) (2023-02-06)
**Note:** Version bump only for package @standardnotes/workspace-server
## [1.19.22](https://github.com/standardnotes/server/compare/@standardnotes/workspace-server@1.19.21...@standardnotes/workspace-server@1.19.22) (2023-01-30)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/workspace-server",
"version": "1.19.22",
"version": "1.19.23",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -13,9 +13,6 @@ import { Env } from './Env'
import TYPES from './Types'
import { AppDataSource } from './DataSource'
import {
RedisDomainEventPublisher,
RedisDomainEventSubscriberFactory,
RedisEventMessageHandler,
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
@@ -141,10 +138,9 @@ export class ContainerConfigLoader {
// env vars
container.bind(TYPES.AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET'))
container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL'))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true))
container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN'))
container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true))
container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL'))
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true))
container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION'))
@@ -169,53 +165,30 @@ export class ContainerConfigLoader {
.bind<TokenDecoderInterface<CrossServiceTokenData>>(TYPES.CrossServiceTokenDecoder)
.toConstantValue(new TokenDecoder<CrossServiceTokenData>(container.get(TYPES.AUTH_JWT_SECRET)))
if (env.get('SNS_TOPIC_ARN', true)) {
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
} else {
container
.bind<RedisDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(
new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)),
)
}
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
['USER_REGISTERED', container.get(TYPES.UserRegisteredEventHandler)],
])
if (env.get('SQS_QUEUE_URL', true)) {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new RedisDomainEventSubscriberFactory(
container.get(TYPES.Redis),
container.get(TYPES.DomainEventMessageHandler),
container.get(TYPES.REDIS_EVENTS_CHANNEL),
),
)
}
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger))
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
),
)
return container
}

View File

@@ -22,7 +22,6 @@ const TYPES = {
SNS_AWS_REGION: Symbol.for('SNS_AWS_REGION'),
SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'),
SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'),
REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'),
NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'),
VERSION: Symbol.for('VERSION'),
// use cases