-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
392 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,7 @@ testem.log | |
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Filesystem storage | ||
data/* | ||
!data/.gitkeep |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const envFile = process.env['NODE_ENV'] ? `.${process.env['NODE_ENV']}` : ''; | ||
|
||
export const { env } = require(`./environment${envFile}.ts`); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {Environment} from "./environment.schema"; | ||
|
||
export const env: Environment = { | ||
production: true, | ||
keycloak: { | ||
baseUrl: 'http://localhost:8080', | ||
realm: 'app' | ||
}, | ||
//@TODO: Inject via env | ||
postgres: { | ||
host: 'localhost', | ||
port: 5432, | ||
database: 'app', | ||
user: 'dev', | ||
password: 'dev', | ||
max: 200 | ||
}, | ||
eventStore: { | ||
adapter: "postgres" | ||
}, | ||
documentStore: { | ||
adapter: "postgres" | ||
}, | ||
authentication: { | ||
disabled: false | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {PoolConfig} from "pg"; | ||
|
||
export interface Environment { | ||
production: boolean; | ||
postgres: PoolConfig; | ||
keycloak: {baseUrl: string, realm: string}; | ||
eventStore: { | ||
adapter: "postgres" | "memory" | "filesystem" | ||
}, | ||
documentStore: { | ||
adapter: "postgres" | "memory" | "filesystem" | ||
}, | ||
authentication?: { | ||
disabled: boolean; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// This file can be replaced during build by using the `fileReplacements` array. | ||
// When building for production, this file is replaced with `environment.prod.ts`. | ||
|
||
import {Environment} from "./environment.schema"; | ||
|
||
export const env: Environment = { | ||
production: false, | ||
keycloak: { | ||
baseUrl: 'http://localhost:8080', | ||
realm: 'app' | ||
}, | ||
postgres: { | ||
host: 'localhost', | ||
port: 5433, | ||
database: 'test', | ||
user: 'dev', | ||
password: 'dev', | ||
max: 200 | ||
}, | ||
eventStore: { | ||
adapter: "filesystem" | ||
}, | ||
documentStore: { | ||
adapter: "filesystem" | ||
}, | ||
authentication: { | ||
disabled: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {DB} from "@event-engine/infrastructure/Postgres/DB"; | ||
import {Pool} from "pg"; | ||
import {env} from "@server/env"; | ||
|
||
let db: DB; | ||
|
||
export const getConfiguredDB = (): DB => { | ||
if(!db) { | ||
db = new DB(new Pool(env.postgres)) | ||
} | ||
|
||
return db; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {DocumentStore} from "@event-engine/infrastructure/DocumentStore"; | ||
import {PostgresDocumentStore} from "@event-engine/infrastructure/DocumentStore/PostgresDocumentStore"; | ||
import {getConfiguredDB} from "@server/infrastructure/configuredDB"; | ||
import {env} from "@server/env"; | ||
import {InMemoryDocumentStore} from "@event-engine/infrastructure/DocumentStore/InMemoryDocumentStore"; | ||
|
||
let store: DocumentStore; | ||
|
||
export const PERSISTENT_COLLECTION_FILE = process.cwd() + '/../../../data/persistent-collections.json'; | ||
|
||
export const getConfiguredDocumentStore = (): DocumentStore => { | ||
if(!store) { | ||
switch (env.documentStore.adapter) { | ||
case "postgres": | ||
store = new PostgresDocumentStore(getConfiguredDB()); | ||
break; | ||
case "filesystem": | ||
store = new InMemoryDocumentStore(PERSISTENT_COLLECTION_FILE); | ||
break; | ||
default: | ||
store = new InMemoryDocumentStore(); | ||
} | ||
} | ||
|
||
return store; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {EventStore} from "@event-engine/infrastructure/EventStore"; | ||
import {PostgresEventStore} from "@event-engine/infrastructure/EventStore/PostgresEventStore"; | ||
import {getConfiguredDB} from "@server/infrastructure/configuredDB"; | ||
import {env} from "@server/env"; | ||
import {InMemoryEventStore} from "@event-engine/infrastructure/EventStore/InMemoryEventStore"; | ||
import {InMemoryStreamListenerQueue} from "@event-engine/infrastructure/Queue/InMemoryStreamListenerQueue"; | ||
import {EventDispatcher} from "@event-engine/infrastructure/EventDispatcher"; | ||
|
||
export const WRITE_MODEL_STREAM = 'write_model_stream'; | ||
export const PUBLIC_STREAM = 'public_stream'; | ||
|
||
export const PERSISTENT_STREAMS_FILE = process.cwd() + '/../../../data/persistent-streams.json'; | ||
|
||
let es: EventStore; | ||
|
||
export const getConfiguredEventStore = (): EventStore => { | ||
if(!es) { | ||
switch (env.eventStore.adapter) { | ||
case "postgres": | ||
es = new PostgresEventStore(getConfiguredDB()); | ||
break; | ||
case "filesystem": | ||
es = new InMemoryEventStore(PERSISTENT_STREAMS_FILE); | ||
break; | ||
default: | ||
es = new InMemoryEventStore(); | ||
} | ||
|
||
// Avoid circular deps in listeners | ||
const streamListener = new InMemoryStreamListenerQueue(es, PUBLIC_STREAM); | ||
|
||
streamListener.startProcessing(); | ||
} | ||
|
||
return es; | ||
} |
51 changes: 51 additions & 0 deletions
51
packages/be/src/infrastructure/configuredMultiModelStore.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {MultiModelStore} from "@event-engine/infrastructure/MultiModelStore"; | ||
import {getConfiguredEventStore} from "@server/infrastructure/configuredEventStore"; | ||
import {getConfiguredDocumentStore} from "@server/infrastructure/configuredDocumentStore"; | ||
import {PostgresDocumentStore} from "@event-engine/infrastructure/DocumentStore/PostgresDocumentStore"; | ||
import {getConfiguredDB} from "@server/infrastructure/configuredDB"; | ||
import {PostgresMultiModelStore} from "@event-engine/infrastructure/MultiModelStore/PostgresMultiModelStore"; | ||
import {PostgresEventStore} from "@event-engine/infrastructure/EventStore/PostgresEventStore"; | ||
import {env} from "@server/env"; | ||
import {InMemoryEventStore} from "@event-engine/infrastructure/EventStore/InMemoryEventStore"; | ||
import {InMemoryDocumentStore} from "@event-engine/infrastructure/DocumentStore/InMemoryDocumentStore"; | ||
import {InMemoryMultiModelStore} from "@event-engine/infrastructure/MultiModelStore/InMemoryMultiModelStore"; | ||
|
||
let store: MultiModelStore; | ||
|
||
export const getConfiguredMultiModelStore = () => { | ||
if(!store) { | ||
const es = getConfiguredEventStore(); | ||
const ds = getConfiguredDocumentStore(); | ||
|
||
if(env.eventStore.adapter === "postgres" && env.documentStore.adapter === "postgres") { | ||
if(!(es instanceof PostgresEventStore)) { | ||
throw new Error("Postgres MultiModelStore requires an instance of PostgresEventStore, but another EventStore is given."); | ||
} | ||
|
||
if(!(ds instanceof PostgresDocumentStore)) { | ||
throw new Error("Postgres MultiModelStore requires an instance of PostgresDocumentStore, but another DocumentStore is given."); | ||
} | ||
|
||
store = new PostgresMultiModelStore( | ||
getConfiguredDB(), | ||
es, | ||
ds | ||
) | ||
} else { | ||
if(!(es instanceof InMemoryEventStore)) { | ||
throw new Error("InMemory MultiModelStore requires an instance of InMemoryEventStore, but another EventStore is given."); | ||
} | ||
|
||
if(!(ds instanceof InMemoryDocumentStore)) { | ||
throw new Error("InMemory MultiModelStore requires an instance of InMemoryDocumentStore, but another DocumentStore is given."); | ||
} | ||
|
||
store = new InMemoryMultiModelStore( | ||
es, | ||
ds | ||
) | ||
} | ||
} | ||
|
||
return store; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface Description { | ||
_pbBoardId: string; | ||
_pbCardId: string; | ||
_pbCreatedBy: string; | ||
_pbCreatedAt: string; | ||
_pbLastUpdatedBy: string; | ||
_pbLastUpdatedAt: string; | ||
_pbVersion: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# shared | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test shared` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'shared', | ||
preset: '../../jest.preset.js', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../coverage/packages/shared', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "shared", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/shared/src", | ||
"projectType": "library", | ||
"targets": { | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["packages/shared/**/*.ts"] | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "packages/shared/jest.config.ts", | ||
"passWithNoTests": true | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"ci": true, | ||
"codeCoverage": true | ||
} | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {CommandRuntimeInfo} from "@event-engine/messaging/command"; | ||
|
||
import {fleetManagementAddCarToFleetRuntimeInfo} from "@app/shared/commands/fleet-management/add-car-to-fleet"; | ||
|
||
type CommandRegistry = {[name: string]: CommandRuntimeInfo}; | ||
|
||
export const commands: CommandRegistry = { | ||
"FleetManagement.AddCarToFleet": fleetManagementAddCarToFleetRuntimeInfo, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {CarListSchema} from "@app/shared/types/fleet-management/car/car-list.schema"; | ||
import {CarSchema} from "@app/shared/types/fleet-management/car/car.schema"; | ||
|
||
const definitions = { | ||
'/definitions/fleet-management/car/car-list': CarListSchema, | ||
'/definitions/fleet-management/car/car': CarSchema, | ||
}; | ||
|
||
export default definitions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {CarListSchema as FleetManagementCarListSchema} from "@app/shared/types/fleet-management/car/car-list.schema"; | ||
import {CarSchema as FleetManagementCarSchema} from "@app/shared/types/fleet-management/car/car.schema"; | ||
|
||
export type references = [ | ||
typeof FleetManagementCarListSchema, | ||
typeof FleetManagementCarSchema, | ||
]; |
Oops, something went wrong.