mirror of
https://github.com/standardnotes/server
synced 2026-05-10 00:57:19 -04:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3164f76662 | |||
| d6e531d4b6 | |||
| af76878dad | |||
| 28cce39fe7 | |||
| a8b806af08 | |||
| fa0b0294b4 | |||
| 58ab410b0a | |||
| 51c8b20506 | |||
| 1e62a3760e | |||
| 2f569d4104 | |||
| f23e444ed0 | |||
| e6e9a32f03 | |||
| 8237df33a7 | |||
| 624b574013 |
@@ -54,6 +54,11 @@ jobs:
|
|||||||
|
|
||||||
e2e-home-server:
|
e2e-home-server:
|
||||||
name: (Home Server) E2E Test Suite
|
name: (Home Server) E2E Test Suite
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
db_type: [mysql, sqlite]
|
||||||
|
cache_type: [redis, memory]
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
services:
|
services:
|
||||||
@@ -61,6 +66,19 @@ jobs:
|
|||||||
image: standardnotes/snjs:${{ inputs.snjs_image_tag }}
|
image: standardnotes/snjs:${{ inputs.snjs_image_tag }}
|
||||||
ports:
|
ports:
|
||||||
- 9001:9001
|
- 9001:9001
|
||||||
|
cache:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- 6379:6379
|
||||||
|
db:
|
||||||
|
image: mysql
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
env:
|
||||||
|
MYSQL_ROOT_PASSWORD: root
|
||||||
|
MYSQL_DATABASE: standardnotes
|
||||||
|
MYSQL_USER: standardnotes
|
||||||
|
MYSQL_PASSWORD: standardnotes
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -90,6 +108,13 @@ jobs:
|
|||||||
echo "ACCESS_TOKEN_AGE=4" >> packages/home-server/.env
|
echo "ACCESS_TOKEN_AGE=4" >> packages/home-server/.env
|
||||||
echo "REFRESH_TOKEN_AGE=7" >> packages/home-server/.env
|
echo "REFRESH_TOKEN_AGE=7" >> packages/home-server/.env
|
||||||
echo "REVISIONS_FREQUENCY=5" >> packages/home-server/.env
|
echo "REVISIONS_FREQUENCY=5" >> packages/home-server/.env
|
||||||
|
echo "DB_HOST=db" >> packages/home-server/.env
|
||||||
|
echo "DB_PORT=3306" >> packages/home-server/.env
|
||||||
|
echo "DB_USERNAME=standardnotes" >> packages/home-server/.env
|
||||||
|
echo "DB_PASSWORD=standardnotes" >> packages/home-server/.env
|
||||||
|
echo "DB_TYPE=${{ matrix.db_type }}" >> packages/home-server/.env
|
||||||
|
echo "REDIS_URL=redis://cache" >> packages/home-server/.env
|
||||||
|
echo "CACHE_TYPE=${{ matrix.cache_type }}" >> packages/home-server/.env
|
||||||
|
|
||||||
- name: Run Server
|
- name: Run Server
|
||||||
run: nohup yarn workspace @standardnotes/home-server start &
|
run: nohup yarn workspace @standardnotes/home-server start &
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [2.24.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.0...@standardnotes/analytics@2.24.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/server/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
# [2.24.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.23.7...@standardnotes/analytics@2.24.0) (2023-06-02)
|
# [2.24.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.23.7...@standardnotes/analytics@2.24.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/analytics",
|
"name": "@standardnotes/analytics",
|
||||||
"version": "2.24.0",
|
"version": "2.24.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -88,9 +88,9 @@ export class ContainerConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(...winstonFormatters),
|
format: winston.format.combine(...winstonFormatters),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
})
|
})
|
||||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
MODE=microservice # microservice | home-server
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VERSION=development
|
VERSION=development
|
||||||
|
|||||||
@@ -3,6 +3,24 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [1.64.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.63.2...@standardnotes/api-gateway@1.64.0) (2023-06-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **home-server:** allow running the home server with a mysql and redis configuration ([#622](https://github.com/standardnotes/api-gateway/issues/622)) ([d6e531d](https://github.com/standardnotes/api-gateway/commit/d6e531d4b6c1c80a894f6d7ec93632595268dd64))
|
||||||
|
|
||||||
|
## [1.63.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.63.1...@standardnotes/api-gateway@1.63.2) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/api-gateway/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
|
## [1.63.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.63.0...@standardnotes/api-gateway@1.63.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** add default for VERSION environment variable ([2f569d4](https://github.com/standardnotes/api-gateway/commit/2f569d41047a802eb72ef1a3618ffe4df28a709c))
|
||||||
|
|
||||||
# [1.63.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.62.4...@standardnotes/api-gateway@1.63.0) (2023-06-02)
|
# [1.63.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.62.4...@standardnotes/api-gateway@1.63.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/api-gateway",
|
"name": "@standardnotes/api-gateway",
|
||||||
"version": "1.63.0",
|
"version": "1.64.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ export class ContainerConfigLoader {
|
|||||||
|
|
||||||
const container = new Container()
|
const container = new Container()
|
||||||
|
|
||||||
const isConfiguredForHomeServer = env.get('CACHE_TYPE') === 'memory'
|
const isConfiguredForHomeServer = env.get('MODE', true) === 'home-server'
|
||||||
|
const isConfiguredForInMemoryCache = env.get('CACHE_TYPE', true) === 'memory'
|
||||||
|
|
||||||
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
||||||
if (env.get('NEW_RELIC_ENABLED', true) === 'true') {
|
if (env.get('NEW_RELIC_ENABLED', true) === 'true') {
|
||||||
@@ -49,15 +50,15 @@ export class ContainerConfigLoader {
|
|||||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(configuration.logger as winston.Logger)
|
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(configuration.logger as winston.Logger)
|
||||||
} else {
|
} else {
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(...winstonFormatters),
|
format: winston.format.combine(...winstonFormatters),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
defaultMeta: { service: 'api-gateway' },
|
defaultMeta: { service: 'api-gateway' },
|
||||||
})
|
})
|
||||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isConfiguredForHomeServer) {
|
if (!isConfiguredForInMemoryCache) {
|
||||||
const redisUrl = env.get('REDIS_URL')
|
const redisUrl = env.get('REDIS_URL')
|
||||||
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
||||||
let redis
|
let redis
|
||||||
@@ -83,7 +84,7 @@ export class ContainerConfigLoader {
|
|||||||
container
|
container
|
||||||
.bind(TYPES.HTTP_CALL_TIMEOUT)
|
.bind(TYPES.HTTP_CALL_TIMEOUT)
|
||||||
.toConstantValue(env.get('HTTP_CALL_TIMEOUT', true) ? +env.get('HTTP_CALL_TIMEOUT', true) : 60_000)
|
.toConstantValue(env.get('HTTP_CALL_TIMEOUT', true) ? +env.get('HTTP_CALL_TIMEOUT', true) : 60_000)
|
||||||
container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION'))
|
container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION', true) ?? 'development')
|
||||||
container.bind(TYPES.CROSS_SERVICE_TOKEN_CACHE_TTL).toConstantValue(+env.get('CROSS_SERVICE_TOKEN_CACHE_TTL', true))
|
container.bind(TYPES.CROSS_SERVICE_TOKEN_CACHE_TTL).toConstantValue(+env.get('CROSS_SERVICE_TOKEN_CACHE_TTL', true))
|
||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
MODE=microservice # microservice | home-server
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VERSION=development
|
VERSION=development
|
||||||
@@ -20,8 +21,10 @@ DB_USERNAME=auth
|
|||||||
DB_PASSWORD=changeme123
|
DB_PASSWORD=changeme123
|
||||||
DB_DATABASE=auth
|
DB_DATABASE=auth
|
||||||
DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"
|
DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"
|
||||||
|
DB_TYPE=mysql
|
||||||
|
|
||||||
REDIS_URL=redis://cache
|
REDIS_URL=redis://cache
|
||||||
|
CACHE_TYPE=redis
|
||||||
|
|
||||||
DISABLE_USER_REGISTRATION=false
|
DISABLE_USER_REGISTRATION=false
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,24 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [1.117.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.116.2...@standardnotes/auth-server@1.117.0) (2023-06-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **home-server:** allow running the home server with a mysql and redis configuration ([#622](https://github.com/standardnotes/server/issues/622)) ([d6e531d](https://github.com/standardnotes/server/commit/d6e531d4b6c1c80a894f6d7ec93632595268dd64))
|
||||||
|
|
||||||
|
## [1.116.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.116.1...@standardnotes/auth-server@1.116.2) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/server/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
|
## [1.116.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.116.0...@standardnotes/auth-server@1.116.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* initializing data source with already configured environment ([624b574](https://github.com/standardnotes/server/commit/624b574013157e9e044d4a8ed53cadb7fcc567ae))
|
||||||
|
|
||||||
# [1.116.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.115.5...@standardnotes/auth-server@1.116.0) (2023-06-02)
|
# [1.116.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.115.5...@standardnotes/auth-server@1.116.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/auth-server",
|
"name": "@standardnotes/auth-server",
|
||||||
"version": "1.116.0",
|
"version": "1.117.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -267,11 +267,13 @@ export class ContainerConfigLoader {
|
|||||||
|
|
||||||
const container = new Container()
|
const container = new Container()
|
||||||
|
|
||||||
await AppDataSource.initialize()
|
const appDataSource = new AppDataSource(env)
|
||||||
|
await appDataSource.initialize()
|
||||||
|
|
||||||
const isConfiguredForHomeServer = env.get('DB_TYPE') === 'sqlite'
|
const isConfiguredForHomeServer = env.get('MODE', true) === 'home-server'
|
||||||
|
const isConfiguredForInMemoryCache = env.get('CACHE_TYPE', true) === 'memory'
|
||||||
|
|
||||||
if (!isConfiguredForHomeServer) {
|
if (!isConfiguredForInMemoryCache) {
|
||||||
const redisUrl = env.get('REDIS_URL')
|
const redisUrl = env.get('REDIS_URL')
|
||||||
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
||||||
let redis
|
let redis
|
||||||
@@ -297,9 +299,9 @@ export class ContainerConfigLoader {
|
|||||||
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(configuration.logger as winston.Logger)
|
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(configuration.logger as winston.Logger)
|
||||||
} else {
|
} else {
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(...winstonFormatters),
|
format: winston.format.combine(...winstonFormatters),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
defaultMeta: { service: 'auth' },
|
defaultMeta: { service: 'auth' },
|
||||||
})
|
})
|
||||||
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(logger)
|
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(logger)
|
||||||
@@ -359,42 +361,42 @@ export class ContainerConfigLoader {
|
|||||||
// ORM
|
// ORM
|
||||||
container
|
container
|
||||||
.bind<Repository<OfflineSetting>>(TYPES.Auth_ORMOfflineSettingRepository)
|
.bind<Repository<OfflineSetting>>(TYPES.Auth_ORMOfflineSettingRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(OfflineSetting))
|
.toConstantValue(appDataSource.getRepository(OfflineSetting))
|
||||||
container
|
container
|
||||||
.bind<Repository<OfflineUserSubscription>>(TYPES.Auth_ORMOfflineUserSubscriptionRepository)
|
.bind<Repository<OfflineUserSubscription>>(TYPES.Auth_ORMOfflineUserSubscriptionRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(OfflineUserSubscription))
|
.toConstantValue(appDataSource.getRepository(OfflineUserSubscription))
|
||||||
container
|
container
|
||||||
.bind<Repository<RevokedSession>>(TYPES.Auth_ORMRevokedSessionRepository)
|
.bind<Repository<RevokedSession>>(TYPES.Auth_ORMRevokedSessionRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(RevokedSession))
|
.toConstantValue(appDataSource.getRepository(RevokedSession))
|
||||||
container.bind<Repository<Role>>(TYPES.Auth_ORMRoleRepository).toConstantValue(AppDataSource.getRepository(Role))
|
container.bind<Repository<Role>>(TYPES.Auth_ORMRoleRepository).toConstantValue(appDataSource.getRepository(Role))
|
||||||
container
|
container
|
||||||
.bind<Repository<Session>>(TYPES.Auth_ORMSessionRepository)
|
.bind<Repository<Session>>(TYPES.Auth_ORMSessionRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(Session))
|
.toConstantValue(appDataSource.getRepository(Session))
|
||||||
container
|
container
|
||||||
.bind<Repository<Setting>>(TYPES.Auth_ORMSettingRepository)
|
.bind<Repository<Setting>>(TYPES.Auth_ORMSettingRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(Setting))
|
.toConstantValue(appDataSource.getRepository(Setting))
|
||||||
container
|
container
|
||||||
.bind<Repository<SharedSubscriptionInvitation>>(TYPES.Auth_ORMSharedSubscriptionInvitationRepository)
|
.bind<Repository<SharedSubscriptionInvitation>>(TYPES.Auth_ORMSharedSubscriptionInvitationRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(SharedSubscriptionInvitation))
|
.toConstantValue(appDataSource.getRepository(SharedSubscriptionInvitation))
|
||||||
container
|
container
|
||||||
.bind<Repository<SubscriptionSetting>>(TYPES.Auth_ORMSubscriptionSettingRepository)
|
.bind<Repository<SubscriptionSetting>>(TYPES.Auth_ORMSubscriptionSettingRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(SubscriptionSetting))
|
.toConstantValue(appDataSource.getRepository(SubscriptionSetting))
|
||||||
container.bind<Repository<User>>(TYPES.Auth_ORMUserRepository).toConstantValue(AppDataSource.getRepository(User))
|
container.bind<Repository<User>>(TYPES.Auth_ORMUserRepository).toConstantValue(appDataSource.getRepository(User))
|
||||||
container
|
container
|
||||||
.bind<Repository<UserSubscription>>(TYPES.Auth_ORMUserSubscriptionRepository)
|
.bind<Repository<UserSubscription>>(TYPES.Auth_ORMUserSubscriptionRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(UserSubscription))
|
.toConstantValue(appDataSource.getRepository(UserSubscription))
|
||||||
container
|
container
|
||||||
.bind<Repository<TypeORMSessionTrace>>(TYPES.Auth_ORMSessionTraceRepository)
|
.bind<Repository<TypeORMSessionTrace>>(TYPES.Auth_ORMSessionTraceRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(TypeORMSessionTrace))
|
.toConstantValue(appDataSource.getRepository(TypeORMSessionTrace))
|
||||||
container
|
container
|
||||||
.bind<Repository<TypeORMAuthenticator>>(TYPES.Auth_ORMAuthenticatorRepository)
|
.bind<Repository<TypeORMAuthenticator>>(TYPES.Auth_ORMAuthenticatorRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(TypeORMAuthenticator))
|
.toConstantValue(appDataSource.getRepository(TypeORMAuthenticator))
|
||||||
container
|
container
|
||||||
.bind<Repository<TypeORMAuthenticatorChallenge>>(TYPES.Auth_ORMAuthenticatorChallengeRepository)
|
.bind<Repository<TypeORMAuthenticatorChallenge>>(TYPES.Auth_ORMAuthenticatorChallengeRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(TypeORMAuthenticatorChallenge))
|
.toConstantValue(appDataSource.getRepository(TypeORMAuthenticatorChallenge))
|
||||||
container
|
container
|
||||||
.bind<Repository<TypeORMCacheEntry>>(TYPES.Auth_ORMCacheEntryRepository)
|
.bind<Repository<TypeORMCacheEntry>>(TYPES.Auth_ORMCacheEntryRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(TypeORMCacheEntry))
|
.toConstantValue(appDataSource.getRepository(TypeORMCacheEntry))
|
||||||
|
|
||||||
// Repositories
|
// Repositories
|
||||||
container.bind<SessionRepositoryInterface>(TYPES.Auth_SessionRepository).to(TypeORMSessionRepository)
|
container.bind<SessionRepositoryInterface>(TYPES.Auth_SessionRepository).to(TypeORMSessionRepository)
|
||||||
@@ -549,7 +551,16 @@ export class ContainerConfigLoader {
|
|||||||
.bind(TYPES.Auth_READONLY_USERS)
|
.bind(TYPES.Auth_READONLY_USERS)
|
||||||
.toConstantValue(env.get('READONLY_USERS', true) ? env.get('READONLY_USERS', true).split(',') : [])
|
.toConstantValue(env.get('READONLY_USERS', true) ? env.get('READONLY_USERS', true).split(',') : [])
|
||||||
|
|
||||||
if (isConfiguredForHomeServer) {
|
if (isConfiguredForInMemoryCache) {
|
||||||
|
container
|
||||||
|
.bind<PKCERepositoryInterface>(TYPES.Auth_PKCERepository)
|
||||||
|
.toConstantValue(
|
||||||
|
new TypeORMPKCERepository(
|
||||||
|
container.get(TYPES.Auth_CacheEntryRepository),
|
||||||
|
container.get(TYPES.Auth_Logger),
|
||||||
|
container.get(TYPES.Auth_Timer),
|
||||||
|
),
|
||||||
|
)
|
||||||
container
|
container
|
||||||
.bind<LockRepositoryInterface>(TYPES.Auth_LockRepository)
|
.bind<LockRepositoryInterface>(TYPES.Auth_LockRepository)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
@@ -577,15 +588,6 @@ export class ContainerConfigLoader {
|
|||||||
container.get(TYPES.Auth_Timer),
|
container.get(TYPES.Auth_Timer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
|
||||||
.bind<PKCERepositoryInterface>(TYPES.Auth_PKCERepository)
|
|
||||||
.toConstantValue(
|
|
||||||
new TypeORMPKCERepository(
|
|
||||||
container.get(TYPES.Auth_CacheEntryRepository),
|
|
||||||
container.get(TYPES.Auth_Logger),
|
|
||||||
container.get(TYPES.Auth_Timer),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
container
|
container
|
||||||
.bind<SubscriptionTokenRepositoryInterface>(TYPES.Auth_SubscriptionTokenRepository)
|
.bind<SubscriptionTokenRepositoryInterface>(TYPES.Auth_SubscriptionTokenRepository)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DataSource, LoggerOptions } from 'typeorm'
|
import { DataSource, EntityTarget, LoggerOptions, ObjectLiteral, Repository } from 'typeorm'
|
||||||
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions'
|
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions'
|
||||||
import { Permission } from '../Domain/Permission/Permission'
|
import { Permission } from '../Domain/Permission/Permission'
|
||||||
import { Role } from '../Domain/Role/Role'
|
import { Role } from '../Domain/Role/Role'
|
||||||
@@ -19,88 +19,102 @@ import { TypeORMSessionTrace } from '../Infra/TypeORM/TypeORMSessionTrace'
|
|||||||
import { Env } from './Env'
|
import { Env } from './Env'
|
||||||
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
|
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
|
||||||
|
|
||||||
const env: Env = new Env()
|
export class AppDataSource {
|
||||||
env.load()
|
private dataSource: DataSource | undefined
|
||||||
|
|
||||||
const isConfiguredForMySQL = env.get('DB_TYPE') === 'mysql'
|
constructor(private env: Env) {}
|
||||||
|
|
||||||
const maxQueryExecutionTime = env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity> {
|
||||||
? +env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
if (!this.dataSource) {
|
||||||
: 45_000
|
throw new Error('DataSource not initialized')
|
||||||
|
}
|
||||||
|
|
||||||
const commonDataSourceOptions = {
|
return this.dataSource.getRepository(target)
|
||||||
maxQueryExecutionTime,
|
}
|
||||||
entities: [
|
|
||||||
User,
|
async initialize(): Promise<void> {
|
||||||
UserSubscription,
|
this.env.load()
|
||||||
OfflineUserSubscription,
|
|
||||||
Session,
|
const isConfiguredForMySQL = this.env.get('DB_TYPE') === 'mysql'
|
||||||
RevokedSession,
|
|
||||||
Role,
|
const maxQueryExecutionTime = this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
||||||
Permission,
|
? +this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
||||||
Setting,
|
: 45_000
|
||||||
OfflineSetting,
|
|
||||||
SharedSubscriptionInvitation,
|
const commonDataSourceOptions = {
|
||||||
SubscriptionSetting,
|
maxQueryExecutionTime,
|
||||||
TypeORMSessionTrace,
|
entities: [
|
||||||
TypeORMAuthenticator,
|
User,
|
||||||
TypeORMAuthenticatorChallenge,
|
UserSubscription,
|
||||||
TypeORMEmergencyAccessInvitation,
|
OfflineUserSubscription,
|
||||||
TypeORMCacheEntry,
|
Session,
|
||||||
],
|
RevokedSession,
|
||||||
migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`],
|
Role,
|
||||||
migrationsRun: true,
|
Permission,
|
||||||
logging: <LoggerOptions>env.get('DB_DEBUG_LEVEL', true) ?? 'info',
|
Setting,
|
||||||
|
OfflineSetting,
|
||||||
|
SharedSubscriptionInvitation,
|
||||||
|
SubscriptionSetting,
|
||||||
|
TypeORMSessionTrace,
|
||||||
|
TypeORMAuthenticator,
|
||||||
|
TypeORMAuthenticatorChallenge,
|
||||||
|
TypeORMEmergencyAccessInvitation,
|
||||||
|
TypeORMCacheEntry,
|
||||||
|
],
|
||||||
|
migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`],
|
||||||
|
migrationsRun: true,
|
||||||
|
logging: <LoggerOptions>this.env.get('DB_DEBUG_LEVEL', true) ?? 'info',
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isConfiguredForMySQL) {
|
||||||
|
const inReplicaMode = this.env.get('DB_REPLICA_HOST', true) ? true : false
|
||||||
|
|
||||||
|
const replicationConfig = {
|
||||||
|
master: {
|
||||||
|
host: this.env.get('DB_HOST'),
|
||||||
|
port: parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: this.env.get('DB_USERNAME'),
|
||||||
|
password: this.env.get('DB_PASSWORD'),
|
||||||
|
database: this.env.get('DB_DATABASE'),
|
||||||
|
},
|
||||||
|
slaves: [
|
||||||
|
{
|
||||||
|
host: this.env.get('DB_REPLICA_HOST', true),
|
||||||
|
port: parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: this.env.get('DB_USERNAME'),
|
||||||
|
password: this.env.get('DB_PASSWORD'),
|
||||||
|
database: this.env.get('DB_DATABASE'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
removeNodeErrorCount: 10,
|
||||||
|
restoreNodeTimeout: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
const mySQLDataSourceOptions: MysqlConnectionOptions = {
|
||||||
|
...commonDataSourceOptions,
|
||||||
|
type: 'mysql',
|
||||||
|
charset: 'utf8mb4',
|
||||||
|
supportBigNumbers: true,
|
||||||
|
bigNumberStrings: false,
|
||||||
|
replication: inReplicaMode ? replicationConfig : undefined,
|
||||||
|
host: inReplicaMode ? undefined : this.env.get('DB_HOST'),
|
||||||
|
port: inReplicaMode ? undefined : parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: inReplicaMode ? undefined : this.env.get('DB_USERNAME'),
|
||||||
|
password: inReplicaMode ? undefined : this.env.get('DB_PASSWORD'),
|
||||||
|
database: inReplicaMode ? undefined : this.env.get('DB_DATABASE'),
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dataSource = new DataSource(mySQLDataSourceOptions)
|
||||||
|
} else {
|
||||||
|
const sqliteDataSourceOptions: SqliteConnectionOptions = {
|
||||||
|
...commonDataSourceOptions,
|
||||||
|
type: 'sqlite',
|
||||||
|
database: `data/${this.env.get('DB_DATABASE')}.sqlite`,
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dataSource = new DataSource(sqliteDataSourceOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.dataSource.initialize()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let dataSource: DataSource
|
|
||||||
if (isConfiguredForMySQL) {
|
|
||||||
const inReplicaMode = env.get('DB_REPLICA_HOST', true) ? true : false
|
|
||||||
|
|
||||||
const replicationConfig = {
|
|
||||||
master: {
|
|
||||||
host: env.get('DB_HOST'),
|
|
||||||
port: parseInt(env.get('DB_PORT')),
|
|
||||||
username: env.get('DB_USERNAME'),
|
|
||||||
password: env.get('DB_PASSWORD'),
|
|
||||||
database: env.get('DB_DATABASE'),
|
|
||||||
},
|
|
||||||
slaves: [
|
|
||||||
{
|
|
||||||
host: env.get('DB_REPLICA_HOST', true),
|
|
||||||
port: parseInt(env.get('DB_PORT')),
|
|
||||||
username: env.get('DB_USERNAME'),
|
|
||||||
password: env.get('DB_PASSWORD'),
|
|
||||||
database: env.get('DB_DATABASE'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
removeNodeErrorCount: 10,
|
|
||||||
restoreNodeTimeout: 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
const mySQLDataSourceOptions: MysqlConnectionOptions = {
|
|
||||||
...commonDataSourceOptions,
|
|
||||||
type: 'mysql',
|
|
||||||
charset: 'utf8mb4',
|
|
||||||
supportBigNumbers: true,
|
|
||||||
bigNumberStrings: false,
|
|
||||||
replication: inReplicaMode ? replicationConfig : undefined,
|
|
||||||
host: inReplicaMode ? undefined : env.get('DB_HOST'),
|
|
||||||
port: inReplicaMode ? undefined : parseInt(env.get('DB_PORT')),
|
|
||||||
username: inReplicaMode ? undefined : env.get('DB_USERNAME'),
|
|
||||||
password: inReplicaMode ? undefined : env.get('DB_PASSWORD'),
|
|
||||||
database: inReplicaMode ? undefined : env.get('DB_DATABASE'),
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSource = new DataSource(mySQLDataSourceOptions)
|
|
||||||
} else {
|
|
||||||
const sqliteDataSourceOptions: SqliteConnectionOptions = {
|
|
||||||
...commonDataSourceOptions,
|
|
||||||
type: 'sqlite',
|
|
||||||
database: `data/${env.get('DB_DATABASE')}.sqlite`,
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSource = new DataSource(sqliteDataSourceOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AppDataSource = dataSource
|
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.10.1](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.10.0...@standardnotes/event-store@1.10.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/server/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
# [1.10.0](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.9.6...@standardnotes/event-store@1.10.0) (2023-06-02)
|
# [1.10.0](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.9.6...@standardnotes/event-store@1.10.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/event-store",
|
"name": "@standardnotes/event-store",
|
||||||
"version": "1.10.0",
|
"version": "1.10.1",
|
||||||
"description": "Event Store Service",
|
"description": "Event Store Service",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "dist/src/index.js",
|
"main": "dist/src/index.js",
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ export class ContainerConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(winston.format.splat(), winston.format.json()),
|
format: winston.format.combine(winston.format.splat(), winston.format.json()),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
})
|
})
|
||||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
MODE=microservice # microservice | home-server
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VERSION=development
|
VERSION=development
|
||||||
|
|||||||
@@ -3,6 +3,18 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [1.18.0](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.17.1...@standardnotes/files-server@1.18.0) (2023-06-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **home-server:** allow running the home server with a mysql and redis configuration ([#622](https://github.com/standardnotes/files/issues/622)) ([d6e531d](https://github.com/standardnotes/files/commit/d6e531d4b6c1c80a894f6d7ec93632595268dd64))
|
||||||
|
|
||||||
|
## [1.17.1](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.17.0...@standardnotes/files-server@1.17.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/files/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
# [1.17.0](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.16.5...@standardnotes/files-server@1.17.0) (2023-06-02)
|
# [1.17.0](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.16.5...@standardnotes/files-server@1.17.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/files-server",
|
"name": "@standardnotes/files-server",
|
||||||
"version": "1.17.0",
|
"version": "1.18.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ export class ContainerConfigLoader {
|
|||||||
await import('newrelic')
|
await import('newrelic')
|
||||||
}
|
}
|
||||||
|
|
||||||
const isConfiguredForHomeServer = env.get('CACHE_TYPE') === 'memory'
|
const isConfiguredForHomeServer = env.get('MODE', true) === 'home-server'
|
||||||
|
const isConfiguredForInMemoryCache = env.get('CACHE_TYPE', true) === 'memory'
|
||||||
|
|
||||||
if (configuration?.logger) {
|
if (configuration?.logger) {
|
||||||
container.bind<winston.Logger>(TYPES.Files_Logger).toConstantValue(configuration.logger as winston.Logger)
|
container.bind<winston.Logger>(TYPES.Files_Logger).toConstantValue(configuration.logger as winston.Logger)
|
||||||
@@ -77,20 +78,11 @@ export class ContainerConfigLoader {
|
|||||||
|
|
||||||
container.bind<TimerInterface>(TYPES.Files_Timer).toConstantValue(new Timer())
|
container.bind<TimerInterface>(TYPES.Files_Timer).toConstantValue(new Timer())
|
||||||
|
|
||||||
if (isConfiguredForHomeServer) {
|
if (isConfiguredForInMemoryCache) {
|
||||||
container
|
container
|
||||||
.bind<UploadRepositoryInterface>(TYPES.Files_UploadRepository)
|
.bind<UploadRepositoryInterface>(TYPES.Files_UploadRepository)
|
||||||
.toConstantValue(new InMemoryUploadRepository(container.get(TYPES.Files_Timer)))
|
.toConstantValue(new InMemoryUploadRepository(container.get(TYPES.Files_Timer)))
|
||||||
|
|
||||||
container
|
|
||||||
.bind<DomainEventPublisherInterface>(TYPES.Files_DomainEventPublisher)
|
|
||||||
.toConstantValue(directCallDomainEventPublisher)
|
|
||||||
} else {
|
} else {
|
||||||
container.bind(TYPES.Files_S3_BUCKET_NAME).toConstantValue(env.get('S3_BUCKET_NAME', true))
|
|
||||||
container.bind(TYPES.Files_S3_AWS_REGION).toConstantValue(env.get('S3_AWS_REGION', true))
|
|
||||||
container.bind(TYPES.Files_SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN'))
|
|
||||||
container.bind(TYPES.Files_SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true))
|
|
||||||
container.bind(TYPES.Files_SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
|
|
||||||
container.bind(TYPES.Files_REDIS_URL).toConstantValue(env.get('REDIS_URL'))
|
container.bind(TYPES.Files_REDIS_URL).toConstantValue(env.get('REDIS_URL'))
|
||||||
|
|
||||||
const redisUrl = container.get(TYPES.Files_REDIS_URL) as string
|
const redisUrl = container.get(TYPES.Files_REDIS_URL) as string
|
||||||
@@ -104,6 +96,20 @@ export class ContainerConfigLoader {
|
|||||||
|
|
||||||
container.bind(TYPES.Files_Redis).toConstantValue(redis)
|
container.bind(TYPES.Files_Redis).toConstantValue(redis)
|
||||||
|
|
||||||
|
container.bind<UploadRepositoryInterface>(TYPES.Files_UploadRepository).to(RedisUploadRepository)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isConfiguredForHomeServer) {
|
||||||
|
container
|
||||||
|
.bind<DomainEventPublisherInterface>(TYPES.Files_DomainEventPublisher)
|
||||||
|
.toConstantValue(directCallDomainEventPublisher)
|
||||||
|
} else {
|
||||||
|
container.bind(TYPES.Files_S3_BUCKET_NAME).toConstantValue(env.get('S3_BUCKET_NAME', true))
|
||||||
|
container.bind(TYPES.Files_S3_AWS_REGION).toConstantValue(env.get('S3_AWS_REGION', true))
|
||||||
|
container.bind(TYPES.Files_SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN'))
|
||||||
|
container.bind(TYPES.Files_SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true))
|
||||||
|
container.bind(TYPES.Files_SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL'))
|
||||||
|
|
||||||
if (env.get('SNS_TOPIC_ARN', true)) {
|
if (env.get('SNS_TOPIC_ARN', true)) {
|
||||||
const snsConfig: SNSClientConfig = {
|
const snsConfig: SNSClientConfig = {
|
||||||
apiVersion: 'latest',
|
apiVersion: 'latest',
|
||||||
@@ -137,8 +143,6 @@ export class ContainerConfigLoader {
|
|||||||
container.bind<SQSClient>(TYPES.Files_SQS).toConstantValue(new SQSClient(sqsConfig))
|
container.bind<SQSClient>(TYPES.Files_SQS).toConstantValue(new SQSClient(sqsConfig))
|
||||||
}
|
}
|
||||||
|
|
||||||
container.bind<UploadRepositoryInterface>(TYPES.Files_UploadRepository).to(RedisUploadRepository)
|
|
||||||
|
|
||||||
container
|
container
|
||||||
.bind<DomainEventPublisherInterface>(TYPES.Files_DomainEventPublisher)
|
.bind<DomainEventPublisherInterface>(TYPES.Files_DomainEventPublisher)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
@@ -156,7 +160,7 @@ export class ContainerConfigLoader {
|
|||||||
.bind(TYPES.Files_FILE_UPLOAD_PATH)
|
.bind(TYPES.Files_FILE_UPLOAD_PATH)
|
||||||
.toConstantValue(env.get('FILE_UPLOAD_PATH', true) ?? `${__dirname}/../../uploads`)
|
.toConstantValue(env.get('FILE_UPLOAD_PATH', true) ?? `${__dirname}/../../uploads`)
|
||||||
|
|
||||||
if (env.get('S3_AWS_REGION', true) || env.get('S3_ENDPOINT', true)) {
|
if (!isConfiguredForHomeServer && (env.get('S3_AWS_REGION', true) || env.get('S3_ENDPOINT', true))) {
|
||||||
const s3Opts: S3ClientConfig = {
|
const s3Opts: S3ClientConfig = {
|
||||||
apiVersion: 'latest',
|
apiVersion: 'latest',
|
||||||
}
|
}
|
||||||
@@ -250,9 +254,9 @@ export class ContainerConfigLoader {
|
|||||||
|
|
||||||
createLogger({ env }: { env: Env }): winston.Logger {
|
createLogger({ env }: { env: Env }): winston.Logger {
|
||||||
return winston.createLogger({
|
return winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(winston.format.splat(), winston.format.json()),
|
format: winston.format.combine(winston.format.splat(), winston.format.json()),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
defaultMeta: { service: 'files' },
|
defaultMeta: { service: 'files' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,5 @@
|
|||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VERSION=development
|
|
||||||
|
|
||||||
# (Optional) New Relic Setup
|
|
||||||
NEW_RELIC_ENABLED=false
|
|
||||||
NEW_RELIC_APP_NAME="Home Server"
|
|
||||||
|
|
||||||
CACHE_TYPE=memory
|
|
||||||
|
|
||||||
DB_TYPE=sqlite
|
|
||||||
DB_DATABASE=home_server
|
|
||||||
|
|
||||||
JWT_SECRET=
|
JWT_SECRET=
|
||||||
AUTH_JWT_SECRET=
|
AUTH_JWT_SECRET=
|
||||||
|
|||||||
@@ -3,6 +3,42 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [1.9.0](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.8.5...@standardnotes/home-server@1.9.0) (2023-06-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **home-server:** allow running the home server with a mysql and redis configuration ([#622](https://github.com/standardnotes/server/issues/622)) ([d6e531d](https://github.com/standardnotes/server/commit/d6e531d4b6c1c80a894f6d7ec93632595268dd64))
|
||||||
|
|
||||||
|
## [1.8.5](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.8.4...@standardnotes/home-server@1.8.5) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** linter issues ([28cce39](https://github.com/standardnotes/server/commit/28cce39fe7a75fec035f920573271e1e56421818))
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/server/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
|
## [1.8.4](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.8.3...@standardnotes/home-server@1.8.4) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** remove redundant restart method ([58ab410](https://github.com/standardnotes/server/commit/58ab410b0afb1d811247cd65b2585d06f9c8807a))
|
||||||
|
|
||||||
|
## [1.8.3](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.8.2...@standardnotes/home-server@1.8.3) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** add default for VERSION environment variable ([2f569d4](https://github.com/standardnotes/server/commit/2f569d41047a802eb72ef1a3618ffe4df28a709c))
|
||||||
|
* **home-server:** displaying the port on which it is running ([1e62a37](https://github.com/standardnotes/server/commit/1e62a3760e3b9601478c851cf33db2f2b348d7fb))
|
||||||
|
|
||||||
|
## [1.8.2](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.8.1...@standardnotes/home-server@1.8.2) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** default configuration variables ([e6e9a32](https://github.com/standardnotes/server/commit/e6e9a32f0385789e5e772e5cabcc0da0b8ccbb01))
|
||||||
|
|
||||||
|
## [1.8.1](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.8.0...@standardnotes/home-server@1.8.1) (2023-06-02)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/home-server
|
||||||
|
|
||||||
# [1.8.0](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.7.5...@standardnotes/home-server@1.8.0) (2023-06-02)
|
# [1.8.0](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.7.5...@standardnotes/home-server@1.8.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -2,7 +2,16 @@ import { HomeServer } from '../src/Server/HomeServer'
|
|||||||
|
|
||||||
const homeServer = new HomeServer()
|
const homeServer = new HomeServer()
|
||||||
|
|
||||||
Promise.resolve(homeServer.start()).catch((error) => {
|
Promise.resolve(homeServer.start())
|
||||||
// eslint-disable-next-line no-console
|
.then(() => {
|
||||||
console.log(`Could not start server: ${error.message}`)
|
const logStream = homeServer.logs()
|
||||||
})
|
|
||||||
|
logStream.on('data', (chunk: Buffer) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(chunk.toString())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Could not start server: ${error.message}`)
|
||||||
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/home-server",
|
"name": "@standardnotes/home-server",
|
||||||
"version": "1.8.0",
|
"version": "1.9.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
"clean": "rm -fr dist",
|
"clean": "rm -fr dist",
|
||||||
"build": "tsc --build",
|
"build": "tsc --build",
|
||||||
"lint": "eslint . --ext .ts",
|
"lint": "eslint . --ext .ts",
|
||||||
|
"lint:fix": "eslint . --ext .ts --fix",
|
||||||
"start": "yarn node dist/bin/server.js"
|
"start": "yarn node dist/bin/server.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -24,13 +24,24 @@ import { HomeServerConfiguration } from './HomeServerConfiguration'
|
|||||||
|
|
||||||
export class HomeServer implements HomeServerInterface {
|
export class HomeServer implements HomeServerInterface {
|
||||||
private serverInstance: http.Server | undefined
|
private serverInstance: http.Server | undefined
|
||||||
|
private logStream: PassThrough = new PassThrough()
|
||||||
|
|
||||||
async start(configuration?: HomeServerConfiguration): Promise<void> {
|
async start(configuration?: HomeServerConfiguration): Promise<void> {
|
||||||
const controllerContainer = new ControllerContainer()
|
const controllerContainer = new ControllerContainer()
|
||||||
const serviceContainer = new ServiceContainer()
|
const serviceContainer = new ServiceContainer()
|
||||||
const directCallDomainEventPublisher = new DirectCallDomainEventPublisher()
|
const directCallDomainEventPublisher = new DirectCallDomainEventPublisher()
|
||||||
|
|
||||||
const env: Env = new Env(configuration?.environment)
|
const environmentOverrides = {
|
||||||
|
DB_TYPE: 'sqlite',
|
||||||
|
CACHE_TYPE: 'memory',
|
||||||
|
DB_DATABASE: 'home_server',
|
||||||
|
...configuration?.environment,
|
||||||
|
MODE: 'home-server',
|
||||||
|
NEW_RELIC_ENABLED: 'false',
|
||||||
|
NEW_RELIC_APP_NAME: 'Home Server',
|
||||||
|
}
|
||||||
|
|
||||||
|
const env: Env = new Env(environmentOverrides)
|
||||||
env.load()
|
env.load()
|
||||||
|
|
||||||
this.configureLoggers(env)
|
this.configureLoggers(env)
|
||||||
@@ -44,23 +55,23 @@ export class HomeServer implements HomeServerInterface {
|
|||||||
const container = Container.merge(
|
const container = Container.merge(
|
||||||
(await apiGatewayService.getContainer({
|
(await apiGatewayService.getContainer({
|
||||||
logger: winston.loggers.get('api-gateway'),
|
logger: winston.loggers.get('api-gateway'),
|
||||||
environmentOverrides: configuration?.environment,
|
environmentOverrides,
|
||||||
})) as Container,
|
})) as Container,
|
||||||
(await authService.getContainer({
|
(await authService.getContainer({
|
||||||
logger: winston.loggers.get('auth-server'),
|
logger: winston.loggers.get('auth-server'),
|
||||||
environmentOverrides: configuration?.environment,
|
environmentOverrides,
|
||||||
})) as Container,
|
})) as Container,
|
||||||
(await syncingService.getContainer({
|
(await syncingService.getContainer({
|
||||||
logger: winston.loggers.get('syncing-server'),
|
logger: winston.loggers.get('syncing-server'),
|
||||||
environmentOverrides: configuration?.environment,
|
environmentOverrides,
|
||||||
})) as Container,
|
})) as Container,
|
||||||
(await revisionsService.getContainer({
|
(await revisionsService.getContainer({
|
||||||
logger: winston.loggers.get('revisions-server'),
|
logger: winston.loggers.get('revisions-server'),
|
||||||
environmentOverrides: configuration?.environment,
|
environmentOverrides,
|
||||||
})) as Container,
|
})) as Container,
|
||||||
(await filesService.getContainer({
|
(await filesService.getContainer({
|
||||||
logger: winston.loggers.get('files-server'),
|
logger: winston.loggers.get('files-server'),
|
||||||
environmentOverrides: configuration?.environment,
|
environmentOverrides,
|
||||||
})) as Container,
|
})) as Container,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -119,9 +130,11 @@ export class HomeServer implements HomeServerInterface {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
this.serverInstance = server.build().listen(env.get('PORT', true) ? +env.get('PORT', true) : 3000)
|
const port = env.get('PORT', true) ? +env.get('PORT', true) : 3000
|
||||||
|
|
||||||
logger.info(`Server started on port ${process.env.PORT}`)
|
this.serverInstance = server.build().listen(port)
|
||||||
|
|
||||||
|
logger.info(`Server started on port ${port}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async stop(): Promise<void> {
|
async stop(): Promise<void> {
|
||||||
@@ -130,11 +143,6 @@ export class HomeServer implements HomeServerInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async restart(): Promise<void> {
|
|
||||||
await this.stop()
|
|
||||||
await this.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
async isRunning(): Promise<boolean> {
|
async isRunning(): Promise<boolean> {
|
||||||
if (!this.serverInstance) {
|
if (!this.serverInstance) {
|
||||||
return false
|
return false
|
||||||
@@ -144,18 +152,14 @@ export class HomeServer implements HomeServerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logs(): NodeJS.ReadableStream {
|
logs(): NodeJS.ReadableStream {
|
||||||
const passThroughStream = new PassThrough()
|
return this.logStream
|
||||||
|
|
||||||
for (const logger of winston.loggers.loggers.values()) {
|
|
||||||
logger.stream({ start: -1 }).pipe(passThroughStream, { end: false })
|
|
||||||
}
|
|
||||||
|
|
||||||
return passThroughStream
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private configureLoggers(env: Env): void {
|
private configureLoggers(env: Env): void {
|
||||||
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
||||||
|
|
||||||
|
const level = env.get('LOG_LEVEL', true) || 'info'
|
||||||
|
|
||||||
for (const loggerName of [
|
for (const loggerName of [
|
||||||
'auth-server',
|
'auth-server',
|
||||||
'syncing-server',
|
'syncing-server',
|
||||||
@@ -165,9 +169,14 @@ export class HomeServer implements HomeServerInterface {
|
|||||||
'home-server',
|
'home-server',
|
||||||
]) {
|
]) {
|
||||||
winston.loggers.add(loggerName, {
|
winston.loggers.add(loggerName, {
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level,
|
||||||
format: winston.format.combine(...winstonFormatters),
|
format: winston.format.combine(...winstonFormatters),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [
|
||||||
|
new winston.transports.Stream({
|
||||||
|
level,
|
||||||
|
stream: this.logStream,
|
||||||
|
}),
|
||||||
|
],
|
||||||
defaultMeta: { service: loggerName },
|
defaultMeta: { service: loggerName },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { HomeServerConfiguration } from './HomeServerConfiguration'
|
|||||||
export interface HomeServerInterface {
|
export interface HomeServerInterface {
|
||||||
start(configuration?: HomeServerConfiguration): Promise<void>
|
start(configuration?: HomeServerConfiguration): Promise<void>
|
||||||
stop(): Promise<void>
|
stop(): Promise<void>
|
||||||
restart(): Promise<void>
|
|
||||||
isRunning(): Promise<boolean>
|
isRunning(): Promise<boolean>
|
||||||
logs(): NodeJS.ReadableStream
|
logs(): NodeJS.ReadableStream
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
MODE=microservice # microservice | home-server
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VERSION=development
|
VERSION=development
|
||||||
@@ -14,8 +15,10 @@ DB_PASSWORD=revisionspassword
|
|||||||
DB_DATABASE=revisions
|
DB_DATABASE=revisions
|
||||||
DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"
|
DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"
|
||||||
DB_MIGRATIONS_PATH=dist/migrations/*.js
|
DB_MIGRATIONS_PATH=dist/migrations/*.js
|
||||||
|
DB_TYPE=mysql
|
||||||
|
|
||||||
REDIS_URL=redis://cache
|
REDIS_URL=redis://cache
|
||||||
|
CACHE_TYPE=redis
|
||||||
|
|
||||||
SQS_QUEUE_URL=
|
SQS_QUEUE_URL=
|
||||||
SQS_AWS_REGION=
|
SQS_AWS_REGION=
|
||||||
|
|||||||
@@ -3,6 +3,30 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [1.22.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.21.3...@standardnotes/revisions-server@1.22.0) (2023-06-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **home-server:** allow running the home server with a mysql and redis configuration ([#622](https://github.com/standardnotes/server/issues/622)) ([d6e531d](https://github.com/standardnotes/server/commit/d6e531d4b6c1c80a894f6d7ec93632595268dd64))
|
||||||
|
|
||||||
|
## [1.21.3](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.21.2...@standardnotes/revisions-server@1.21.3) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/server/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
|
## [1.21.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.21.1...@standardnotes/revisions-server@1.21.2) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** add default for VERSION environment variable ([2f569d4](https://github.com/standardnotes/server/commit/2f569d41047a802eb72ef1a3618ffe4df28a709c))
|
||||||
|
|
||||||
|
## [1.21.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.21.0...@standardnotes/revisions-server@1.21.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* initializing data source with already configured environment ([624b574](https://github.com/standardnotes/server/commit/624b574013157e9e044d4a8ed53cadb7fcc567ae))
|
||||||
|
|
||||||
# [1.21.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.20.4...@standardnotes/revisions-server@1.21.0) (2023-06-02)
|
# [1.21.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.20.4...@standardnotes/revisions-server@1.21.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/revisions-server",
|
"name": "@standardnotes/revisions-server",
|
||||||
"version": "1.21.0",
|
"version": "1.22.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -61,13 +61,14 @@ export class ContainerConfigLoader {
|
|||||||
const env: Env = new Env(configuration?.environmentOverrides)
|
const env: Env = new Env(configuration?.environmentOverrides)
|
||||||
env.load()
|
env.load()
|
||||||
|
|
||||||
const isConfiguredForHomeServer = env.get('DB_TYPE') === 'sqlite'
|
const isConfiguredForHomeServer = env.get('MODE', true) === 'home-server'
|
||||||
|
|
||||||
const container = new Container({
|
const container = new Container({
|
||||||
defaultScope: 'Singleton',
|
defaultScope: 'Singleton',
|
||||||
})
|
})
|
||||||
|
|
||||||
await AppDataSource.initialize()
|
const appDataSource = new AppDataSource(env)
|
||||||
|
await appDataSource.initialize()
|
||||||
|
|
||||||
container.bind<Env>(TYPES.Revisions_Env).toConstantValue(env)
|
container.bind<Env>(TYPES.Revisions_Env).toConstantValue(env)
|
||||||
|
|
||||||
@@ -84,9 +85,9 @@ export class ContainerConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(...winstonFormatters),
|
format: winston.format.combine(...winstonFormatters),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
defaultMeta: { service: 'revisions' },
|
defaultMeta: { service: 'revisions' },
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@ export class ContainerConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container.bind(TYPES.Revisions_NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true))
|
container.bind(TYPES.Revisions_NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true))
|
||||||
container.bind(TYPES.Revisions_VERSION).toConstantValue(env.get('VERSION'))
|
container.bind(TYPES.Revisions_VERSION).toConstantValue(env.get('VERSION', true) ?? 'development')
|
||||||
|
|
||||||
// Map
|
// Map
|
||||||
container
|
container
|
||||||
@@ -107,7 +108,7 @@ export class ContainerConfigLoader {
|
|||||||
// ORM
|
// ORM
|
||||||
container
|
container
|
||||||
.bind<Repository<TypeORMRevision>>(TYPES.Revisions_ORMRevisionRepository)
|
.bind<Repository<TypeORMRevision>>(TYPES.Revisions_ORMRevisionRepository)
|
||||||
.toDynamicValue(() => AppDataSource.getRepository(TypeORMRevision))
|
.toDynamicValue(() => appDataSource.getRepository(TypeORMRevision))
|
||||||
|
|
||||||
// Repositories
|
// Repositories
|
||||||
container
|
container
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DataSource, LoggerOptions } from 'typeorm'
|
import { DataSource, EntityTarget, LoggerOptions, ObjectLiteral, Repository } from 'typeorm'
|
||||||
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions'
|
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions'
|
||||||
|
|
||||||
import { TypeORMRevision } from '../Infra/TypeORM/TypeORMRevision'
|
import { TypeORMRevision } from '../Infra/TypeORM/TypeORMRevision'
|
||||||
@@ -6,71 +6,85 @@ import { TypeORMRevision } from '../Infra/TypeORM/TypeORMRevision'
|
|||||||
import { Env } from './Env'
|
import { Env } from './Env'
|
||||||
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
|
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
|
||||||
|
|
||||||
const env: Env = new Env()
|
export class AppDataSource {
|
||||||
env.load()
|
private dataSource: DataSource | undefined
|
||||||
|
|
||||||
const isConfiguredForMySQL = env.get('DB_TYPE') === 'mysql'
|
constructor(private env: Env) {}
|
||||||
|
|
||||||
const maxQueryExecutionTime = env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity> {
|
||||||
? +env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
if (!this.dataSource) {
|
||||||
: 45_000
|
throw new Error('DataSource not initialized')
|
||||||
|
}
|
||||||
|
|
||||||
const commonDataSourceOptions = {
|
return this.dataSource.getRepository(target)
|
||||||
maxQueryExecutionTime,
|
}
|
||||||
entities: [TypeORMRevision],
|
|
||||||
migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`],
|
async initialize(): Promise<void> {
|
||||||
migrationsRun: true,
|
this.env.load()
|
||||||
logging: <LoggerOptions>env.get('DB_DEBUG_LEVEL', true) ?? 'info',
|
|
||||||
|
const isConfiguredForMySQL = this.env.get('DB_TYPE') === 'mysql'
|
||||||
|
|
||||||
|
const maxQueryExecutionTime = this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
||||||
|
? +this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
||||||
|
: 45_000
|
||||||
|
|
||||||
|
const commonDataSourceOptions = {
|
||||||
|
maxQueryExecutionTime,
|
||||||
|
entities: [TypeORMRevision],
|
||||||
|
migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`],
|
||||||
|
migrationsRun: true,
|
||||||
|
logging: <LoggerOptions>this.env.get('DB_DEBUG_LEVEL', true) ?? 'info',
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isConfiguredForMySQL) {
|
||||||
|
const inReplicaMode = this.env.get('DB_REPLICA_HOST', true) ? true : false
|
||||||
|
|
||||||
|
const replicationConfig = {
|
||||||
|
master: {
|
||||||
|
host: this.env.get('DB_HOST'),
|
||||||
|
port: parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: this.env.get('DB_USERNAME'),
|
||||||
|
password: this.env.get('DB_PASSWORD'),
|
||||||
|
database: this.env.get('DB_DATABASE'),
|
||||||
|
},
|
||||||
|
slaves: [
|
||||||
|
{
|
||||||
|
host: this.env.get('DB_REPLICA_HOST', true),
|
||||||
|
port: parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: this.env.get('DB_USERNAME'),
|
||||||
|
password: this.env.get('DB_PASSWORD'),
|
||||||
|
database: this.env.get('DB_DATABASE'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
removeNodeErrorCount: 10,
|
||||||
|
restoreNodeTimeout: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
const mySQLDataSourceOptions: MysqlConnectionOptions = {
|
||||||
|
...commonDataSourceOptions,
|
||||||
|
type: 'mysql',
|
||||||
|
charset: 'utf8mb4',
|
||||||
|
supportBigNumbers: true,
|
||||||
|
bigNumberStrings: false,
|
||||||
|
replication: inReplicaMode ? replicationConfig : undefined,
|
||||||
|
host: inReplicaMode ? undefined : this.env.get('DB_HOST'),
|
||||||
|
port: inReplicaMode ? undefined : parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: inReplicaMode ? undefined : this.env.get('DB_USERNAME'),
|
||||||
|
password: inReplicaMode ? undefined : this.env.get('DB_PASSWORD'),
|
||||||
|
database: inReplicaMode ? undefined : this.env.get('DB_DATABASE'),
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dataSource = new DataSource(mySQLDataSourceOptions)
|
||||||
|
} else {
|
||||||
|
const sqliteDataSourceOptions: SqliteConnectionOptions = {
|
||||||
|
...commonDataSourceOptions,
|
||||||
|
type: 'sqlite',
|
||||||
|
database: `data/${this.env.get('DB_DATABASE')}.sqlite`,
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dataSource = new DataSource(sqliteDataSourceOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.dataSource.initialize()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let dataSource: DataSource
|
|
||||||
if (isConfiguredForMySQL) {
|
|
||||||
const inReplicaMode = env.get('DB_REPLICA_HOST', true) ? true : false
|
|
||||||
|
|
||||||
const replicationConfig = {
|
|
||||||
master: {
|
|
||||||
host: env.get('DB_HOST'),
|
|
||||||
port: parseInt(env.get('DB_PORT')),
|
|
||||||
username: env.get('DB_USERNAME'),
|
|
||||||
password: env.get('DB_PASSWORD'),
|
|
||||||
database: env.get('DB_DATABASE'),
|
|
||||||
},
|
|
||||||
slaves: [
|
|
||||||
{
|
|
||||||
host: env.get('DB_REPLICA_HOST', true),
|
|
||||||
port: parseInt(env.get('DB_PORT')),
|
|
||||||
username: env.get('DB_USERNAME'),
|
|
||||||
password: env.get('DB_PASSWORD'),
|
|
||||||
database: env.get('DB_DATABASE'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
removeNodeErrorCount: 10,
|
|
||||||
restoreNodeTimeout: 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
const mySQLDataSourceOptions: MysqlConnectionOptions = {
|
|
||||||
...commonDataSourceOptions,
|
|
||||||
type: 'mysql',
|
|
||||||
charset: 'utf8mb4',
|
|
||||||
supportBigNumbers: true,
|
|
||||||
bigNumberStrings: false,
|
|
||||||
replication: inReplicaMode ? replicationConfig : undefined,
|
|
||||||
host: inReplicaMode ? undefined : env.get('DB_HOST'),
|
|
||||||
port: inReplicaMode ? undefined : parseInt(env.get('DB_PORT')),
|
|
||||||
username: inReplicaMode ? undefined : env.get('DB_USERNAME'),
|
|
||||||
password: inReplicaMode ? undefined : env.get('DB_PASSWORD'),
|
|
||||||
database: inReplicaMode ? undefined : env.get('DB_DATABASE'),
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSource = new DataSource(mySQLDataSourceOptions)
|
|
||||||
} else {
|
|
||||||
const sqliteDataSourceOptions: SqliteConnectionOptions = {
|
|
||||||
...commonDataSourceOptions,
|
|
||||||
type: 'sqlite',
|
|
||||||
database: `data/${env.get('DB_DATABASE')}.sqlite`,
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSource = new DataSource(sqliteDataSourceOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AppDataSource = dataSource
|
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.20.1](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.20.0...@standardnotes/scheduler-server@1.20.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/server/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
# [1.20.0](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.19.6...@standardnotes/scheduler-server@1.20.0) (2023-06-02)
|
# [1.20.0](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.19.6...@standardnotes/scheduler-server@1.20.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/scheduler-server",
|
"name": "@standardnotes/scheduler-server",
|
||||||
"version": "1.20.0",
|
"version": "1.20.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ export class ContainerConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(...winstonFormatters),
|
format: winston.format.combine(...winstonFormatters),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
})
|
})
|
||||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
MODE=microservice # microservice | home-server
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VERSION=development
|
VERSION=development
|
||||||
@@ -14,8 +15,10 @@ DB_PASSWORD=changeme123
|
|||||||
DB_DATABASE=standard_notes_db
|
DB_DATABASE=standard_notes_db
|
||||||
DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"
|
DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"
|
||||||
DB_MIGRATIONS_PATH=dist/migrations/*.js
|
DB_MIGRATIONS_PATH=dist/migrations/*.js
|
||||||
|
DB_TYPE=mysql
|
||||||
|
|
||||||
REDIS_URL=redis://cache
|
REDIS_URL=redis://cache
|
||||||
|
CACHE_TYPE=redis
|
||||||
|
|
||||||
SNS_TOPIC_ARN=
|
SNS_TOPIC_ARN=
|
||||||
SNS_AWS_REGION=
|
SNS_AWS_REGION=
|
||||||
|
|||||||
@@ -3,6 +3,24 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [1.43.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.42.2...@standardnotes/syncing-server@1.43.0) (2023-06-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **home-server:** allow running the home server with a mysql and redis configuration ([#622](https://github.com/standardnotes/syncing-server-js/issues/622)) ([d6e531d](https://github.com/standardnotes/syncing-server-js/commit/d6e531d4b6c1c80a894f6d7ec93632595268dd64))
|
||||||
|
|
||||||
|
## [1.42.2](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.42.1...@standardnotes/syncing-server@1.42.2) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/syncing-server-js/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
|
## [1.42.1](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.42.0...@standardnotes/syncing-server@1.42.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* initializing data source with already configured environment ([624b574](https://github.com/standardnotes/syncing-server-js/commit/624b574013157e9e044d4a8ed53cadb7fcc567ae))
|
||||||
|
|
||||||
# [1.42.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.41.4...@standardnotes/syncing-server@1.42.0) (2023-06-02)
|
# [1.42.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.41.4...@standardnotes/syncing-server@1.42.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/syncing-server",
|
"name": "@standardnotes/syncing-server",
|
||||||
"version": "1.42.0",
|
"version": "1.43.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -95,9 +95,10 @@ export class ContainerConfigLoader {
|
|||||||
defaultScope: 'Singleton',
|
defaultScope: 'Singleton',
|
||||||
})
|
})
|
||||||
|
|
||||||
await AppDataSource.initialize()
|
const appDataSource = new AppDataSource(env)
|
||||||
|
await appDataSource.initialize()
|
||||||
|
|
||||||
const isConfiguredForHomeServer = env.get('DB_TYPE') === 'sqlite'
|
const isConfiguredForHomeServer = env.get('MODE', true) === 'home-server'
|
||||||
|
|
||||||
container.bind<Env>(TYPES.Sync_Env).toConstantValue(env)
|
container.bind<Env>(TYPES.Sync_Env).toConstantValue(env)
|
||||||
|
|
||||||
@@ -114,9 +115,9 @@ export class ContainerConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(...winstonFormatters),
|
format: winston.format.combine(...winstonFormatters),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
defaultMeta: { service: 'syncing-server' },
|
defaultMeta: { service: 'syncing-server' },
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -206,7 +207,7 @@ export class ContainerConfigLoader {
|
|||||||
// ORM
|
// ORM
|
||||||
container
|
container
|
||||||
.bind<Repository<Item>>(TYPES.Sync_ORMItemRepository)
|
.bind<Repository<Item>>(TYPES.Sync_ORMItemRepository)
|
||||||
.toDynamicValue(() => AppDataSource.getRepository(Item))
|
.toDynamicValue(() => appDataSource.getRepository(Item))
|
||||||
|
|
||||||
// Projectors
|
// Projectors
|
||||||
container
|
container
|
||||||
|
|||||||
@@ -1,74 +1,88 @@
|
|||||||
import { DataSource, LoggerOptions } from 'typeorm'
|
import { DataSource, EntityTarget, LoggerOptions, ObjectLiteral, Repository } from 'typeorm'
|
||||||
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions'
|
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions'
|
||||||
import { Item } from '../Domain/Item/Item'
|
import { Item } from '../Domain/Item/Item'
|
||||||
import { Env } from './Env'
|
import { Env } from './Env'
|
||||||
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
|
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
|
||||||
|
|
||||||
const env: Env = new Env()
|
export class AppDataSource {
|
||||||
env.load()
|
private dataSource: DataSource | undefined
|
||||||
|
|
||||||
const isConfiguredForMySQL = env.get('DB_TYPE') === 'mysql'
|
constructor(private env: Env) {}
|
||||||
|
|
||||||
const maxQueryExecutionTime = env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity> {
|
||||||
? +env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
if (!this.dataSource) {
|
||||||
: 45_000
|
throw new Error('DataSource not initialized')
|
||||||
|
}
|
||||||
|
|
||||||
const commonDataSourceOptions = {
|
return this.dataSource.getRepository(target)
|
||||||
maxQueryExecutionTime,
|
}
|
||||||
entities: [Item],
|
|
||||||
migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`],
|
async initialize(): Promise<void> {
|
||||||
migrationsRun: true,
|
this.env.load()
|
||||||
logging: <LoggerOptions>env.get('DB_DEBUG_LEVEL', true) ?? 'info',
|
|
||||||
|
const isConfiguredForMySQL = this.env.get('DB_TYPE') === 'mysql'
|
||||||
|
|
||||||
|
const maxQueryExecutionTime = this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
||||||
|
? +this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
||||||
|
: 45_000
|
||||||
|
|
||||||
|
const commonDataSourceOptions = {
|
||||||
|
maxQueryExecutionTime,
|
||||||
|
entities: [Item],
|
||||||
|
migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`],
|
||||||
|
migrationsRun: true,
|
||||||
|
logging: <LoggerOptions>this.env.get('DB_DEBUG_LEVEL', true) ?? 'info',
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isConfiguredForMySQL) {
|
||||||
|
const inReplicaMode = this.env.get('DB_REPLICA_HOST', true) ? true : false
|
||||||
|
|
||||||
|
const replicationConfig = {
|
||||||
|
master: {
|
||||||
|
host: this.env.get('DB_HOST'),
|
||||||
|
port: parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: this.env.get('DB_USERNAME'),
|
||||||
|
password: this.env.get('DB_PASSWORD'),
|
||||||
|
database: this.env.get('DB_DATABASE'),
|
||||||
|
},
|
||||||
|
slaves: [
|
||||||
|
{
|
||||||
|
host: this.env.get('DB_REPLICA_HOST', true),
|
||||||
|
port: parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: this.env.get('DB_USERNAME'),
|
||||||
|
password: this.env.get('DB_PASSWORD'),
|
||||||
|
database: this.env.get('DB_DATABASE'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
removeNodeErrorCount: 10,
|
||||||
|
restoreNodeTimeout: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
const mySQLDataSourceOptions: MysqlConnectionOptions = {
|
||||||
|
...commonDataSourceOptions,
|
||||||
|
type: 'mysql',
|
||||||
|
charset: 'utf8mb4',
|
||||||
|
supportBigNumbers: true,
|
||||||
|
bigNumberStrings: false,
|
||||||
|
replication: inReplicaMode ? replicationConfig : undefined,
|
||||||
|
host: inReplicaMode ? undefined : this.env.get('DB_HOST'),
|
||||||
|
port: inReplicaMode ? undefined : parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: inReplicaMode ? undefined : this.env.get('DB_USERNAME'),
|
||||||
|
password: inReplicaMode ? undefined : this.env.get('DB_PASSWORD'),
|
||||||
|
database: inReplicaMode ? undefined : this.env.get('DB_DATABASE'),
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dataSource = new DataSource(mySQLDataSourceOptions)
|
||||||
|
} else {
|
||||||
|
const sqliteDataSourceOptions: SqliteConnectionOptions = {
|
||||||
|
...commonDataSourceOptions,
|
||||||
|
type: 'sqlite',
|
||||||
|
database: `data/${this.env.get('DB_DATABASE')}.sqlite`,
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dataSource = new DataSource(sqliteDataSourceOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.dataSource.initialize()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let dataSource: DataSource
|
|
||||||
if (isConfiguredForMySQL) {
|
|
||||||
const inReplicaMode = env.get('DB_REPLICA_HOST', true) ? true : false
|
|
||||||
|
|
||||||
const replicationConfig = {
|
|
||||||
master: {
|
|
||||||
host: env.get('DB_HOST'),
|
|
||||||
port: parseInt(env.get('DB_PORT')),
|
|
||||||
username: env.get('DB_USERNAME'),
|
|
||||||
password: env.get('DB_PASSWORD'),
|
|
||||||
database: env.get('DB_DATABASE'),
|
|
||||||
},
|
|
||||||
slaves: [
|
|
||||||
{
|
|
||||||
host: env.get('DB_REPLICA_HOST', true),
|
|
||||||
port: parseInt(env.get('DB_PORT')),
|
|
||||||
username: env.get('DB_USERNAME'),
|
|
||||||
password: env.get('DB_PASSWORD'),
|
|
||||||
database: env.get('DB_DATABASE'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
removeNodeErrorCount: 10,
|
|
||||||
restoreNodeTimeout: 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
const mySQLDataSourceOptions: MysqlConnectionOptions = {
|
|
||||||
...commonDataSourceOptions,
|
|
||||||
type: 'mysql',
|
|
||||||
charset: 'utf8mb4',
|
|
||||||
supportBigNumbers: true,
|
|
||||||
bigNumberStrings: false,
|
|
||||||
replication: inReplicaMode ? replicationConfig : undefined,
|
|
||||||
host: inReplicaMode ? undefined : env.get('DB_HOST'),
|
|
||||||
port: inReplicaMode ? undefined : parseInt(env.get('DB_PORT')),
|
|
||||||
username: inReplicaMode ? undefined : env.get('DB_USERNAME'),
|
|
||||||
password: inReplicaMode ? undefined : env.get('DB_PASSWORD'),
|
|
||||||
database: inReplicaMode ? undefined : env.get('DB_DATABASE'),
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSource = new DataSource(mySQLDataSourceOptions)
|
|
||||||
} else {
|
|
||||||
const sqliteDataSourceOptions: SqliteConnectionOptions = {
|
|
||||||
...commonDataSourceOptions,
|
|
||||||
type: 'sqlite',
|
|
||||||
database: `data/${env.get('DB_DATABASE')}.sqlite`,
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSource = new DataSource(sqliteDataSourceOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AppDataSource = dataSource
|
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.9.1](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.9.0...@standardnotes/websockets-server@1.9.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/server/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
# [1.9.0](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.8.6...@standardnotes/websockets-server@1.9.0) (2023-06-02)
|
# [1.9.0](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.8.6...@standardnotes/websockets-server@1.9.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/websockets-server",
|
"name": "@standardnotes/websockets-server",
|
||||||
"version": "1.9.0",
|
"version": "1.9.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ export class ContainerConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(...winstonFormatters),
|
format: winston.format.combine(...winstonFormatters),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
})
|
})
|
||||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user