mirror of
https://github.com/standardnotes/server
synced 2026-01-19 02:06:04 -05:00
Compare commits
75 Commits
@standardn
...
@standardn
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09d7f608cd | ||
|
|
d023a27377 | ||
|
|
190595febf | ||
|
|
b25edec26c | ||
|
|
85d0c12dad | ||
|
|
25c98ef078 | ||
|
|
af51baea9a | ||
|
|
e97b16606c | ||
|
|
5ff9e43899 | ||
|
|
d3a49e109c | ||
|
|
e3dbff6996 | ||
|
|
d9f5410afd | ||
|
|
0568c8f563 | ||
|
|
16043a7d68 | ||
|
|
f24ee61d11 | ||
|
|
881a6967ac | ||
|
|
a93f66c6ac | ||
|
|
fdf4b29ae2 | ||
|
|
d5f6ca0d2e | ||
|
|
12d9ccf28c | ||
|
|
ffc270cc6f | ||
|
|
61e2e58297 | ||
|
|
b68ede1f63 | ||
|
|
d333c1393c | ||
|
|
35d6f2f961 | ||
|
|
3d619a0c61 | ||
|
|
bda812f170 | ||
|
|
826719bb67 | ||
|
|
631101eae5 | ||
|
|
fa0b9bf935 | ||
|
|
708af5e83c | ||
|
|
993d31167b | ||
|
|
ac5fc7d28a | ||
|
|
73f3fad13d | ||
|
|
85e0e2165f | ||
|
|
89ee103303 | ||
|
|
6b313947c3 | ||
|
|
fba8e6ce35 | ||
|
|
622c024547 | ||
|
|
2c51d92bab | ||
|
|
11ef2ef708 | ||
|
|
df793e07fd | ||
|
|
bae6eea3aa | ||
|
|
be17b67cc1 | ||
|
|
645a24d29b | ||
|
|
64962ce632 | ||
|
|
5120883691 | ||
|
|
0b4570ebee | ||
|
|
5bbdc7e426 | ||
|
|
a1d60630a0 | ||
|
|
e96fd6d69e | ||
|
|
1423b3fc35 | ||
|
|
fd10b4d585 | ||
|
|
8a79437668 | ||
|
|
85a87dc40a | ||
|
|
95aa0a0024 | ||
|
|
d0c44d1376 | ||
|
|
b0e31ff305 | ||
|
|
f11569ac53 | ||
|
|
fbf7a61bc9 | ||
|
|
2265165fa3 | ||
|
|
b216b17ef5 | ||
|
|
b2c7b924ac | ||
|
|
1349f950c9 | ||
|
|
f1c398a3a4 | ||
|
|
369231ff11 | ||
|
|
271dee5be6 | ||
|
|
a0c8f40e7b | ||
|
|
4db0aef0ff | ||
|
|
5ed9bd243f | ||
|
|
2c53306f5a | ||
|
|
a3624357dc | ||
|
|
afe0be31f2 | ||
|
|
71854b704d | ||
|
|
0907773d6f |
12
.env.sample
12
.env.sample
@@ -1,14 +1,3 @@
|
||||
###########
|
||||
# General #
|
||||
###########
|
||||
EXPOSED_PORT=3000
|
||||
|
||||
#########
|
||||
# FILES #
|
||||
#########
|
||||
EXPOSED_FILES_SERVER_PORT=3042
|
||||
PUBLIC_FILES_SERVER_URL=http://localhost:3042
|
||||
|
||||
######
|
||||
# DB #
|
||||
######
|
||||
@@ -19,7 +8,6 @@ DB_USERNAME=std_notes_user
|
||||
DB_PASSWORD=changeme123
|
||||
DB_DATABASE=standard_notes_db
|
||||
DB_DEBUG_LEVEL=all
|
||||
DB_MIGRATIONS_PATH=dist/migrations/*.js
|
||||
|
||||
#########
|
||||
# CACHE #
|
||||
|
||||
21
.github/ci.env
vendored
Normal file
21
.github/ci.env
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
PUBLIC_FILES_SERVER_URL=http://localhost:3125
|
||||
DB_HOST=db
|
||||
DB_USERNAME=std_notes_user
|
||||
DB_PASSWORD=changeme123
|
||||
DB_DATABASE=standard_notes_db
|
||||
REDIS_PORT=6379
|
||||
REDIS_HOST=cache
|
||||
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
|
||||
|
||||
MYSQL_DATABASE=standard_notes_db
|
||||
MYSQL_USER=std_notes_user
|
||||
MYSQL_PASSWORD=changeme123
|
||||
MYSQL_ROOT_PASSWORD=changeme123
|
||||
8
.github/workflows/analytics.yml
vendored
8
.github/workflows/analytics.yml
vendored
@@ -11,9 +11,9 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
call_server_utility_workflow:
|
||||
name: Server Utility
|
||||
uses: standardnotes/server/.github/workflows/common-server-utility.yml@main
|
||||
call_server_application_workflow:
|
||||
name: Server Application
|
||||
uses: standardnotes/server/.github/workflows/common-server-application.yml@main
|
||||
with:
|
||||
service_name: analytics
|
||||
workspace_name: "@standardnotes/analytics"
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
secrets: inherit
|
||||
|
||||
newrelic:
|
||||
needs: call_server_utility_workflow
|
||||
needs: call_server_application_workflow
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
||||
1
.github/workflows/api-gateway.yml
vendored
1
.github/workflows/api-gateway.yml
vendored
@@ -17,7 +17,6 @@ jobs:
|
||||
with:
|
||||
service_name: api-gateway
|
||||
workspace_name: "@standardnotes/api-gateway"
|
||||
e2e_tag_parameter_name: api_gateway_image_tag
|
||||
deploy_worker: false
|
||||
package_path: packages/api-gateway
|
||||
secrets: inherit
|
||||
|
||||
1
.github/workflows/auth.yml
vendored
1
.github/workflows/auth.yml
vendored
@@ -17,7 +17,6 @@ jobs:
|
||||
with:
|
||||
service_name: auth
|
||||
workspace_name: "@standardnotes/auth-server"
|
||||
e2e_tag_parameter_name: auth_image_tag
|
||||
package_path: packages/auth
|
||||
secrets: inherit
|
||||
|
||||
|
||||
15
.github/workflows/common-docker-image.yml
vendored
15
.github/workflows/common-docker-image.yml
vendored
@@ -6,9 +6,6 @@ on:
|
||||
service_name:
|
||||
required: true
|
||||
type: string
|
||||
bundle_dir:
|
||||
required: true
|
||||
type: string
|
||||
package_path:
|
||||
required: true
|
||||
type: string
|
||||
@@ -32,13 +29,17 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Bundle Dir
|
||||
id: bundle-dir
|
||||
run: echo "temp_dir=$(mktemp -d -t ${{ inputs.service_name }}-${{ github.sha }}-XXXXXXX)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
${{ inputs.bundle_dir }}
|
||||
${{ steps.bundle-dir.outputs.temp_dir }}
|
||||
key: ${{ runner.os }}-${{ inputs.service_name }}-build-${{ github.sha }}
|
||||
|
||||
- name: Set up Node
|
||||
@@ -53,7 +54,7 @@ jobs:
|
||||
|
||||
- name: Bundle
|
||||
if: steps.cache-build.outputs.cache-hit != 'true'
|
||||
run: yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory ${{ inputs.bundle_dir }}
|
||||
run: yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory ${{ steps.bundle-dir.outputs.temp_dir }}
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
@@ -85,8 +86,8 @@ jobs:
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: ${{ inputs.bundle_dir }}
|
||||
file: ${{ inputs.bundle_dir }}/${{ inputs.package_path }}/Dockerfile
|
||||
context: ${{ steps.bundle-dir.outputs.temp_dir }}
|
||||
file: ${{ steps.bundle-dir.outputs.temp_dir }}/${{ inputs.package_path }}/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
|
||||
57
.github/workflows/common-e2e.yml
vendored
57
.github/workflows/common-e2e.yml
vendored
@@ -2,6 +2,11 @@ name: Reusable Run E2E Test Suite Workflow
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
snjs_image_tag:
|
||||
type: string
|
||||
default: latest
|
||||
description: The Docker image tag used for SNJS container
|
||||
secrets:
|
||||
DOCKER_USERNAME:
|
||||
required: true
|
||||
@@ -18,22 +23,9 @@ jobs:
|
||||
|
||||
services:
|
||||
snjs:
|
||||
image: standardnotes/snjs
|
||||
image: standardnotes/snjs:${{ inputs.snjs_image_tag }}
|
||||
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:
|
||||
@@ -61,41 +53,14 @@ jobs:
|
||||
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
|
||||
run: docker compose -f docker-compose.ci.yml up -d
|
||||
|
||||
- name: Wait for server to start
|
||||
run: docker/wait-for.sh localhost 3123
|
||||
run: docker/is-available.sh http://localhost:3123 $(pwd)/logs
|
||||
|
||||
- name: Connect external containers to self-hosted network
|
||||
run: docker network connect --alias mock-event-publisher standardnotes_self_hosted mock-event-publisher
|
||||
|
||||
- name: Run E2E Test Suite
|
||||
run: yarn dlx mocha-headless-chrome --timeout 1200000 -f http://localhost:9001/mocha/test.html
|
||||
|
||||
7
.github/workflows/common-self-hosting.yml
vendored
7
.github/workflows/common-self-hosting.yml
vendored
@@ -13,16 +13,9 @@ on:
|
||||
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
|
||||
|
||||
|
||||
169
.github/workflows/common-server-application.yml
vendored
169
.github/workflows/common-server-application.yml
vendored
@@ -17,9 +17,6 @@ on:
|
||||
required: false
|
||||
default: true
|
||||
type: boolean
|
||||
e2e_tag_parameter_name:
|
||||
required: false
|
||||
type: string
|
||||
package_path:
|
||||
required: true
|
||||
type: string
|
||||
@@ -36,177 +33,11 @@ on:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
temp_dir: ${{ steps.bundle-dir.outputs.temp_dir }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Bundle Dir
|
||||
id: bundle-dir
|
||||
run: echo "temp_dir=$(mktemp -d -t ${{ inputs.service_name }}-${{ github.sha }}-XXXXXXX)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
${{ steps.bundle-dir.outputs.temp_dir }}
|
||||
key: ${{ runner.os }}-${{ inputs.service_name }}-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
|
||||
run: yarn build ${{ inputs.package_path }}
|
||||
|
||||
- name: Bundle
|
||||
run: yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory ${{ steps.bundle-dir.outputs.temp_dir }}
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
${{ needs.build.outputs.temp_dir }}
|
||||
key: ${{ runner.os }}-${{ inputs.service_name }}-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 ${{ inputs.package_path }}
|
||||
|
||||
- name: Lint
|
||||
run: yarn lint:${{ inputs.service_name }}
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
${{ needs.build.outputs.temp_dir }}
|
||||
key: ${{ runner.os }}-${{ inputs.service_name }}-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 ${{ inputs.package_path }}
|
||||
|
||||
- name: Test
|
||||
run: yarn test ${{ inputs.package_path }}
|
||||
|
||||
e2e:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
${{ needs.build.outputs.temp_dir }}
|
||||
key: ${{ runner.os }}-${{ inputs.service_name }}-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 ${{ inputs.package_path }}
|
||||
|
||||
- name: Bundle
|
||||
if: steps.cache-build.outputs.cache-hit != 'true'
|
||||
run: yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory ${{ needs.build.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: ${{ needs.build.outputs.temp_dir }}
|
||||
file: ${{ needs.build.outputs.temp_dir }}/${{ inputs.package_path }}/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: standardnotes/${{ inputs.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: '{"${{ inputs.e2e_tag_parameter_name }}": "${{ github.sha }}"}'
|
||||
propagate_failure: true
|
||||
trigger_workflow: true
|
||||
wait_workflow: true
|
||||
|
||||
publish:
|
||||
needs: [ build, test, lint, e2e ]
|
||||
|
||||
name: Publish Docker Image
|
||||
uses: standardnotes/server/.github/workflows/common-docker-image.yml@main
|
||||
with:
|
||||
service_name: ${{ inputs.service_name }}
|
||||
bundle_dir: ${{ needs.build.outputs.temp_dir }}
|
||||
package_path: ${{ inputs.package_path }}
|
||||
workspace_name: ${{ inputs.workspace_name }}
|
||||
secrets: inherit
|
||||
|
||||
164
.github/workflows/common-server-utility.yml
vendored
164
.github/workflows/common-server-utility.yml
vendored
@@ -1,164 +0,0 @@
|
||||
name: Reusable Server Utility Workflow
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
service_name:
|
||||
required: true
|
||||
type: string
|
||||
workspace_name:
|
||||
required: true
|
||||
type: string
|
||||
deploy_web:
|
||||
required: false
|
||||
default: true
|
||||
type: boolean
|
||||
deploy_worker:
|
||||
required: false
|
||||
default: true
|
||||
type: boolean
|
||||
package_path:
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
DOCKER_USERNAME:
|
||||
required: true
|
||||
DOCKER_PASSWORD:
|
||||
required: true
|
||||
CI_PAT_TOKEN:
|
||||
required: true
|
||||
AWS_ACCESS_KEY_ID:
|
||||
required: true
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
temp_dir: ${{ steps.bundle-dir.outputs.temp_dir }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Bundle Dir
|
||||
id: bundle-dir
|
||||
run: echo "temp_dir=$(mktemp -d -t ${{ inputs.service_name }}-${{ github.sha }}-XXXXXXX)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
${{ steps.bundle-dir.outputs.temp_dir }}
|
||||
key: ${{ runner.os }}-${{ inputs.service_name }}-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
|
||||
run: yarn build ${{ inputs.package_path }}
|
||||
|
||||
- name: Bundle
|
||||
run: yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory ${{ steps.bundle-dir.outputs.temp_dir }}
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
${{ needs.build.outputs.temp_dir }}
|
||||
key: ${{ runner.os }}-${{ inputs.service_name }}-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 ${{ inputs.package_path }}
|
||||
|
||||
- name: Lint
|
||||
run: yarn lint:${{ inputs.service_name }}
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
${{ needs.build.outputs.temp_dir }}
|
||||
key: ${{ runner.os }}-${{ inputs.service_name }}-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 ${{ inputs.package_path }}
|
||||
|
||||
- name: Test
|
||||
run: yarn test ${{ inputs.package_path }}
|
||||
|
||||
publish:
|
||||
needs: [ build, test, lint ]
|
||||
|
||||
name: Publish Docker Image
|
||||
uses: standardnotes/server/.github/workflows/common-docker-image.yml@main
|
||||
with:
|
||||
service_name: ${{ inputs.service_name }}
|
||||
bundle_dir: ${{ needs.build.outputs.temp_dir }}
|
||||
package_path: ${{ inputs.package_path }}
|
||||
workspace_name: ${{ inputs.workspace_name }}
|
||||
secrets: inherit
|
||||
|
||||
deploy-web:
|
||||
if: ${{ inputs.deploy_web }}
|
||||
|
||||
needs: publish
|
||||
|
||||
name: Deploy Web
|
||||
uses: standardnotes/server/.github/workflows/common-deploy.yml@main
|
||||
with:
|
||||
service_name: ${{ inputs.service_name }}
|
||||
docker_image: ${{ inputs.service_name }}:${{ github.sha }}
|
||||
secrets: inherit
|
||||
|
||||
deploy-worker:
|
||||
if: ${{ inputs.deploy_worker }}
|
||||
|
||||
needs: publish
|
||||
|
||||
name: Deploy Worker
|
||||
uses: standardnotes/server/.github/workflows/common-deploy.yml@main
|
||||
with:
|
||||
service_name: ${{ inputs.service_name }}-worker
|
||||
docker_image: ${{ inputs.service_name }}:${{ github.sha }}
|
||||
secrets: inherit
|
||||
17
.github/workflows/e2e-test-suite.yml
vendored
Normal file
17
.github/workflows/e2e-test-suite.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
name: E2E Test Suite On Self Hosted Server
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
snjs_image_tag:
|
||||
type: string
|
||||
default: latest
|
||||
description: The Docker image tag used for SNJS container
|
||||
|
||||
jobs:
|
||||
e2e:
|
||||
name: E2E
|
||||
uses: standardnotes/server/.github/workflows/common-e2e.yml@main
|
||||
with:
|
||||
snjs_image_tag: ${{ inputs.snjs_image_tag }}
|
||||
secrets: inherit
|
||||
8
.github/workflows/event-store.yml
vendored
8
.github/workflows/event-store.yml
vendored
@@ -11,9 +11,9 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
call_server_utility_workflow:
|
||||
name: Server Utility
|
||||
uses: standardnotes/server/.github/workflows/common-server-utility.yml@main
|
||||
call_server_application_workflow:
|
||||
name: Server Application
|
||||
uses: standardnotes/server/.github/workflows/common-server-application.yml@main
|
||||
with:
|
||||
service_name: event-store
|
||||
workspace_name: "@standardnotes/event-store"
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
secrets: inherit
|
||||
|
||||
newrelic:
|
||||
needs: call_server_utility_workflow
|
||||
needs: call_server_application_workflow
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
||||
1
.github/workflows/files.yml
vendored
1
.github/workflows/files.yml
vendored
@@ -17,7 +17,6 @@ jobs:
|
||||
with:
|
||||
service_name: files
|
||||
workspace_name: "@standardnotes/files-server"
|
||||
e2e_tag_parameter_name: files_image_tag
|
||||
package_path: packages/files
|
||||
secrets: inherit
|
||||
|
||||
|
||||
78
.github/workflows/pr.yml
vendored
78
.github/workflows/pr.yml
vendored
@@ -94,3 +94,81 @@ jobs:
|
||||
name: E2E
|
||||
uses: standardnotes/server/.github/workflows/common-e2e.yml@main
|
||||
secrets: inherit
|
||||
|
||||
legacy_e2e:
|
||||
needs: build
|
||||
name: Legacy 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
|
||||
|
||||
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.legacy_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
|
||||
|
||||
110
.github/workflows/publish.yml
vendored
110
.github/workflows/publish.yml
vendored
@@ -5,9 +5,106 @@ on:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
release_and_publish:
|
||||
build:
|
||||
if: contains(github.event.head_commit.message, 'chore(release)') == false
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
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
|
||||
run: yarn build
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
${{ needs.build.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: Lint
|
||||
run: yarn lint
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
packages/**/dist
|
||||
${{ needs.build.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: Test
|
||||
run: yarn test
|
||||
|
||||
e2e:
|
||||
needs: build
|
||||
name: E2E
|
||||
uses: standardnotes/server/.github/workflows/common-e2e.yml@main
|
||||
secrets: inherit
|
||||
|
||||
publish-self-hosting:
|
||||
needs: [ test, lint, e2e ]
|
||||
name: Publish Self Hosting Docker Image
|
||||
uses: standardnotes/server/.github/workflows/common-self-hosting.yml@main
|
||||
secrets: inherit
|
||||
|
||||
publish-services:
|
||||
needs: [ test, lint, e2e ]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
@@ -34,7 +131,8 @@ jobs:
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
node-version-file: '.nvmrc'
|
||||
|
||||
- name: Build packages
|
||||
- name: Build
|
||||
if: steps.cache-build.outputs.cache-hit != 'true'
|
||||
run: yarn build
|
||||
|
||||
- name: Bump version
|
||||
@@ -44,11 +142,3 @@ jobs:
|
||||
run: yarn publish
|
||||
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
|
||||
|
||||
|
||||
1
.github/workflows/revisions.yml
vendored
1
.github/workflows/revisions.yml
vendored
@@ -17,7 +17,6 @@ jobs:
|
||||
with:
|
||||
service_name: revisions
|
||||
workspace_name: "@standardnotes/revisions-server"
|
||||
e2e_tag_parameter_name: revisions_image_tag
|
||||
package_path: packages/revisions
|
||||
secrets: inherit
|
||||
|
||||
|
||||
8
.github/workflows/scheduler.yml
vendored
8
.github/workflows/scheduler.yml
vendored
@@ -11,9 +11,9 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
call_server_utility_workflow:
|
||||
name: Server Utility
|
||||
uses: standardnotes/server/.github/workflows/common-server-utility.yml@main
|
||||
call_server_application_workflow:
|
||||
name: Server Application
|
||||
uses: standardnotes/server/.github/workflows/common-server-application.yml@main
|
||||
with:
|
||||
service_name: scheduler
|
||||
workspace_name: "@standardnotes/scheduler-server"
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
secrets: inherit
|
||||
|
||||
newrelic:
|
||||
needs: call_server_utility_workflow
|
||||
needs: call_server_application_workflow
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
||||
1
.github/workflows/syncing-server.yml
vendored
1
.github/workflows/syncing-server.yml
vendored
@@ -17,7 +17,6 @@ jobs:
|
||||
with:
|
||||
service_name: syncing-server-js
|
||||
workspace_name: "@standardnotes/syncing-server"
|
||||
e2e_tag_parameter_name: syncing_server_js_image_tag
|
||||
package_path: packages/syncing-server
|
||||
secrets: inherit
|
||||
|
||||
|
||||
8
.github/workflows/websockets.yml
vendored
8
.github/workflows/websockets.yml
vendored
@@ -11,9 +11,9 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
call_server_utility_workflow:
|
||||
name: Server Utility
|
||||
uses: standardnotes/server/.github/workflows/common-server-utility.yml@main
|
||||
call_server_application_workflow:
|
||||
name: Server Application
|
||||
uses: standardnotes/server/.github/workflows/common-server-application.yml@main
|
||||
with:
|
||||
service_name: websockets
|
||||
workspace_name: "@standardnotes/websockets-server"
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
secrets: inherit
|
||||
|
||||
newrelic:
|
||||
needs: call_server_utility_workflow
|
||||
needs: call_server_application_workflow
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
8
.github/workflows/workspace.yml
vendored
8
.github/workflows/workspace.yml
vendored
@@ -11,9 +11,9 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
call_server_utility_workflow:
|
||||
name: Server Utility
|
||||
uses: standardnotes/server/.github/workflows/common-server-utility.yml@main
|
||||
call_server_application_workflow:
|
||||
name: Server Application
|
||||
uses: standardnotes/server/.github/workflows/common-server-application.yml@main
|
||||
with:
|
||||
service_name: workspace
|
||||
workspace_name: "@standardnotes/workspace-server"
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
secrets: inherit
|
||||
|
||||
newrelic:
|
||||
needs: call_server_utility_workflow
|
||||
needs: call_server_application_workflow
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -23,3 +23,5 @@ data/*
|
||||
|
||||
logs/*
|
||||
!logs/.gitkeep
|
||||
|
||||
docker-compose.yml
|
||||
|
||||
114
.pnp.cjs
generated
114
.pnp.cjs
generated
@@ -4257,8 +4257,6 @@ const RAW_RUNTIME_STATE =
|
||||
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:5.48.2"],\
|
||||
["eslint-plugin-prettier", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:4.2.1"],\
|
||||
["jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.1.2"],\
|
||||
["reflect-metadata", "npm:0.1.13"],\
|
||||
["shallow-equal-object", "npm:1.1.1"],\
|
||||
["ts-jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.0.3"],\
|
||||
["typescript", "patch:typescript@npm%3A4.8.4#optional!builtin<compat/typescript>::version=4.8.4&hash=701156"],\
|
||||
["uuid", "npm:9.0.0"]\
|
||||
@@ -4507,7 +4505,6 @@ const RAW_RUNTIME_STATE =
|
||||
["@types/dotenv", "npm:8.2.0"],\
|
||||
["@types/express", "npm:4.17.14"],\
|
||||
["@types/inversify-express-utils", "npm:2.0.0"],\
|
||||
["@types/ioredis", "npm:5.0.0"],\
|
||||
["@types/jest", "npm:29.1.1"],\
|
||||
["@types/newrelic", "npm:9.4.0"],\
|
||||
["@typescript-eslint/eslint-plugin", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:5.48.2"],\
|
||||
@@ -4516,17 +4513,15 @@ const RAW_RUNTIME_STATE =
|
||||
["eslint", "npm:8.32.0"],\
|
||||
["eslint-plugin-prettier", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.2.1"],\
|
||||
["express", "npm:4.18.2"],\
|
||||
["helmet", "npm:6.0.0"],\
|
||||
["inversify", "npm:6.0.1"],\
|
||||
["inversify-express-utils", "npm:6.4.3"],\
|
||||
["ioredis", "npm:5.2.4"],\
|
||||
["jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.1.2"],\
|
||||
["mysql2", "npm:3.0.1"],\
|
||||
["newrelic", "npm:9.8.0"],\
|
||||
["npm-check-updates", "npm:16.0.1"],\
|
||||
["reflect-metadata", "npm:0.1.13"],\
|
||||
["ts-jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.0.3"],\
|
||||
["typeorm", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:0.3.10"],\
|
||||
["typeorm", "virtual:365b8c88cdf194291829ee28b79556e2328175d26a621363e703848100bea0042e9500db2a1206c9bbc3a4a76a1d169639ef774b2ea3a1a98584a9936b58c6be#npm:0.3.10"],\
|
||||
["typescript", "patch:typescript@npm%3A4.8.4#optional!builtin<compat/typescript>::version=4.8.4&hash=701156"],\
|
||||
["winston", "npm:3.8.2"]\
|
||||
],\
|
||||
@@ -4691,7 +4686,6 @@ const RAW_RUNTIME_STATE =
|
||||
["@types/dotenv", "npm:8.2.0"],\
|
||||
["@types/express", "npm:4.17.14"],\
|
||||
["@types/inversify-express-utils", "npm:2.0.0"],\
|
||||
["@types/ioredis", "npm:5.0.0"],\
|
||||
["@types/jest", "npm:29.1.1"],\
|
||||
["@types/jsonwebtoken", "npm:9.0.1"],\
|
||||
["@types/newrelic", "npm:9.4.0"],\
|
||||
@@ -4708,7 +4702,6 @@ const RAW_RUNTIME_STATE =
|
||||
["helmet", "npm:6.0.0"],\
|
||||
["inversify", "npm:6.0.1"],\
|
||||
["inversify-express-utils", "npm:6.4.3"],\
|
||||
["ioredis", "npm:5.2.4"],\
|
||||
["jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.1.2"],\
|
||||
["jsonwebtoken", "npm:9.0.0"],\
|
||||
["mysql2", "npm:3.0.1"],\
|
||||
@@ -4718,7 +4711,7 @@ const RAW_RUNTIME_STATE =
|
||||
["prettyjson", "npm:1.2.5"],\
|
||||
["reflect-metadata", "npm:0.1.13"],\
|
||||
["ts-jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.0.3"],\
|
||||
["typeorm", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:0.3.10"],\
|
||||
["typeorm", "virtual:365b8c88cdf194291829ee28b79556e2328175d26a621363e703848100bea0042e9500db2a1206c9bbc3a4a76a1d169639ef774b2ea3a1a98584a9936b58c6be#npm:0.3.10"],\
|
||||
["typescript", "patch:typescript@npm%3A4.8.4#optional!builtin<compat/typescript>::version=4.8.4&hash=701156"],\
|
||||
["ua-parser-js", "npm:1.0.32"],\
|
||||
["uuid", "npm:9.0.0"],\
|
||||
@@ -13341,15 +13334,6 @@ const RAW_RUNTIME_STATE =
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["shallow-equal-object", [\
|
||||
["npm:1.1.1", {\
|
||||
"packageLocation": "./.yarn/cache/shallow-equal-object-npm-1.1.1-a41b289b2e-9e5e0cd10b.zip/node_modules/shallow-equal-object/",\
|
||||
"packageDependencies": [\
|
||||
["shallow-equal-object", "npm:1.1.1"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["shebang-command", [\
|
||||
["npm:2.0.0", {\
|
||||
"packageLocation": "./.yarn/cache/shebang-command-npm-2.0.0-eb2b01921d-5907a8d5fa.zip/node_modules/shebang-command/",\
|
||||
@@ -14489,6 +14473,100 @@ const RAW_RUNTIME_STATE =
|
||||
],\
|
||||
"linkType": "SOFT"\
|
||||
}],\
|
||||
["virtual:365b8c88cdf194291829ee28b79556e2328175d26a621363e703848100bea0042e9500db2a1206c9bbc3a4a76a1d169639ef774b2ea3a1a98584a9936b58c6be#npm:0.3.10", {\
|
||||
"packageLocation": "./.yarn/__virtual__/typeorm-virtual-6480afe6bc/0/cache/typeorm-npm-0.3.10-4667857f33-749e1a6777.zip/node_modules/typeorm/",\
|
||||
"packageDependencies": [\
|
||||
["typeorm", "virtual:365b8c88cdf194291829ee28b79556e2328175d26a621363e703848100bea0042e9500db2a1206c9bbc3a4a76a1d169639ef774b2ea3a1a98584a9936b58c6be#npm:0.3.10"],\
|
||||
["@google-cloud/spanner", null],\
|
||||
["@sap/hana-client", null],\
|
||||
["@sqltools/formatter", "npm:1.2.5"],\
|
||||
["@types/better-sqlite3", null],\
|
||||
["@types/google-cloud__spanner", null],\
|
||||
["@types/hdb-pool", null],\
|
||||
["@types/ioredis", null],\
|
||||
["@types/mongodb", null],\
|
||||
["@types/mssql", null],\
|
||||
["@types/mysql2", null],\
|
||||
["@types/oracledb", null],\
|
||||
["@types/pg", null],\
|
||||
["@types/pg-native", null],\
|
||||
["@types/pg-query-stream", null],\
|
||||
["@types/redis", null],\
|
||||
["@types/sap__hana-client", null],\
|
||||
["@types/sql.js", null],\
|
||||
["@types/sqlite3", null],\
|
||||
["@types/ts-node", null],\
|
||||
["@types/typeorm-aurora-data-api-driver", null],\
|
||||
["app-root-path", "npm:3.1.0"],\
|
||||
["better-sqlite3", null],\
|
||||
["buffer", "npm:6.0.3"],\
|
||||
["chalk", "npm:4.1.2"],\
|
||||
["cli-highlight", "npm:2.1.11"],\
|
||||
["date-fns", "npm:2.29.3"],\
|
||||
["debug", "virtual:b86a9fb34323a98c6519528ed55faa0d9b44ca8879307c0b29aa384bde47ff59a7d0c9051b31246f14521dfb71ba3c5d6d0b35c29fffc17bf875aa6ad977d9e8#npm:4.3.4"],\
|
||||
["dotenv", "npm:16.0.3"],\
|
||||
["glob", "npm:7.2.3"],\
|
||||
["hdb-pool", null],\
|
||||
["ioredis", null],\
|
||||
["js-yaml", "npm:4.1.0"],\
|
||||
["mkdirp", "npm:1.0.4"],\
|
||||
["mongodb", null],\
|
||||
["mssql", null],\
|
||||
["mysql2", "npm:3.0.1"],\
|
||||
["oracledb", null],\
|
||||
["pg", null],\
|
||||
["pg-native", null],\
|
||||
["pg-query-stream", null],\
|
||||
["redis", null],\
|
||||
["reflect-metadata", "npm:0.1.13"],\
|
||||
["sha.js", "npm:2.4.11"],\
|
||||
["sql.js", null],\
|
||||
["sqlite3", null],\
|
||||
["ts-node", null],\
|
||||
["tslib", "npm:2.4.0"],\
|
||||
["typeorm-aurora-data-api-driver", null],\
|
||||
["uuid", "npm:8.3.2"],\
|
||||
["xml2js", "npm:0.4.23"],\
|
||||
["yargs", "npm:17.5.1"]\
|
||||
],\
|
||||
"packagePeers": [\
|
||||
"@google-cloud/spanner",\
|
||||
"@sap/hana-client",\
|
||||
"@types/better-sqlite3",\
|
||||
"@types/google-cloud__spanner",\
|
||||
"@types/hdb-pool",\
|
||||
"@types/ioredis",\
|
||||
"@types/mongodb",\
|
||||
"@types/mssql",\
|
||||
"@types/mysql2",\
|
||||
"@types/oracledb",\
|
||||
"@types/pg-native",\
|
||||
"@types/pg-query-stream",\
|
||||
"@types/pg",\
|
||||
"@types/redis",\
|
||||
"@types/sap__hana-client",\
|
||||
"@types/sql.js",\
|
||||
"@types/sqlite3",\
|
||||
"@types/ts-node",\
|
||||
"@types/typeorm-aurora-data-api-driver",\
|
||||
"better-sqlite3",\
|
||||
"hdb-pool",\
|
||||
"ioredis",\
|
||||
"mongodb",\
|
||||
"mssql",\
|
||||
"mysql2",\
|
||||
"oracledb",\
|
||||
"pg-native",\
|
||||
"pg-query-stream",\
|
||||
"pg",\
|
||||
"redis",\
|
||||
"sql.js",\
|
||||
"sqlite3",\
|
||||
"ts-node",\
|
||||
"typeorm-aurora-data-api-driver"\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}],\
|
||||
["virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:0.3.10", {\
|
||||
"packageLocation": "./.yarn/__virtual__/typeorm-virtual-a38286c9d5/0/cache/typeorm-npm-0.3.10-4667857f33-749e1a6777.zip/node_modules/typeorm/",\
|
||||
"packageDependencies": [\
|
||||
|
||||
Binary file not shown.
18
Dockerfile
18
Dockerfile
@@ -26,4 +26,22 @@ RUN yarn install --immutable
|
||||
|
||||
RUN CI=true yarn build
|
||||
|
||||
RUN mkdir -p \
|
||||
/opt/bundled/syncing-server \
|
||||
/opt/bundled/auth \
|
||||
/opt/bundled/files \
|
||||
/opt/bundled/revisions \
|
||||
/opt/bundled/api-gateway \
|
||||
/opt/shared/uploads
|
||||
|
||||
RUN yarn workspace @standardnotes/syncing-server bundle --no-compress --output-directory /opt/bundled/syncing-server
|
||||
RUN yarn workspace @standardnotes/auth-server bundle --no-compress --output-directory /opt/bundled/auth
|
||||
RUN yarn workspace @standardnotes/files-server bundle --no-compress --output-directory /opt/bundled/files
|
||||
RUN yarn workspace @standardnotes/revisions-server bundle --no-compress --output-directory /opt/bundled/revisions
|
||||
RUN yarn workspace @standardnotes/api-gateway bundle --no-compress --output-directory /opt/bundled/api-gateway
|
||||
|
||||
WORKDIR /opt/bundled
|
||||
|
||||
RUN rm -rf /opt/server
|
||||
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
services:
|
||||
server:
|
||||
build: .
|
||||
env_file: .env
|
||||
container_name: server-self-hosted
|
||||
env_file: .github/ci.env
|
||||
container_name: server-ci
|
||||
ports:
|
||||
- ${EXPOSED_PORT}:3000
|
||||
- 3123:3000
|
||||
- 3125:3104
|
||||
volumes:
|
||||
- ./logs:/var/lib/server/logs
|
||||
networks:
|
||||
- standardnotes_self_hosted
|
||||
|
||||
localstack:
|
||||
image: localstack/localstack:1.3
|
||||
container_name: localstack-self-hosted
|
||||
container_name: localstack-ci
|
||||
expose:
|
||||
- 4566
|
||||
restart: unless-stopped
|
||||
@@ -22,28 +25,34 @@ services:
|
||||
volumes:
|
||||
- ./docker/localstack_bootstrap.sh:/etc/localstack/init/ready.d/localstack_bootstrap.sh
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
networks:
|
||||
- standardnotes_self_hosted
|
||||
|
||||
db:
|
||||
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}'
|
||||
container_name: db-ci
|
||||
env_file: .github/ci.env
|
||||
expose:
|
||||
- 3306
|
||||
restart: unless-stopped
|
||||
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8 --collation-server=utf8_general_ci
|
||||
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
|
||||
volumes:
|
||||
- ./data/mysql:/var/lib/mysql
|
||||
- ./data/import:/docker-entrypoint-initdb.d
|
||||
networks:
|
||||
- standardnotes_self_hosted
|
||||
|
||||
cache:
|
||||
image: redis:6.0-alpine
|
||||
container_name: cache-self-hosted
|
||||
container_name: cache-ci
|
||||
volumes:
|
||||
- ./data/redis/:/data
|
||||
expose:
|
||||
- 6379
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- standardnotes_self_hosted
|
||||
|
||||
networks:
|
||||
standardnotes_self_hosted:
|
||||
name: standardnotes_self_hosted
|
||||
63
docker-compose.example.yml
Normal file
63
docker-compose.example.yml
Normal file
@@ -0,0 +1,63 @@
|
||||
services:
|
||||
server:
|
||||
image: standardnotes/server
|
||||
env_file: .env
|
||||
container_name: server_self_hosted
|
||||
ports:
|
||||
- 3000:3000
|
||||
- 3125:3104
|
||||
volumes:
|
||||
- ./logs:/var/lib/server/logs
|
||||
- ./uploads:/opt/bundled/files/packages/files/dist/uploads
|
||||
networks:
|
||||
- standardnotes_self_hosted
|
||||
|
||||
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:
|
||||
- ./localstack_bootstrap.sh:/etc/localstack/init/ready.d/localstack_bootstrap.sh
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
networks:
|
||||
- standardnotes_self_hosted
|
||||
|
||||
db:
|
||||
image: mysql:8
|
||||
container_name: db_self_hosted
|
||||
environment:
|
||||
- MYSQL_DATABASE=standard_notes_db
|
||||
- MYSQL_USER=std_notes_user
|
||||
- MYSQL_ROOT_PASSWORD=changeme123
|
||||
- MYSQL_PASSWORD=changeme123
|
||||
expose:
|
||||
- 3306
|
||||
restart: unless-stopped
|
||||
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
|
||||
volumes:
|
||||
- ./data/mysql:/var/lib/mysql
|
||||
- ./data/import:/docker-entrypoint-initdb.d
|
||||
networks:
|
||||
- standardnotes_self_hosted
|
||||
|
||||
cache:
|
||||
image: redis:6.0-alpine
|
||||
container_name: cache_self_hosted
|
||||
volumes:
|
||||
- ./data/redis/:/data
|
||||
expose:
|
||||
- 6379
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- standardnotes_self_hosted
|
||||
|
||||
networks:
|
||||
standardnotes_self_hosted:
|
||||
name: standardnotes_self_hosted
|
||||
@@ -16,11 +16,7 @@ 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
|
||||
export FILES_SERVER_PORT=3104
|
||||
|
||||
if [ -z "$REVISIONS_SERVER_PORT" ]; then
|
||||
export REVISIONS_SERVER_PORT=3105
|
||||
@@ -48,9 +44,7 @@ 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
|
||||
export DB_MIGRATIONS_PATH="dist/migrations/*.js"
|
||||
|
||||
#########
|
||||
# CACHE #
|
||||
@@ -61,11 +55,11 @@ if [ -z "$REDIS_PORT" ]; then
|
||||
fi
|
||||
|
||||
if [ -z "$REDIS_HOST" ]; then
|
||||
export REDIS_URL="redis://cache"
|
||||
else
|
||||
export REDIS_URL="redis://$REDIS_HOST"
|
||||
export REDIS_HOST="cache"
|
||||
fi
|
||||
|
||||
export REDIS_URL="redis://$REDIS_HOST"
|
||||
|
||||
##########
|
||||
# SHARED #
|
||||
##########
|
||||
@@ -182,7 +176,7 @@ 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
|
||||
printenv | grep AUTH_SERVER_ | sed 's/AUTH_SERVER_//g' > /opt/bundled/auth/packages/auth/.env
|
||||
|
||||
##################
|
||||
# SYNCING SERVER #
|
||||
@@ -239,11 +233,9 @@ 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
|
||||
export SYNCING_SERVER_FILE_UPLOAD_PATH="/opt/shared/uploads"
|
||||
|
||||
printenv | grep SYNCING_SERVER_ | sed 's/SYNCING_SERVER_//g' > /opt/server/packages/syncing-server/.env
|
||||
printenv | grep SYNCING_SERVER_ | sed 's/SYNCING_SERVER_//g' > /opt/bundled/syncing-server/packages/syncing-server/.env
|
||||
|
||||
|
||||
################
|
||||
@@ -293,7 +285,7 @@ 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
|
||||
printenv | grep FILES_SERVER_ | sed 's/FILES_SERVER_//g' > /opt/bundled/files/packages/files/.env
|
||||
|
||||
#############
|
||||
# REVISIONS #
|
||||
@@ -339,7 +331,7 @@ 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
|
||||
printenv | grep REVISIONS_SERVER_ | sed 's/REVISIONS_SERVER_//g' > /opt/bundled/revisions/packages/revisions/.env
|
||||
|
||||
###############
|
||||
# API GATEWAY #
|
||||
@@ -360,15 +352,14 @@ 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
|
||||
export PUBLIC_FILES_SERVER_URL=http://localhost:3125
|
||||
fi
|
||||
export API_GATEWAY_FILES_SERVER_URL=$PUBLIC_FILES_SERVER_URL
|
||||
|
||||
printenv | grep API_GATEWAY_ | sed 's/API_GATEWAY_//g' > /opt/server/packages/api-gateway/.env
|
||||
printenv | grep API_GATEWAY_ | sed 's/API_GATEWAY_//g' > /opt/bundled/api-gateway/packages/api-gateway/.env
|
||||
|
||||
# Run supervisor
|
||||
|
||||
supervisord -c /etc/supervisord.conf
|
||||
|
||||
exec "$@"
|
||||
exec "$@"
|
||||
|
||||
30
docker/is-available.sh
Executable file
30
docker/is-available.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
WAIT_FOR_URL="$1"
|
||||
shift
|
||||
LOGS_PATH="$1"
|
||||
shift
|
||||
|
||||
attempt=0
|
||||
while [ $attempt -le 120 ]; do
|
||||
attempt=$(( $attempt + 1 ))
|
||||
echo "# Waiting for all services to be up (attempt: $attempt) ..."
|
||||
ping_api_gateway_result=`curl -s $WAIT_FOR_URL | grep "Welcome"`
|
||||
if [ "$?" -eq "0" ]; then
|
||||
sleep 2 # for warmup
|
||||
echo "# All services are up!"
|
||||
exit 0
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "# Failed to wait for all services to be up!"
|
||||
|
||||
echo "# Errors:"
|
||||
tail -n 50 $LOGS_PATH/*.err
|
||||
|
||||
echo "# Logs:"
|
||||
tail -n 50 $LOGS_PATH/*.log
|
||||
|
||||
exit 1
|
||||
@@ -1,75 +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
|
||||
logfile=/var/lib/server/logs/supervisord.log
|
||||
|
||||
[program:syncing-server]
|
||||
directory=/opt/server
|
||||
command=yarn start:syncing-server
|
||||
directory=/opt/bundled/syncing-server/packages/syncing-server
|
||||
command=/opt/bundled/syncing-server/packages/syncing-server/supervisor/supervisor-server.sh
|
||||
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
|
||||
directory=/opt/bundled/syncing-server/packages/syncing-server
|
||||
command=/opt/bundled/syncing-server/packages/syncing-server/supervisor/supervisor-worker.sh
|
||||
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:auth]
|
||||
directory=/opt/bundled/auth/packages/auth
|
||||
command=/opt/bundled/auth/packages/auth/supervisor/supervisor-server.sh
|
||||
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/bundled/auth/packages/auth
|
||||
command=/opt/bundled/auth/packages/auth/supervisor/supervisor-worker.sh
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/lib/server/logs/auth-worker.log
|
||||
stderr_logfile=/var/lib/server/logs/auth-worker.err
|
||||
|
||||
[program:files]
|
||||
directory=/opt/server
|
||||
command=yarn start:files
|
||||
directory=/opt/bundled/files/packages/files
|
||||
command=/opt/bundled/files/packages/files/supervisor/supervisor-server.sh
|
||||
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
|
||||
directory=/opt/bundled/files/packages/files
|
||||
command=/opt/bundled/files/packages/files/supervisor/supervisor-worker.sh
|
||||
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
|
||||
directory=/opt/bundled/revisions/packages/revisions
|
||||
command=/opt/bundled/revisions/packages/revisions/supervisor/supervisor-server.sh
|
||||
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
|
||||
directory=/opt/bundled/revisions/packages/revisions
|
||||
command=/opt/bundled/revisions/packages/revisions/supervisor/supervisor-worker.sh
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/lib/server/logs/revisions-worker.log
|
||||
stderr_logfile=/var/lib/server/logs/revisions-worker.err
|
||||
stderr_logfile=/var/lib/server/logs/revisions-worker.err
|
||||
|
||||
[program:api-gateway]
|
||||
directory=/opt/bundled/api-gateway/packages/api-gateway
|
||||
command=/opt/bundled/api-gateway/packages/api-gateway/supervisor/supervisor-server.sh
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/lib/server/logs/api-gateway.log
|
||||
stderr_logfile=/var/lib/server/logs/api-gateway.err
|
||||
|
||||
30
package.json
30
package.json
@@ -12,38 +12,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "yarn workspaces foreach -p -j 10 --verbose run lint",
|
||||
"lint:auth": "yarn workspace @standardnotes/auth-server lint",
|
||||
"lint:scheduler": "yarn workspace @standardnotes/scheduler-server lint",
|
||||
"lint:syncing-server-js": "yarn workspace @standardnotes/syncing-server lint",
|
||||
"lint:files": "yarn workspace @standardnotes/files-server lint",
|
||||
"lint:api-gateway": "yarn workspace @standardnotes/api-gateway lint",
|
||||
"lint:event-store": "yarn workspace @standardnotes/event-store lint",
|
||||
"lint:websockets": "yarn workspace @standardnotes/websockets-server lint",
|
||||
"lint:workspace": "yarn workspace @standardnotes/workspace-server lint",
|
||||
"lint:analytics": "yarn workspace @standardnotes/analytics lint",
|
||||
"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",
|
||||
"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 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 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",
|
||||
|
||||
@@ -3,6 +3,20 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.20.2](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.20.1...@standardnotes/analytics@2.20.2) (2023-02-20)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/analytics
|
||||
|
||||
## [2.20.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.20.0...@standardnotes/analytics@2.20.1) (2023-02-15)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/analytics
|
||||
|
||||
# [2.20.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.19.16...@standardnotes/analytics@2.20.0) (2023-02-15)
|
||||
|
||||
### Features
|
||||
|
||||
* optimize memory on server utilities ([881a696](https://github.com/standardnotes/server/commit/881a6967aca57d68795af0792114f848ddddf120))
|
||||
|
||||
## [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
|
||||
|
||||
@@ -8,10 +8,10 @@ ENV NODE_ENV production
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY ./ /workspace
|
||||
|
||||
WORKDIR /workspace/packages/analytics
|
||||
|
||||
ENTRYPOINT [ "/workspace/packages/analytics/docker/entrypoint.sh" ]
|
||||
|
||||
CMD [ "start-worker" ]
|
||||
|
||||
11
packages/analytics/docker/entrypoint-report.js
Normal file
11
packages/analytics/docker/entrypoint-report.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/report.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
11
packages/analytics/docker/entrypoint-worker.js
Normal file
11
packages/analytics/docker/entrypoint-worker.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/worker.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
@@ -6,12 +6,12 @@ COMMAND=$1 && shift 1
|
||||
case "$COMMAND" in
|
||||
'start-worker' )
|
||||
echo "[Docker] Starting Worker..."
|
||||
yarn workspace @standardnotes/analytics worker
|
||||
node docker/entrypoint-worker.js
|
||||
;;
|
||||
|
||||
'report' )
|
||||
echo "[Docker] Starting Usage Report Generation..."
|
||||
yarn workspace @standardnotes/analytics report
|
||||
node docker/entrypoint-report.js
|
||||
;;
|
||||
|
||||
* )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/analytics",
|
||||
"version": "2.19.16",
|
||||
"version": "2.20.2",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,42 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.48.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.48.1...@standardnotes/api-gateway@1.48.2) (2023-02-20)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||
|
||||
## [1.48.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.48.0...@standardnotes/api-gateway@1.48.1) (2023-02-15)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||
|
||||
# [1.48.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.47.1...@standardnotes/api-gateway@1.48.0) (2023-02-15)
|
||||
|
||||
### Features
|
||||
|
||||
* optimize memory usage ([#444](https://github.com/standardnotes/api-gateway/issues/444)) ([fdf4b29](https://github.com/standardnotes/api-gateway/commit/fdf4b29ae2717e9b5d1fba2722beb7621a7e5c37))
|
||||
|
||||
## [1.47.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.47.0...@standardnotes/api-gateway@1.47.1) (2023-02-14)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||
|
||||
# [1.47.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.46.13...@standardnotes/api-gateway@1.47.0) (2023-02-13)
|
||||
|
||||
### Features
|
||||
|
||||
* **syncing-server:** refactor container config into server and worker ([#443](https://github.com/standardnotes/api-gateway/issues/443)) ([993d311](https://github.com/standardnotes/api-gateway/commit/993d31167b8b0ac11e3df530d2d1ee566940df6e))
|
||||
|
||||
## [1.46.13](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.46.12...@standardnotes/api-gateway@1.46.13) (2023-02-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* performance of startup sequence in supervisor controlled self-hosting setup ([5bbdc7e](https://github.com/standardnotes/api-gateway/commit/5bbdc7e426c436b17dc130e3c6d9163080561c76))
|
||||
|
||||
## [1.46.12](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.46.11...@standardnotes/api-gateway@1.46.12) (2023-02-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* optimize memory usage ([e96fd6d](https://github.com/standardnotes/api-gateway/commit/e96fd6d69e1252842b5c91b1bedefa36e5d4a232))
|
||||
|
||||
## [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
|
||||
|
||||
@@ -8,10 +8,10 @@ ENV NODE_ENV production
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY ./ /workspace
|
||||
|
||||
WORKDIR /workspace/packages/api-gateway
|
||||
|
||||
ENTRYPOINT [ "/workspace/packages/api-gateway/docker/entrypoint.sh" ]
|
||||
|
||||
CMD [ "start-web" ]
|
||||
|
||||
11
packages/api-gateway/docker/entrypoint-server.js
Normal file
11
packages/api-gateway/docker/entrypoint-server.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/server.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
@@ -4,16 +4,9 @@ set -e
|
||||
COMMAND=$1 && shift 1
|
||||
|
||||
case "$COMMAND" in
|
||||
'start-local' )
|
||||
echo "Building the project..."
|
||||
yarn workspace @standardnotes/api-gateway build
|
||||
echo "Starting Web..."
|
||||
yarn workspace @standardnotes/api-gateway start
|
||||
;;
|
||||
|
||||
'start-web' )
|
||||
echo "Starting Web..."
|
||||
yarn workspace @standardnotes/api-gateway start
|
||||
node docker/entrypoint-server.js
|
||||
;;
|
||||
|
||||
* )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/api-gateway",
|
||||
"version": "1.46.11",
|
||||
"version": "1.48.2",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -1,35 +1,41 @@
|
||||
import { Request, Response } from 'express'
|
||||
import { inject } from 'inversify'
|
||||
import { BaseHttpController, controller, httpDelete, httpGet } from 'inversify-express-utils'
|
||||
import { BaseHttpController, controller, httpDelete, httpGet, results } from 'inversify-express-utils'
|
||||
import TYPES from '../../Bootstrap/Types'
|
||||
import { HttpServiceInterface } from '../../Service/Http/HttpServiceInterface'
|
||||
|
||||
@controller('/v1/items/:item_id/revisions', TYPES.AuthMiddleware)
|
||||
export class RevisionsController extends BaseHttpController {
|
||||
constructor(@inject(TYPES.HTTPService) private httpService: HttpServiceInterface) {
|
||||
super()
|
||||
}
|
||||
|
||||
@httpGet('/')
|
||||
async getRevisions(request: Request, response: Response): Promise<void> {
|
||||
await this.httpService.callSyncingServer(request, response, `items/${request.params.item_id}/revisions`)
|
||||
async getRevisions(): Promise<results.JsonResult> {
|
||||
return this.json(
|
||||
{
|
||||
error: {
|
||||
message: 'Please update your client application.',
|
||||
},
|
||||
},
|
||||
410,
|
||||
)
|
||||
}
|
||||
|
||||
@httpGet('/:id')
|
||||
async getRevision(request: Request, response: Response): Promise<void> {
|
||||
await this.httpService.callSyncingServer(
|
||||
request,
|
||||
response,
|
||||
`items/${request.params.item_id}/revisions/${request.params.id}`,
|
||||
async getRevision(): Promise<results.JsonResult> {
|
||||
return this.json(
|
||||
{
|
||||
error: {
|
||||
message: 'Please update your client application.',
|
||||
},
|
||||
},
|
||||
410,
|
||||
)
|
||||
}
|
||||
|
||||
@httpDelete('/:id')
|
||||
async deleteRevision(request: Request, response: Response): Promise<void> {
|
||||
await this.httpService.callSyncingServer(
|
||||
request,
|
||||
response,
|
||||
`items/${request.params.item_id}/revisions/${request.params.id}`,
|
||||
async deleteRevision(): Promise<results.JsonResult> {
|
||||
return this.json(
|
||||
{
|
||||
error: {
|
||||
message: 'Please update your client application.',
|
||||
},
|
||||
},
|
||||
410,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
6
packages/api-gateway/supervisor/supervisor-server.sh
Executable file
6
packages/api-gateway/supervisor/supervisor-server.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
sh supervisor/wait-for.sh localhost $SYNCING_SERVER_PORT
|
||||
node docker/entrypoint-server.js
|
||||
13
packages/api-gateway/supervisor/wait-for.sh
Executable file
13
packages/api-gateway/supervisor/wait-for.sh
Executable 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."
|
||||
@@ -3,6 +3,36 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.88.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.88.1...@standardnotes/auth-server@1.88.2) (2023-02-20)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/auth-server
|
||||
|
||||
## [1.88.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.88.0...@standardnotes/auth-server@1.88.1) (2023-02-15)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/auth-server
|
||||
|
||||
# [1.88.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.87.15...@standardnotes/auth-server@1.88.0) (2023-02-15)
|
||||
|
||||
### Features
|
||||
|
||||
* optimize memory usage ([#444](https://github.com/standardnotes/server/issues/444)) ([fdf4b29](https://github.com/standardnotes/server/commit/fdf4b29ae2717e9b5d1fba2722beb7621a7e5c37))
|
||||
|
||||
## [1.87.15](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.87.14...@standardnotes/auth-server@1.87.15) (2023-02-14)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/auth-server
|
||||
|
||||
## [1.87.14](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.87.13...@standardnotes/auth-server@1.87.14) (2023-02-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* performance of startup sequence in supervisor controlled self-hosting setup ([5bbdc7e](https://github.com/standardnotes/server/commit/5bbdc7e426c436b17dc130e3c6d9163080561c76))
|
||||
|
||||
## [1.87.13](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.87.12...@standardnotes/auth-server@1.87.13) (2023-02-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* optimize memory usage ([e96fd6d](https://github.com/standardnotes/server/commit/e96fd6d69e1252842b5c91b1bedefa36e5d4a232))
|
||||
|
||||
## [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
|
||||
|
||||
@@ -8,10 +8,10 @@ ENV NODE_ENV production
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY ./ /workspace
|
||||
|
||||
WORKDIR /workspace/packages/auth
|
||||
|
||||
ENTRYPOINT [ "/workspace/packages/auth/docker/entrypoint.sh" ]
|
||||
|
||||
CMD [ "start-web" ]
|
||||
|
||||
11
packages/auth/docker/entrypoint-backup.js
Normal file
11
packages/auth/docker/entrypoint-backup.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/backup.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
11
packages/auth/docker/entrypoint-cleanup.js
Normal file
11
packages/auth/docker/entrypoint-cleanup.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/cleanup.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
11
packages/auth/docker/entrypoint-content.js
Normal file
11
packages/auth/docker/entrypoint-content.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/content.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
11
packages/auth/docker/entrypoint-server.js
Normal file
11
packages/auth/docker/entrypoint-server.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/server.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
11
packages/auth/docker/entrypoint-stats.js
Normal file
11
packages/auth/docker/entrypoint-stats.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/stats.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
11
packages/auth/docker/entrypoint-user-email-backup.js
Normal file
11
packages/auth/docker/entrypoint-user-email-backup.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/user_email_backup.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
11
packages/auth/docker/entrypoint-worker.js
Normal file
11
packages/auth/docker/entrypoint-worker.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/worker.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
@@ -4,65 +4,60 @@ set -e
|
||||
COMMAND=$1 && shift 1
|
||||
|
||||
case "$COMMAND" in
|
||||
'start-local' )
|
||||
echo "[Docker] Starting Web..."
|
||||
yarn workspace @standardnotes/auth-server start:local
|
||||
;;
|
||||
|
||||
'start-web' )
|
||||
echo "[Docker] Starting Web..."
|
||||
yarn workspace @standardnotes/auth-server start
|
||||
node docker/entrypoint-server.js
|
||||
;;
|
||||
|
||||
'start-worker' )
|
||||
echo "[Docker] Starting Worker..."
|
||||
yarn workspace @standardnotes/auth-server worker
|
||||
node docker/entrypoint-worker.js
|
||||
;;
|
||||
|
||||
'cleanup' )
|
||||
echo "[Docker] Starting Cleanup..."
|
||||
yarn workspace @standardnotes/auth-server cleanup
|
||||
node docker/entrypoint-cleanup.js
|
||||
;;
|
||||
|
||||
'stats' )
|
||||
echo "[Docker] Starting Persisting Stats..."
|
||||
yarn workspace @standardnotes/auth-server stats
|
||||
node docker/entrypoint-stats.js
|
||||
;;
|
||||
|
||||
'email-daily-backup' )
|
||||
echo "[Docker] Starting Email Daily Backup..."
|
||||
yarn workspace @standardnotes/auth-server daily-backup:email
|
||||
node docker/entrypoint-backup.js email daily
|
||||
;;
|
||||
|
||||
'email-weekly-backup' )
|
||||
echo "[Docker] Starting Email Weekly Backup..."
|
||||
yarn workspace @standardnotes/auth-server weekly-backup:email
|
||||
node docker/entrypoint-backup.js email weekly
|
||||
;;
|
||||
|
||||
'email-backup' )
|
||||
echo "[Docker] Starting Email Backup For Single User..."
|
||||
EMAIL=$1 && shift 1
|
||||
yarn workspace @standardnotes/auth-server user-email-backup $EMAIL
|
||||
node docker/entrypoint-user-email-backup.js $EMAIL
|
||||
;;
|
||||
|
||||
'dropbox-daily-backup' )
|
||||
echo "[Docker] Starting Dropbox Daily Backup..."
|
||||
yarn workspace @standardnotes/auth-server daily-backup:dropbox
|
||||
node docker/entrypoint-backup.js dropbox daily
|
||||
;;
|
||||
|
||||
'google-drive-daily-backup' )
|
||||
echo "[Docker] Starting Google Drive Daily Backup..."
|
||||
yarn workspace @standardnotes/auth-server daily-backup:google_drive
|
||||
node docker/entrypoint-backup.js google_drive daily
|
||||
;;
|
||||
|
||||
'one-drive-daily-backup' )
|
||||
echo "[Docker] Starting One Drive Daily Backup..."
|
||||
yarn workspace @standardnotes/auth-server daily-backup:one_drive
|
||||
node docker/entrypoint-backup.js one_drive daily
|
||||
;;
|
||||
|
||||
'content-recalculation' )
|
||||
echo "[Docker] Starting Content Size Recalculation..."
|
||||
yarn workspace @standardnotes/auth-server content-recalculation
|
||||
node docker/entrypoint-content.js
|
||||
;;
|
||||
|
||||
* )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/auth-server",
|
||||
"version": "1.87.12",
|
||||
"version": "1.88.2",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
6
packages/auth/supervisor/supervisor-server.sh
Executable file
6
packages/auth/supervisor/supervisor-server.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
sh supervisor/wait-for.sh localhost $SYNCING_SERVER_PORT
|
||||
node docker/entrypoint-server.js
|
||||
6
packages/auth/supervisor/supervisor-worker.sh
Executable file
6
packages/auth/supervisor/supervisor-worker.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
sh supervisor/wait-for.sh localhost $AUTH_SERVER_PORT
|
||||
node docker/entrypoint-worker.js
|
||||
13
packages/auth/supervisor/wait-for.sh
Executable file
13
packages/auth/supervisor/wait-for.sh
Executable 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."
|
||||
@@ -3,6 +3,12 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.11.3](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.11.2...@standardnotes/domain-core@1.11.3) (2023-02-15)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **domain-core:** remove unnecessary dependencies ([16043a7](https://github.com/standardnotes/server/commit/16043a7d6881378ed3286e08dc9e21e5e6b89171))
|
||||
|
||||
## [1.11.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.11.1...@standardnotes/domain-core@1.11.2) (2023-01-20)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/domain-core
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/domain-core",
|
||||
"version": "1.11.2",
|
||||
"version": "1.11.3",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
@@ -23,8 +23,6 @@
|
||||
"test": "jest spec --coverage --passWithNoTests"
|
||||
},
|
||||
"dependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"shallow-equal-object": "^1.1.1",
|
||||
"uuid": "^9.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -10,7 +10,7 @@ export class RoleNameCollection extends ValueObject<RoleNameCollectionProps> {
|
||||
|
||||
includes(roleName: RoleName): boolean {
|
||||
for (const existingRoleName of this.props.value) {
|
||||
if (existingRoleName.equals(roleName)) {
|
||||
if (existingRoleName.value === roleName.value) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ export class RoleNameCollection extends ValueObject<RoleNameCollectionProps> {
|
||||
return false
|
||||
}
|
||||
|
||||
override equals(roleNameCollection: RoleNameCollection): boolean {
|
||||
equals(roleNameCollection: RoleNameCollection): boolean {
|
||||
if (this.props.value.length !== roleNameCollection.value.length) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
/* istanbul ignore file */
|
||||
|
||||
import { shallowEqual } from 'shallow-equal-object'
|
||||
|
||||
import { ValueObjectProps } from './ValueObjectProps'
|
||||
|
||||
export abstract class ValueObject<T extends ValueObjectProps> {
|
||||
@@ -10,15 +7,4 @@ export abstract class ValueObject<T extends ValueObjectProps> {
|
||||
constructor(props: T) {
|
||||
this.props = Object.freeze(props)
|
||||
}
|
||||
|
||||
equals(valueObject?: ValueObject<T>): boolean {
|
||||
if (valueObject === null || valueObject === undefined) {
|
||||
return false
|
||||
}
|
||||
if (valueObject.props === undefined) {
|
||||
return false
|
||||
}
|
||||
|
||||
return shallowEqual(this.props, valueObject.props)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.69](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.9.68...@standardnotes/domain-events-infra@1.9.69) (2023-02-20)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/domain-events-infra
|
||||
|
||||
## [1.9.68](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.9.67...@standardnotes/domain-events-infra@1.9.68) (2023-01-30)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/domain-events-infra
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/domain-events-infra",
|
||||
"version": "1.9.68",
|
||||
"version": "1.9.69",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
# [2.107.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.106.2...@standardnotes/domain-events@2.107.0) (2023-02-20)
|
||||
|
||||
### Features
|
||||
|
||||
* **domain-events:** add email sent event ([190595f](https://github.com/standardnotes/server/commit/190595febf935f0f47818a2d9f7926a5f351a458))
|
||||
|
||||
## [2.106.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.106.1...@standardnotes/domain-events@2.106.2) (2023-01-20)
|
||||
|
||||
### Reverts
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/domain-events",
|
||||
"version": "2.106.2",
|
||||
"version": "2.107.0",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { DomainEventInterface } from './DomainEventInterface'
|
||||
import { EmailSentEventPayload } from './EmailSentEventPayload'
|
||||
|
||||
export interface EmailSentEvent extends DomainEventInterface {
|
||||
type: 'EMAIL_SENT'
|
||||
payload: EmailSentEventPayload
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface EmailSentEventPayload {
|
||||
userEmail: string
|
||||
messageIdentifier: string
|
||||
level: string
|
||||
subject: string
|
||||
body: string
|
||||
sender?: string
|
||||
additionalStyles?: string
|
||||
attachments?: Array<{
|
||||
filePath: string
|
||||
fileName: string
|
||||
attachmentFileName: string
|
||||
attachmentContentType: string
|
||||
}>
|
||||
}
|
||||
@@ -14,6 +14,8 @@ export * from './Event/EmailBackupRequestedEvent'
|
||||
export * from './Event/EmailBackupRequestedEventPayload'
|
||||
export * from './Event/EmailRequestedEvent'
|
||||
export * from './Event/EmailRequestedEventPayload'
|
||||
export * from './Event/EmailSentEvent'
|
||||
export * from './Event/EmailSentEventPayload'
|
||||
export * from './Event/EmailSubscriptionUnsubscribedEvent'
|
||||
export * from './Event/EmailSubscriptionUnsubscribedEventPayload'
|
||||
export * from './Event/ExitDiscountAppliedEvent'
|
||||
|
||||
@@ -3,6 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.7.1](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.7.0...@standardnotes/event-store@1.7.1) (2023-02-20)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **event-store:** add handling of email sent events ([d023a27](https://github.com/standardnotes/server/commit/d023a2737772e01eca8dc2c848ddebe43bb58734))
|
||||
|
||||
# [1.7.0](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.6.68...@standardnotes/event-store@1.7.0) (2023-02-15)
|
||||
|
||||
### Features
|
||||
|
||||
* optimize memory on server utilities ([881a696](https://github.com/standardnotes/server/commit/881a6967aca57d68795af0792114f848ddddf120))
|
||||
|
||||
## [1.6.68](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.6.67...@standardnotes/event-store@1.6.68) (2023-01-30)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -8,10 +8,10 @@ ENV NODE_ENV production
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY ./ /workspace
|
||||
|
||||
WORKDIR /workspace/packages/event-store
|
||||
|
||||
ENTRYPOINT [ "/workspace/packages/event-store/docker/entrypoint.sh" ]
|
||||
|
||||
CMD [ "start-worker" ]
|
||||
|
||||
11
packages/event-store/docker/entrypoint-worker.js
Normal file
11
packages/event-store/docker/entrypoint-worker.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/worker.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
@@ -6,7 +6,7 @@ COMMAND=$1 && shift 1
|
||||
case "$COMMAND" in
|
||||
'start-worker' )
|
||||
echo "Starting Worker..."
|
||||
yarn workspace @standardnotes/event-store worker
|
||||
node docker/entrypoint-worker.js
|
||||
;;
|
||||
|
||||
* )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/event-store",
|
||||
"version": "1.6.68",
|
||||
"version": "1.7.1",
|
||||
"description": "Event Store Service",
|
||||
"private": true,
|
||||
"main": "dist/src/index.js",
|
||||
|
||||
@@ -81,6 +81,7 @@ export class ContainerConfigLoader {
|
||||
['LISTED_ACCOUNT_CREATED', container.get(TYPES.EventHandler)],
|
||||
['LISTED_ACCOUNT_DELETED', container.get(TYPES.EventHandler)],
|
||||
['EMAIL_REQUESTED', container.get(TYPES.EventHandler)],
|
||||
['EMAIL_SENT', container.get(TYPES.EventHandler)],
|
||||
['SHARED_SUBSCRIPTION_INVITATION_CREATED', container.get(TYPES.EventHandler)],
|
||||
['EMAIL_BACKUP_REQUESTED', container.get(TYPES.EventHandler)],
|
||||
['PAYMENT_FAILED', container.get(TYPES.EventHandler)],
|
||||
|
||||
@@ -3,6 +3,36 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.10.2](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.10.1...@standardnotes/files-server@1.10.2) (2023-02-20)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/files-server
|
||||
|
||||
## [1.10.1](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.10.0...@standardnotes/files-server@1.10.1) (2023-02-15)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/files-server
|
||||
|
||||
# [1.10.0](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.9.18...@standardnotes/files-server@1.10.0) (2023-02-15)
|
||||
|
||||
### Features
|
||||
|
||||
* optimize memory usage ([#444](https://github.com/standardnotes/files/issues/444)) ([fdf4b29](https://github.com/standardnotes/files/commit/fdf4b29ae2717e9b5d1fba2722beb7621a7e5c37))
|
||||
|
||||
## [1.9.18](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.9.17...@standardnotes/files-server@1.9.18) (2023-02-14)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/files-server
|
||||
|
||||
## [1.9.17](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.9.16...@standardnotes/files-server@1.9.17) (2023-02-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* performance of startup sequence in supervisor controlled self-hosting setup ([5bbdc7e](https://github.com/standardnotes/files/commit/5bbdc7e426c436b17dc130e3c6d9163080561c76))
|
||||
|
||||
## [1.9.16](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.9.15...@standardnotes/files-server@1.9.16) (2023-02-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* optimize memory usage ([e96fd6d](https://github.com/standardnotes/files/commit/e96fd6d69e1252842b5c91b1bedefa36e5d4a232))
|
||||
|
||||
## [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
|
||||
|
||||
@@ -8,10 +8,10 @@ ENV NODE_ENV production
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY ./ /workspace
|
||||
|
||||
WORKDIR /workspace/packages/files
|
||||
|
||||
ENTRYPOINT [ "/workspace/packages/files/docker/entrypoint.sh" ]
|
||||
|
||||
CMD [ "start-web" ]
|
||||
|
||||
11
packages/files/docker/entrypoint-server.js
Normal file
11
packages/files/docker/entrypoint-server.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/server.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
11
packages/files/docker/entrypoint-worker.js
Normal file
11
packages/files/docker/entrypoint-worker.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/worker.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
@@ -4,19 +4,14 @@ set -e
|
||||
COMMAND=$1 && shift 1
|
||||
|
||||
case "$COMMAND" in
|
||||
'start-local')
|
||||
echo "Starting Web in Local Mode..."
|
||||
yarn workspace @standardnotes/files-server start:local
|
||||
;;
|
||||
|
||||
'start-web' )
|
||||
echo "Starting Web..."
|
||||
yarn workspace @standardnotes/files-server start
|
||||
node docker/entrypoint-server.js
|
||||
;;
|
||||
|
||||
'start-worker' )
|
||||
echo "Starting Worker..."
|
||||
yarn workspace @standardnotes/files-server worker
|
||||
node docker/entrypoint-worker.js
|
||||
;;
|
||||
|
||||
* )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/files-server",
|
||||
"version": "1.9.15",
|
||||
"version": "1.10.2",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
|
||||
7
packages/files/supervisor/supervisor-server.sh
Executable file
7
packages/files/supervisor/supervisor-server.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
sh supervisor/wait-for.sh $DB_HOST $DB_PORT
|
||||
sh supervisor/wait-for.sh $REDIS_HOST $REDIS_PORT
|
||||
node docker/entrypoint-server.js
|
||||
6
packages/files/supervisor/supervisor-worker.sh
Executable file
6
packages/files/supervisor/supervisor-worker.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
sh supervisor/wait-for.sh localhost $SYNCING_SERVER_PORT
|
||||
node docker/entrypoint-worker.js
|
||||
13
packages/files/supervisor/wait-for.sh
Executable file
13
packages/files/supervisor/wait-for.sh
Executable 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."
|
||||
@@ -3,6 +3,83 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.12.3](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.12.2...@standardnotes/revisions-server@1.12.3) (2023-02-20)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/revisions-server
|
||||
|
||||
## [1.12.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.12.1...@standardnotes/revisions-server@1.12.2) (2023-02-17)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **revisions:** initial migration to check if user_uuid exists on table ([85d0c12](https://github.com/standardnotes/server/commit/85d0c12dadffe3ed7b8c0717725813e168e20b6c))
|
||||
|
||||
## [1.12.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.12.0...@standardnotes/revisions-server@1.12.1) (2023-02-15)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/revisions-server
|
||||
|
||||
# [1.12.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.11.6...@standardnotes/revisions-server@1.12.0) (2023-02-15)
|
||||
|
||||
### Features
|
||||
|
||||
* optimize memory usage ([#444](https://github.com/standardnotes/server/issues/444)) ([fdf4b29](https://github.com/standardnotes/server/commit/fdf4b29ae2717e9b5d1fba2722beb7621a7e5c37))
|
||||
|
||||
## [1.11.6](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.11.5...@standardnotes/revisions-server@1.11.6) (2023-02-14)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/revisions-server
|
||||
|
||||
## [1.11.5](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.11.4...@standardnotes/revisions-server@1.11.5) (2023-02-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **revisions:** api gateway middleware binding ([d333c13](https://github.com/standardnotes/server/commit/d333c1393c67899a6303dbec40527584cd1b48ab))
|
||||
|
||||
## [1.11.4](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.11.3...@standardnotes/revisions-server@1.11.4) (2023-02-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **revisions:** missing api gateway middleware ([826719b](https://github.com/standardnotes/server/commit/826719bb67dd403e4880ab61b25c92c4506e3c57))
|
||||
|
||||
## [1.11.3](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.11.2...@standardnotes/revisions-server@1.11.3) (2023-02-13)
|
||||
|
||||
### Reverts
|
||||
|
||||
* Revert "fix(revisions): remove inversify.js in favour of simple di container implementation (#442)" ([73f3fad](https://github.com/standardnotes/server/commit/73f3fad13da57619f008ed486c1d4114f3bad3b6)), closes [#442](https://github.com/standardnotes/server/issues/442)
|
||||
|
||||
## [1.11.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.11.1...@standardnotes/revisions-server@1.11.2) (2023-02-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **revisions:** remove inversify.js in favour of simple di container implementation ([#442](https://github.com/standardnotes/server/issues/442)) ([89ee103](https://github.com/standardnotes/server/commit/89ee103303651b2b181c3b79b7a500358165dcf2))
|
||||
|
||||
## [1.11.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.11.0...@standardnotes/revisions-server@1.11.1) (2023-02-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **revisions:** remove missing middleware binding ([622c024](https://github.com/standardnotes/server/commit/622c024547126a7580274d7e368f3787b809f7bc))
|
||||
|
||||
# [1.11.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.10.30...@standardnotes/revisions-server@1.11.0) (2023-02-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **revisions:** controller bindings ([645a24d](https://github.com/standardnotes/server/commit/645a24d29b2d1858251b80a8d453c98b955c79e3))
|
||||
* **revisions:** remove the interval ping ([be17b67](https://github.com/standardnotes/server/commit/be17b67cc1ff27c62dfee571f7d85954c1401fda))
|
||||
|
||||
### Features
|
||||
|
||||
* **revisions:** refactor container to split worker and server containers ([5120883](https://github.com/standardnotes/server/commit/512088369152766027cb25f1566fd2295ab75ac3))
|
||||
|
||||
## [1.10.30](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.10.29...@standardnotes/revisions-server@1.10.30) (2023-02-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* performance of startup sequence in supervisor controlled self-hosting setup ([5bbdc7e](https://github.com/standardnotes/server/commit/5bbdc7e426c436b17dc130e3c6d9163080561c76))
|
||||
|
||||
## [1.10.29](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.10.28...@standardnotes/revisions-server@1.10.29) (2023-02-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* optimize memory usage ([e96fd6d](https://github.com/standardnotes/server/commit/e96fd6d69e1252842b5c91b1bedefa36e5d4a232))
|
||||
|
||||
## [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
|
||||
|
||||
@@ -8,10 +8,10 @@ ENV NODE_ENV production
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY ./ /workspace
|
||||
|
||||
WORKDIR /workspace/packages/revisions
|
||||
|
||||
ENTRYPOINT [ "/workspace/packages/revisions/docker/entrypoint.sh" ]
|
||||
|
||||
CMD [ "start-web" ]
|
||||
|
||||
@@ -4,22 +4,21 @@ import 'newrelic'
|
||||
|
||||
import * as Sentry from '@sentry/node'
|
||||
|
||||
import '../src/Infra/InversifyExpress/InversifyExpressRevisionsController'
|
||||
import '../src/Infra/InversifyExpress/InversifyExpressHealthCheckController'
|
||||
|
||||
import * as cors from 'cors'
|
||||
import { urlencoded, json, Request, Response, NextFunction, RequestHandler, ErrorRequestHandler } from 'express'
|
||||
import * as winston from 'winston'
|
||||
|
||||
import { InversifyExpressServer } from 'inversify-express-utils'
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
import TYPES from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
import { ServerContainerConfigLoader } from '../src/Bootstrap/ServerContainerConfigLoader'
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
import '../src/Infra/InversifyExpress/InversifyExpressRevisionsController'
|
||||
import '../src/Infra/InversifyExpress/InversifyExpressHealthCheckController'
|
||||
|
||||
const container = new ServerContainerConfigLoader()
|
||||
void container.load().then((container) => {
|
||||
const env: Env = new Env()
|
||||
env.load()
|
||||
const env: Env = container.get(TYPES.Env)
|
||||
|
||||
const server = new InversifyExpressServer(container)
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ import 'newrelic'
|
||||
|
||||
import { Logger } from 'winston'
|
||||
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
import TYPES from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
|
||||
import { WorkerContainerConfigLoader } from '../src/Bootstrap/WorkerContainerConfigLoader'
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
const container = new WorkerContainerConfigLoader()
|
||||
void container.load().then((container) => {
|
||||
const env: Env = new Env()
|
||||
env.load()
|
||||
@@ -20,6 +20,4 @@ void container.load().then((container) => {
|
||||
|
||||
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(TYPES.DomainEventSubscriberFactory)
|
||||
subscriberFactory.create().start()
|
||||
|
||||
setInterval(() => logger.info('Alive and kicking!'), 20 * 60 * 1000)
|
||||
})
|
||||
|
||||
11
packages/revisions/docker/entrypoint-server.js
Normal file
11
packages/revisions/docker/entrypoint-server.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/server.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
11
packages/revisions/docker/entrypoint-worker.js
Normal file
11
packages/revisions/docker/entrypoint-worker.js
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
|
||||
|
||||
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/worker.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
@@ -6,12 +6,12 @@ COMMAND=$1 && shift 1
|
||||
case "$COMMAND" in
|
||||
'start-web' )
|
||||
echo "Starting Web..."
|
||||
yarn workspace @standardnotes/revisions-server start
|
||||
node docker/entrypoint-server.js
|
||||
;;
|
||||
|
||||
'start-worker' )
|
||||
echo "Starting Worker..."
|
||||
yarn workspace @standardnotes/revisions-server worker
|
||||
node docker/entrypoint-worker.js
|
||||
;;
|
||||
|
||||
* )
|
||||
|
||||
@@ -28,6 +28,14 @@ export class init1669113322388 implements MigrationInterface {
|
||||
return
|
||||
}
|
||||
|
||||
const revisionsTableHasUserUuidColumnQueryResult = await queryRunner.manager.query(
|
||||
'SELECT COUNT(*) as count FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = "revisions" AND column_name = "user_uuid"',
|
||||
)
|
||||
const revisionsTableHasUserUuidColumn = revisionsTableHasUserUuidColumnQueryResult[0].count === 1
|
||||
if (revisionsTableHasUserUuidColumn) {
|
||||
return
|
||||
}
|
||||
|
||||
await queryRunner.query('ALTER TABLE `revisions` ADD COLUMN `user_uuid` varchar(36) NULL')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/revisions-server",
|
||||
"version": "1.10.28",
|
||||
"version": "1.12.3",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <19.0.0"
|
||||
},
|
||||
@@ -37,10 +37,8 @@
|
||||
"cors": "2.8.5",
|
||||
"dotenv": "^16.0.1",
|
||||
"express": "^4.18.2",
|
||||
"helmet": "^6.0.0",
|
||||
"inversify": "^6.0.1",
|
||||
"inversify-express-utils": "^6.4.3",
|
||||
"ioredis": "^5.2.4",
|
||||
"mysql2": "^3.0.1",
|
||||
"newrelic": "^9.8.0",
|
||||
"reflect-metadata": "0.1.13",
|
||||
@@ -52,7 +50,6 @@
|
||||
"@types/dotenv": "^8.2.0",
|
||||
"@types/express": "^4.17.14",
|
||||
"@types/inversify-express-utils": "^2.0.0",
|
||||
"@types/ioredis": "^5.0.0",
|
||||
"@types/jest": "^29.1.1",
|
||||
"@types/newrelic": "^9.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.48.2",
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import { MapperInterface } from '@standardnotes/domain-core'
|
||||
import { Container, interfaces } from 'inversify'
|
||||
import { Repository } from 'typeorm'
|
||||
import * as winston from 'winston'
|
||||
import { Revision } from '../Domain/Revision/Revision'
|
||||
import { RevisionMetadata } from '../Domain/Revision/RevisionMetadata'
|
||||
import { RevisionRepositoryInterface } from '../Domain/Revision/RevisionRepositoryInterface'
|
||||
import { MySQLRevisionRepository } from '../Infra/MySQL/MySQLRevisionRepository'
|
||||
import { TypeORMRevision } from '../Infra/TypeORM/TypeORMRevision'
|
||||
import { RevisionMetadataPersistenceMapper } from '../Mapping/RevisionMetadataPersistenceMapper'
|
||||
import { RevisionPersistenceMapper } from '../Mapping/RevisionPersistenceMapper'
|
||||
import { AppDataSource } from './DataSource'
|
||||
import { Env } from './Env'
|
||||
import TYPES from './Types'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const newrelicFormatter = require('@newrelic/winston-enricher')
|
||||
|
||||
export class CommonContainerConfigLoader {
|
||||
async load(): Promise<Container> {
|
||||
const env: Env = new Env()
|
||||
env.load()
|
||||
|
||||
const container = new Container({
|
||||
defaultScope: 'Singleton',
|
||||
})
|
||||
|
||||
await AppDataSource.initialize()
|
||||
|
||||
container.bind<Env>(TYPES.Env).toConstantValue(env)
|
||||
|
||||
container.bind<winston.Logger>(TYPES.Logger).toDynamicValue((context: interfaces.Context) => {
|
||||
const env: Env = context.container.get(TYPES.Env)
|
||||
|
||||
const newrelicWinstonFormatter = newrelicFormatter(winston)
|
||||
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
||||
if (env.get('NEW_RELIC_ENABLED', true) === 'true') {
|
||||
winstonFormatters.push(newrelicWinstonFormatter())
|
||||
}
|
||||
|
||||
const logger = winston.createLogger({
|
||||
level: env.get('LOG_LEVEL') || 'info',
|
||||
format: winston.format.combine(...winstonFormatters),
|
||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
||||
})
|
||||
|
||||
return logger
|
||||
})
|
||||
|
||||
container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true))
|
||||
container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION'))
|
||||
|
||||
// Map
|
||||
container
|
||||
.bind<MapperInterface<RevisionMetadata, TypeORMRevision>>(TYPES.RevisionMetadataPersistenceMapper)
|
||||
.toDynamicValue(() => new RevisionMetadataPersistenceMapper())
|
||||
container
|
||||
.bind<MapperInterface<Revision, TypeORMRevision>>(TYPES.RevisionPersistenceMapper)
|
||||
.toDynamicValue(() => new RevisionPersistenceMapper())
|
||||
|
||||
// ORM
|
||||
container
|
||||
.bind<Repository<TypeORMRevision>>(TYPES.ORMRevisionRepository)
|
||||
.toDynamicValue(() => AppDataSource.getRepository(TypeORMRevision))
|
||||
|
||||
// Repositories
|
||||
container
|
||||
.bind<RevisionRepositoryInterface>(TYPES.RevisionRepository)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
return new MySQLRevisionRepository(
|
||||
context.container.get(TYPES.ORMRevisionRepository),
|
||||
context.container.get(TYPES.RevisionMetadataPersistenceMapper),
|
||||
context.container.get(TYPES.RevisionPersistenceMapper),
|
||||
context.container.get(TYPES.Logger),
|
||||
)
|
||||
})
|
||||
|
||||
return container
|
||||
}
|
||||
}
|
||||
@@ -1,283 +0,0 @@
|
||||
import * as winston from 'winston'
|
||||
import Redis from 'ioredis'
|
||||
import { Timer, TimerInterface } from '@standardnotes/time'
|
||||
import { SQSClient, SQSClientConfig } from '@aws-sdk/client-sqs'
|
||||
import { S3Client } from '@aws-sdk/client-s3'
|
||||
import { Container } from 'inversify'
|
||||
import { Repository } from 'typeorm'
|
||||
import {
|
||||
DomainEventHandlerInterface,
|
||||
DomainEventMessageHandlerInterface,
|
||||
DomainEventSubscriberFactoryInterface,
|
||||
} from '@standardnotes/domain-events'
|
||||
import { TokenDecoderInterface, CrossServiceTokenData, TokenDecoder } from '@standardnotes/security'
|
||||
import {
|
||||
SQSDomainEventSubscriberFactory,
|
||||
SQSEventMessageHandler,
|
||||
SQSNewRelicEventMessageHandler,
|
||||
} from '@standardnotes/domain-events-infra'
|
||||
import { MapperInterface } from '@standardnotes/domain-core'
|
||||
|
||||
import { Env } from './Env'
|
||||
import TYPES from './Types'
|
||||
import { AppDataSource } from './DataSource'
|
||||
import { InversifyExpressApiGatewayAuthMiddleware } from '../Infra/InversifyExpress/InversifyExpressApiGatewayAuthMiddleware'
|
||||
import { RevisionsController } from '../Controller/RevisionsController'
|
||||
import { GetRevisionsMetada } from '../Domain/UseCase/GetRevisionsMetada/GetRevisionsMetada'
|
||||
import { RevisionRepositoryInterface } from '../Domain/Revision/RevisionRepositoryInterface'
|
||||
import { MySQLRevisionRepository } from '../Infra/MySQL/MySQLRevisionRepository'
|
||||
import { RevisionMetadataPersistenceMapper } from '../Mapping/RevisionMetadataPersistenceMapper'
|
||||
import { TypeORMRevision } from '../Infra/TypeORM/TypeORMRevision'
|
||||
import { RevisionMetadata } from '../Domain/Revision/RevisionMetadata'
|
||||
import { Revision } from '../Domain/Revision/Revision'
|
||||
import { RevisionItemStringMapper } from '../Mapping/RevisionItemStringMapper'
|
||||
import { RevisionPersistenceMapper } from '../Mapping/RevisionPersistenceMapper'
|
||||
import { ItemDumpedEventHandler } from '../Domain/Handler/ItemDumpedEventHandler'
|
||||
import { DumpRepositoryInterface } from '../Domain/Dump/DumpRepositoryInterface'
|
||||
import { S3DumpRepository } from '../Infra/S3/S3ItemDumpRepository'
|
||||
import { FSDumpRepository } from '../Infra/FS/FSDumpRepository'
|
||||
import { GetRevision } from '../Domain/UseCase/GetRevision/GetRevision'
|
||||
import { DeleteRevision } from '../Domain/UseCase/DeleteRevision/DeleteRevision'
|
||||
import { AccountDeletionRequestedEventHandler } from '../Domain/Handler/AccountDeletionRequestedEventHandler'
|
||||
import { RevisionsCopyRequestedEventHandler } from '../Domain/Handler/RevisionsCopyRequestedEventHandler'
|
||||
import { CopyRevisions } from '../Domain/UseCase/CopyRevisions/CopyRevisions'
|
||||
import { RevisionsOwnershipUpdateRequestedEventHandler } from '../Domain/Handler/RevisionsOwnershipUpdateRequestedEventHandler'
|
||||
import { RevisionHttpMapper } from '../Mapping/RevisionHttpMapper'
|
||||
import { RevisionMetadataHttpMapper } from '../Mapping/RevisionMetadataHttpMapper'
|
||||
import { GetRequiredRoleToViewRevision } from '../Domain/UseCase/GetRequiredRoleToViewRevision/GetRequiredRoleToViewRevision'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const newrelicFormatter = require('@newrelic/winston-enricher')
|
||||
|
||||
export class ContainerConfigLoader {
|
||||
async load(): Promise<Container> {
|
||||
const env: Env = new Env()
|
||||
env.load()
|
||||
|
||||
const container = new Container()
|
||||
|
||||
await AppDataSource.initialize()
|
||||
|
||||
const redisUrl = env.get('REDIS_URL')
|
||||
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
||||
let redis
|
||||
if (isRedisInClusterMode) {
|
||||
redis = new Redis.Cluster(redisUrl.split(','))
|
||||
} else {
|
||||
redis = new Redis(redisUrl)
|
||||
}
|
||||
|
||||
container.bind(TYPES.Redis).toConstantValue(redis)
|
||||
|
||||
const newrelicWinstonFormatter = newrelicFormatter(winston)
|
||||
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
||||
if (env.get('NEW_RELIC_ENABLED', true) === 'true') {
|
||||
winstonFormatters.push(newrelicWinstonFormatter())
|
||||
}
|
||||
|
||||
const logger = winston.createLogger({
|
||||
level: env.get('LOG_LEVEL') || 'info',
|
||||
format: winston.format.combine(...winstonFormatters),
|
||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
||||
})
|
||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
let s3Client = undefined
|
||||
if (env.get('S3_AWS_REGION', true)) {
|
||||
s3Client = new S3Client({
|
||||
apiVersion: 'latest',
|
||||
region: env.get('S3_AWS_REGION', true),
|
||||
})
|
||||
}
|
||||
container.bind<S3Client | undefined>(TYPES.S3).toConstantValue(s3Client)
|
||||
|
||||
container.bind<TimerInterface>(TYPES.Timer).toConstantValue(new Timer())
|
||||
|
||||
container
|
||||
.bind<GetRequiredRoleToViewRevision>(TYPES.GetRequiredRoleToViewRevision)
|
||||
.toConstantValue(new GetRequiredRoleToViewRevision(container.get(TYPES.Timer)))
|
||||
|
||||
// Map
|
||||
container
|
||||
.bind<MapperInterface<RevisionMetadata, TypeORMRevision>>(TYPES.RevisionMetadataPersistenceMapper)
|
||||
.toConstantValue(new RevisionMetadataPersistenceMapper())
|
||||
container
|
||||
.bind<MapperInterface<Revision, TypeORMRevision>>(TYPES.RevisionPersistenceMapper)
|
||||
.toConstantValue(new RevisionPersistenceMapper())
|
||||
container
|
||||
.bind<MapperInterface<Revision, string>>(TYPES.RevisionItemStringMapper)
|
||||
.toConstantValue(new RevisionItemStringMapper())
|
||||
container
|
||||
.bind<
|
||||
MapperInterface<
|
||||
Revision,
|
||||
{
|
||||
uuid: string
|
||||
item_uuid: string
|
||||
content: string | null
|
||||
content_type: string
|
||||
items_key_id: string | null
|
||||
enc_item_key: string | null
|
||||
auth_hash: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
>
|
||||
>(TYPES.RevisionHttpMapper)
|
||||
.toConstantValue(new RevisionHttpMapper())
|
||||
container
|
||||
.bind<
|
||||
MapperInterface<
|
||||
RevisionMetadata,
|
||||
{
|
||||
uuid: string
|
||||
content_type: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
>
|
||||
>(TYPES.RevisionMetadataHttpMapper)
|
||||
.toConstantValue(new RevisionMetadataHttpMapper(container.get(TYPES.GetRequiredRoleToViewRevision)))
|
||||
|
||||
// ORM
|
||||
container
|
||||
.bind<Repository<TypeORMRevision>>(TYPES.ORMRevisionRepository)
|
||||
.toConstantValue(AppDataSource.getRepository(TypeORMRevision))
|
||||
|
||||
// env vars
|
||||
container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL'))
|
||||
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))
|
||||
container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true))
|
||||
container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION'))
|
||||
|
||||
// Repositories
|
||||
container
|
||||
.bind<RevisionRepositoryInterface>(TYPES.RevisionRepository)
|
||||
.toConstantValue(
|
||||
new MySQLRevisionRepository(
|
||||
container.get(TYPES.ORMRevisionRepository),
|
||||
container.get(TYPES.RevisionMetadataPersistenceMapper),
|
||||
container.get(TYPES.RevisionPersistenceMapper),
|
||||
container.get(TYPES.Logger),
|
||||
),
|
||||
)
|
||||
if (env.get('S3_AWS_REGION', true)) {
|
||||
container
|
||||
.bind<DumpRepositoryInterface>(TYPES.DumpRepository)
|
||||
.toConstantValue(
|
||||
new S3DumpRepository(
|
||||
container.get(TYPES.S3_BACKUP_BUCKET_NAME),
|
||||
container.get(TYPES.S3),
|
||||
container.get(TYPES.RevisionItemStringMapper),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
container
|
||||
.bind<DumpRepositoryInterface>(TYPES.DumpRepository)
|
||||
.toConstantValue(new FSDumpRepository(container.get(TYPES.RevisionItemStringMapper)))
|
||||
}
|
||||
|
||||
// use cases
|
||||
container
|
||||
.bind<GetRevisionsMetada>(TYPES.GetRevisionsMetada)
|
||||
.toConstantValue(new GetRevisionsMetada(container.get(TYPES.RevisionRepository)))
|
||||
container
|
||||
.bind<GetRevision>(TYPES.GetRevision)
|
||||
.toConstantValue(new GetRevision(container.get(TYPES.RevisionRepository)))
|
||||
container
|
||||
.bind<DeleteRevision>(TYPES.DeleteRevision)
|
||||
.toConstantValue(new DeleteRevision(container.get(TYPES.RevisionRepository)))
|
||||
container
|
||||
.bind<CopyRevisions>(TYPES.CopyRevisions)
|
||||
.toConstantValue(new CopyRevisions(container.get(TYPES.RevisionRepository)))
|
||||
|
||||
// Controller
|
||||
container
|
||||
.bind<RevisionsController>(TYPES.RevisionsController)
|
||||
.toConstantValue(
|
||||
new RevisionsController(
|
||||
container.get(TYPES.GetRevisionsMetada),
|
||||
container.get(TYPES.GetRevision),
|
||||
container.get(TYPES.DeleteRevision),
|
||||
container.get(TYPES.RevisionHttpMapper),
|
||||
container.get(TYPES.RevisionMetadataHttpMapper),
|
||||
container.get(TYPES.Logger),
|
||||
),
|
||||
)
|
||||
|
||||
// Handlers
|
||||
container
|
||||
.bind<ItemDumpedEventHandler>(TYPES.ItemDumpedEventHandler)
|
||||
.toConstantValue(
|
||||
new ItemDumpedEventHandler(container.get(TYPES.DumpRepository), container.get(TYPES.RevisionRepository)),
|
||||
)
|
||||
container
|
||||
.bind<AccountDeletionRequestedEventHandler>(TYPES.AccountDeletionRequestedEventHandler)
|
||||
.toConstantValue(
|
||||
new AccountDeletionRequestedEventHandler(container.get(TYPES.RevisionRepository), container.get(TYPES.Logger)),
|
||||
)
|
||||
container
|
||||
.bind<RevisionsCopyRequestedEventHandler>(TYPES.RevisionsCopyRequestedEventHandler)
|
||||
.toConstantValue(
|
||||
new RevisionsCopyRequestedEventHandler(container.get(TYPES.CopyRevisions), container.get(TYPES.Logger)),
|
||||
)
|
||||
container
|
||||
.bind<RevisionsOwnershipUpdateRequestedEventHandler>(TYPES.RevisionsOwnershipUpdateRequestedEventHandler)
|
||||
.toConstantValue(new RevisionsOwnershipUpdateRequestedEventHandler(container.get(TYPES.RevisionRepository)))
|
||||
|
||||
// Services
|
||||
container
|
||||
.bind<TokenDecoderInterface<CrossServiceTokenData>>(TYPES.CrossServiceTokenDecoder)
|
||||
.toConstantValue(new TokenDecoder<CrossServiceTokenData>(container.get(TYPES.AUTH_JWT_SECRET)))
|
||||
|
||||
// Middleware
|
||||
container
|
||||
.bind<InversifyExpressApiGatewayAuthMiddleware>(TYPES.ApiGatewayAuthMiddleware)
|
||||
.to(InversifyExpressApiGatewayAuthMiddleware)
|
||||
|
||||
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
|
||||
['ITEM_DUMPED', container.get(TYPES.ItemDumpedEventHandler)],
|
||||
['ACCOUNT_DELETION_REQUESTED', container.get(TYPES.AccountDeletionRequestedEventHandler)],
|
||||
['REVISIONS_COPY_REQUESTED', container.get(TYPES.RevisionsCopyRequestedEventHandler)],
|
||||
['REVISIONS_OWNERSHIP_UPDATE_REQUESTED', container.get(TYPES.RevisionsOwnershipUpdateRequestedEventHandler)],
|
||||
])
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
112
packages/revisions/src/Bootstrap/ServerContainerConfigLoader.ts
Normal file
112
packages/revisions/src/Bootstrap/ServerContainerConfigLoader.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
import { Timer, TimerInterface } from '@standardnotes/time'
|
||||
import { Container, interfaces } from 'inversify'
|
||||
import { MapperInterface } from '@standardnotes/domain-core'
|
||||
|
||||
import TYPES from './Types'
|
||||
import { RevisionsController } from '../Controller/RevisionsController'
|
||||
import { GetRevisionsMetada } from '../Domain/UseCase/GetRevisionsMetada/GetRevisionsMetada'
|
||||
import { RevisionMetadata } from '../Domain/Revision/RevisionMetadata'
|
||||
import { Revision } from '../Domain/Revision/Revision'
|
||||
import { GetRevision } from '../Domain/UseCase/GetRevision/GetRevision'
|
||||
import { DeleteRevision } from '../Domain/UseCase/DeleteRevision/DeleteRevision'
|
||||
import { RevisionHttpMapper } from '../Mapping/RevisionHttpMapper'
|
||||
import { RevisionMetadataHttpMapper } from '../Mapping/RevisionMetadataHttpMapper'
|
||||
import { GetRequiredRoleToViewRevision } from '../Domain/UseCase/GetRequiredRoleToViewRevision/GetRequiredRoleToViewRevision'
|
||||
import { CommonContainerConfigLoader } from './CommonContainerConfigLoader'
|
||||
import { ApiGatewayAuthMiddleware } from '../Controller/ApiGatewayAuthMiddleware'
|
||||
import { CrossServiceTokenData, TokenDecoder, TokenDecoderInterface } from '@standardnotes/security'
|
||||
import { Env } from './Env'
|
||||
|
||||
export class ServerContainerConfigLoader extends CommonContainerConfigLoader {
|
||||
override async load(): Promise<Container> {
|
||||
const container = await super.load()
|
||||
|
||||
const env: Env = container.get(TYPES.Env)
|
||||
|
||||
container.bind<TimerInterface>(TYPES.Timer).toDynamicValue(() => new Timer())
|
||||
|
||||
container
|
||||
.bind<GetRequiredRoleToViewRevision>(TYPES.GetRequiredRoleToViewRevision)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
return new GetRequiredRoleToViewRevision(context.container.get(TYPES.Timer))
|
||||
})
|
||||
|
||||
// Map
|
||||
container
|
||||
.bind<
|
||||
MapperInterface<
|
||||
Revision,
|
||||
{
|
||||
uuid: string
|
||||
item_uuid: string
|
||||
content: string | null
|
||||
content_type: string
|
||||
items_key_id: string | null
|
||||
enc_item_key: string | null
|
||||
auth_hash: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
>
|
||||
>(TYPES.RevisionHttpMapper)
|
||||
.toDynamicValue(() => new RevisionHttpMapper())
|
||||
container
|
||||
.bind<
|
||||
MapperInterface<
|
||||
RevisionMetadata,
|
||||
{
|
||||
uuid: string
|
||||
content_type: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
>
|
||||
>(TYPES.RevisionMetadataHttpMapper)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
return new RevisionMetadataHttpMapper(context.container.get(TYPES.GetRequiredRoleToViewRevision))
|
||||
})
|
||||
|
||||
// use cases
|
||||
container.bind<GetRevisionsMetada>(TYPES.GetRevisionsMetada).toDynamicValue((context: interfaces.Context) => {
|
||||
return new GetRevisionsMetada(context.container.get(TYPES.RevisionRepository))
|
||||
})
|
||||
container.bind<GetRevision>(TYPES.GetRevision).toDynamicValue((context: interfaces.Context) => {
|
||||
return new GetRevision(context.container.get(TYPES.RevisionRepository))
|
||||
})
|
||||
container.bind<DeleteRevision>(TYPES.DeleteRevision).toDynamicValue((context: interfaces.Context) => {
|
||||
return new DeleteRevision(context.container.get(TYPES.RevisionRepository))
|
||||
})
|
||||
|
||||
// env vars
|
||||
container.bind(TYPES.AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET'))
|
||||
|
||||
// Controller
|
||||
container.bind<RevisionsController>(TYPES.RevisionsController).toDynamicValue((context: interfaces.Context) => {
|
||||
return new RevisionsController(
|
||||
context.container.get(TYPES.GetRevisionsMetada),
|
||||
context.container.get(TYPES.GetRevision),
|
||||
context.container.get(TYPES.DeleteRevision),
|
||||
context.container.get(TYPES.RevisionHttpMapper),
|
||||
context.container.get(TYPES.RevisionMetadataHttpMapper),
|
||||
context.container.get(TYPES.Logger),
|
||||
)
|
||||
})
|
||||
|
||||
container
|
||||
.bind<TokenDecoderInterface<CrossServiceTokenData>>(TYPES.CrossServiceTokenDecoder)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
return new TokenDecoder<CrossServiceTokenData>(context.container.get(TYPES.AUTH_JWT_SECRET))
|
||||
})
|
||||
|
||||
container
|
||||
.bind<ApiGatewayAuthMiddleware>(TYPES.ApiGatewayAuthMiddleware)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
return new ApiGatewayAuthMiddleware(
|
||||
context.container.get(TYPES.CrossServiceTokenDecoder),
|
||||
context.container.get(TYPES.Logger),
|
||||
)
|
||||
})
|
||||
|
||||
return container
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
const TYPES = {
|
||||
DBConnection: Symbol.for('DBConnection'),
|
||||
Logger: Symbol.for('Logger'),
|
||||
Redis: Symbol.for('Redis'),
|
||||
SQS: Symbol.for('SQS'),
|
||||
S3: Symbol.for('S3'),
|
||||
Env: Symbol.for('Env'),
|
||||
// Map
|
||||
RevisionMetadataPersistenceMapper: Symbol.for('RevisionMetadataPersistenceMapper'),
|
||||
RevisionPersistenceMapper: Symbol.for('RevisionPersistenceMapper'),
|
||||
@@ -16,10 +16,9 @@ const TYPES = {
|
||||
RevisionRepository: Symbol.for('RevisionRepository'),
|
||||
DumpRepository: Symbol.for('DumpRepository'),
|
||||
// env vars
|
||||
REDIS_URL: Symbol.for('REDIS_URL'),
|
||||
AUTH_JWT_SECRET: Symbol.for('AUTH_JWT_SECRET'),
|
||||
SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'),
|
||||
SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'),
|
||||
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'),
|
||||
NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'),
|
||||
@@ -32,6 +31,7 @@ const TYPES = {
|
||||
GetRequiredRoleToViewRevision: Symbol.for('GetRequiredRoleToViewRevision'),
|
||||
// Controller
|
||||
RevisionsController: Symbol.for('RevisionsController'),
|
||||
ApiGatewayAuthMiddleware: Symbol.for('ApiGatewayAuthMiddleware'),
|
||||
// Handlers
|
||||
ItemDumpedEventHandler: Symbol.for('ItemDumpedEventHandler'),
|
||||
AccountDeletionRequestedEventHandler: Symbol.for('AccountDeletionRequestedEventHandler'),
|
||||
@@ -42,8 +42,6 @@ const TYPES = {
|
||||
DomainEventSubscriberFactory: Symbol.for('DomainEventSubscriberFactory'),
|
||||
DomainEventMessageHandler: Symbol.for('DomainEventMessageHandler'),
|
||||
Timer: Symbol.for('Timer'),
|
||||
// Middleware
|
||||
ApiGatewayAuthMiddleware: Symbol.for('ApiGatewayAuthMiddleware'),
|
||||
}
|
||||
|
||||
export default TYPES
|
||||
|
||||
164
packages/revisions/src/Bootstrap/WorkerContainerConfigLoader.ts
Normal file
164
packages/revisions/src/Bootstrap/WorkerContainerConfigLoader.ts
Normal file
@@ -0,0 +1,164 @@
|
||||
import { SQSClient, SQSClientConfig } from '@aws-sdk/client-sqs'
|
||||
import { S3Client } from '@aws-sdk/client-s3'
|
||||
import { Container, interfaces } from 'inversify'
|
||||
import {
|
||||
DomainEventHandlerInterface,
|
||||
DomainEventMessageHandlerInterface,
|
||||
DomainEventSubscriberFactoryInterface,
|
||||
} from '@standardnotes/domain-events'
|
||||
import {
|
||||
SQSDomainEventSubscriberFactory,
|
||||
SQSEventMessageHandler,
|
||||
SQSNewRelicEventMessageHandler,
|
||||
} from '@standardnotes/domain-events-infra'
|
||||
import { MapperInterface } from '@standardnotes/domain-core'
|
||||
|
||||
import TYPES from './Types'
|
||||
import { Revision } from '../Domain/Revision/Revision'
|
||||
import { RevisionItemStringMapper } from '../Mapping/RevisionItemStringMapper'
|
||||
import { ItemDumpedEventHandler } from '../Domain/Handler/ItemDumpedEventHandler'
|
||||
import { DumpRepositoryInterface } from '../Domain/Dump/DumpRepositoryInterface'
|
||||
import { S3DumpRepository } from '../Infra/S3/S3ItemDumpRepository'
|
||||
import { FSDumpRepository } from '../Infra/FS/FSDumpRepository'
|
||||
import { AccountDeletionRequestedEventHandler } from '../Domain/Handler/AccountDeletionRequestedEventHandler'
|
||||
import { RevisionsCopyRequestedEventHandler } from '../Domain/Handler/RevisionsCopyRequestedEventHandler'
|
||||
import { CopyRevisions } from '../Domain/UseCase/CopyRevisions/CopyRevisions'
|
||||
import { RevisionsOwnershipUpdateRequestedEventHandler } from '../Domain/Handler/RevisionsOwnershipUpdateRequestedEventHandler'
|
||||
import { CommonContainerConfigLoader } from './CommonContainerConfigLoader'
|
||||
import { Env } from './Env'
|
||||
|
||||
export class WorkerContainerConfigLoader extends CommonContainerConfigLoader {
|
||||
override async load(): Promise<Container> {
|
||||
const container = await super.load()
|
||||
|
||||
const env: Env = container.get(TYPES.Env)
|
||||
|
||||
container.bind<SQSClient>(TYPES.SQS).toDynamicValue((context: interfaces.Context) => {
|
||||
const env: Env = context.container.get(TYPES.Env)
|
||||
|
||||
const sqsConfig: SQSClientConfig = {
|
||||
region: env.get('SQS_AWS_REGION'),
|
||||
}
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
return new SQSClient(sqsConfig)
|
||||
})
|
||||
|
||||
container.bind<S3Client | undefined>(TYPES.S3).toDynamicValue((context: interfaces.Context) => {
|
||||
const env: Env = context.container.get(TYPES.Env)
|
||||
|
||||
let s3Client = undefined
|
||||
if (env.get('S3_AWS_REGION', true)) {
|
||||
s3Client = new S3Client({
|
||||
apiVersion: 'latest',
|
||||
region: env.get('S3_AWS_REGION', true),
|
||||
})
|
||||
}
|
||||
|
||||
return s3Client
|
||||
})
|
||||
|
||||
// Map
|
||||
container
|
||||
.bind<MapperInterface<Revision, string>>(TYPES.RevisionItemStringMapper)
|
||||
.toDynamicValue(() => new RevisionItemStringMapper())
|
||||
|
||||
// env vars
|
||||
container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
|
||||
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))
|
||||
|
||||
container.bind<DumpRepositoryInterface>(TYPES.DumpRepository).toDynamicValue((context: interfaces.Context) => {
|
||||
const env: Env = context.container.get(TYPES.Env)
|
||||
|
||||
if (env.get('S3_AWS_REGION', true)) {
|
||||
return new S3DumpRepository(
|
||||
context.container.get(TYPES.S3_BACKUP_BUCKET_NAME),
|
||||
context.container.get(TYPES.S3),
|
||||
context.container.get(TYPES.RevisionItemStringMapper),
|
||||
)
|
||||
} else {
|
||||
return new FSDumpRepository(context.container.get(TYPES.RevisionItemStringMapper))
|
||||
}
|
||||
})
|
||||
|
||||
// use cases
|
||||
container.bind<CopyRevisions>(TYPES.CopyRevisions).toDynamicValue((context: interfaces.Context) => {
|
||||
return new CopyRevisions(context.container.get(TYPES.RevisionRepository))
|
||||
})
|
||||
|
||||
// Handlers
|
||||
container
|
||||
.bind<ItemDumpedEventHandler>(TYPES.ItemDumpedEventHandler)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
return new ItemDumpedEventHandler(
|
||||
context.container.get(TYPES.DumpRepository),
|
||||
context.container.get(TYPES.RevisionRepository),
|
||||
)
|
||||
})
|
||||
container
|
||||
.bind<AccountDeletionRequestedEventHandler>(TYPES.AccountDeletionRequestedEventHandler)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
return new AccountDeletionRequestedEventHandler(
|
||||
context.container.get(TYPES.RevisionRepository),
|
||||
context.container.get(TYPES.Logger),
|
||||
)
|
||||
})
|
||||
container
|
||||
.bind<RevisionsCopyRequestedEventHandler>(TYPES.RevisionsCopyRequestedEventHandler)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
return new RevisionsCopyRequestedEventHandler(
|
||||
context.container.get(TYPES.CopyRevisions),
|
||||
context.container.get(TYPES.Logger),
|
||||
)
|
||||
})
|
||||
container
|
||||
.bind<RevisionsOwnershipUpdateRequestedEventHandler>(TYPES.RevisionsOwnershipUpdateRequestedEventHandler)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
return new RevisionsOwnershipUpdateRequestedEventHandler(context.container.get(TYPES.RevisionRepository))
|
||||
})
|
||||
|
||||
container
|
||||
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
const env: Env = context.container.get(TYPES.Env)
|
||||
|
||||
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
|
||||
['ITEM_DUMPED', context.container.get(TYPES.ItemDumpedEventHandler)],
|
||||
['ACCOUNT_DELETION_REQUESTED', context.container.get(TYPES.AccountDeletionRequestedEventHandler)],
|
||||
['REVISIONS_COPY_REQUESTED', context.container.get(TYPES.RevisionsCopyRequestedEventHandler)],
|
||||
[
|
||||
'REVISIONS_OWNERSHIP_UPDATE_REQUESTED',
|
||||
context.container.get(TYPES.RevisionsOwnershipUpdateRequestedEventHandler),
|
||||
],
|
||||
])
|
||||
|
||||
const handler =
|
||||
env.get('NEW_RELIC_ENABLED', true) === 'true'
|
||||
? new SQSNewRelicEventMessageHandler(eventHandlers, context.container.get(TYPES.Logger))
|
||||
: new SQSEventMessageHandler(eventHandlers, context.container.get(TYPES.Logger))
|
||||
|
||||
return handler
|
||||
})
|
||||
|
||||
container
|
||||
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
|
||||
.toDynamicValue((context: interfaces.Context) => {
|
||||
return new SQSDomainEventSubscriberFactory(
|
||||
context.container.get(TYPES.SQS),
|
||||
context.container.get(TYPES.SQS_QUEUE_URL),
|
||||
context.container.get(TYPES.DomainEventMessageHandler),
|
||||
)
|
||||
})
|
||||
|
||||
return container
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,10 @@
|
||||
import { CrossServiceTokenData, TokenDecoderInterface } from '@standardnotes/security'
|
||||
import { NextFunction, Request, Response } from 'express'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { BaseMiddleware } from 'inversify-express-utils'
|
||||
import { Logger } from 'winston'
|
||||
|
||||
import TYPES from '../../Bootstrap/Types'
|
||||
|
||||
@injectable()
|
||||
export class InversifyExpressApiGatewayAuthMiddleware extends BaseMiddleware {
|
||||
constructor(
|
||||
@inject(TYPES.CrossServiceTokenDecoder) private tokenDecoder: TokenDecoderInterface<CrossServiceTokenData>,
|
||||
@inject(TYPES.Logger) private logger: Logger,
|
||||
) {
|
||||
export class ApiGatewayAuthMiddleware extends BaseMiddleware {
|
||||
constructor(private tokenDecoder: TokenDecoderInterface<CrossServiceTokenData>, private logger: Logger) {
|
||||
super()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { controller, httpGet } from 'inversify-express-utils'
|
||||
import { BaseHttpController, controller, httpGet } from 'inversify-express-utils'
|
||||
|
||||
@controller('/healthcheck')
|
||||
export class InversifyExpressHealthCheckController {
|
||||
export class InversifyExpressHealthCheckController extends BaseHttpController {
|
||||
@httpGet('/')
|
||||
public async get(): Promise<string> {
|
||||
return 'OK'
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user