Skip to content

Commit

Permalink
Added infra for running servicebus connections in main node process
Browse files Browse the repository at this point in the history
  • Loading branch information
mligtenberg committed Dec 24, 2024
1 parent 71ed462 commit 6582f74
Show file tree
Hide file tree
Showing 80 changed files with 17,636 additions and 27,270 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
3 changes: 2 additions & 1 deletion apps/servicebus-browser-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"outputPath": "dist/apps/servicebus-browser-app",
"main": "apps/servicebus-browser-app/src/main.ts",
"tsConfig": "apps/servicebus-browser-app/tsconfig.app.json",
"assets": ["apps/servicebus-browser-app/src/assets"]
"assets": ["apps/servicebus-browser-app/src/assets"],
"externalDependencies": "none"
},
"configurations": {
"production": {
Expand Down
4 changes: 4 additions & 0 deletions apps/servicebus-browser-app/src/app/api/main.preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ contextBridge.exposeInMainWorld('electron', {
getAppVersion: () => ipcRenderer.invoke('get-app-version'),
platform: process.platform,
});

contextBridge.exposeInMainWorld('serviceBusApi', {
doRequest: (requestType: string, request) => ipcRenderer.invoke('service-bus:do-request', requestType, request),
})
12 changes: 12 additions & 0 deletions apps/servicebus-browser-app/src/app/events/service-bus.events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ipcMain } from 'electron';
import { execute } from '@service-bus-browser/service-bus-server';

export default class ServiceBusEvents {
static bootstrapServiceBusEvents(): Electron.IpcMain {
return ipcMain;
}
}

ipcMain.handle('service-bus:do-request', async (event, requestType: string, request: unknown) => {
return await execute(requestType, request);
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"$schema": "../../../../../node_modules/nx-electron/src/validation/maker.schema.json"
"$schema": "../../../../../node_modules/nx-electron/src/validation/maker.schema.json",
"appId": "digital.ligtenberg.servicebus-browser",
"artifactName": "Servicebus Browser"
}
2 changes: 2 additions & 0 deletions apps/servicebus-browser-app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ElectronEvents from './app/events/electron.events';
import { app, BrowserWindow } from 'electron';
import App from './app/app';
import { installExtension, REDUX_DEVTOOLS } from 'electron-devtools-installer';
import ServiceBusEvents from './app/events/service-bus.events';



Expand All @@ -20,6 +21,7 @@ export default class Main {

static bootstrapAppEvents() {
ElectronEvents.bootstrapElectronEvents();
ServiceBusEvents.bootstrapServiceBusEvents();

// initialize auto updater service
if (!App.isDevelopmentMode()) {
Expand Down
3 changes: 2 additions & 1 deletion apps/servicebus-browser-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"types": ["node"]
"types": ["node"],
"importHelpers": true
},
"include": ["**/*.ts"]
}
5 changes: 3 additions & 2 deletions apps/servicebus-browser-frontend/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { provideLogsState } from '@service-bus-browser/logs-store';
import { provideStore } from '@ngrx/store';
import { provideStoreDevtools } from '@ngrx/store-devtools';
import { provideTopologyState } from '@service-bus-browser/topology-store';
import { provideServiceBusClient } from '@service-bus-browser/service-bus-angular-providers';

export const appConfig: ApplicationConfig = {
providers: [
Expand All @@ -27,13 +28,13 @@ export const appConfig: ApplicationConfig = {
provideRouter(appRoutes, withHashLocation()),
provideLogsState(),
provideTopologyState(),
provideServiceBusClient(),

// ngrx
provideStore(),
provideStoreDevtools({
maxAge: 25,
logOnly: !
isDevMode(),
logOnly: !isDevMode(),
}),
],
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "contract",
"name": "@service-bus-browser/logs-contracts",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/logs/contract/src",
"projectType": "library",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions libs/service-bus/angular-providers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @service-bus-browser/service-bus-angular-providers

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test @service-bus-browser/service-bus-angular-providers` to execute the unit tests.
34 changes: 34 additions & 0 deletions libs/service-bus/angular-providers/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const nx = require('@nx/eslint-plugin');
const baseConfig = require('../../../eslint.config.js');

module.exports = [
...baseConfig,
...nx.configs['flat/angular'],
...nx.configs['flat/angular-template'],
{
files: ['**/*.ts'],
rules: {
'@angular-eslint/directive-selector': [
'error',
{
type: 'attribute',
prefix: 'lib',
style: 'camelCase',
},
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: 'lib',
style: 'kebab-case',
},
],
},
},
{
files: ['**/*.html'],
// Override or add rules here
rules: {},
},
];
21 changes: 21 additions & 0 deletions libs/service-bus/angular-providers/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default {
displayName: '@service-bus-browser/service-bus-angular-providers',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../coverage/libs/angular-providers',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
20 changes: 20 additions & 0 deletions libs/service-bus/angular-providers/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@service-bus-browser/service-bus-angular-providers",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/angular-providers/src",
"prefix": "lib",
"projectType": "library",
"tags": [],
"targets": {
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/angular-providers/jest.config.ts"
}
},
"lint": {
"executor": "@nx/eslint:lint"
}
}
}
14 changes: 14 additions & 0 deletions libs/service-bus/angular-providers/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { EnvironmentProviders, Provider } from '@angular/core';
import { ServiceBusElectronClient } from '@service-bus-browser/service-bus-electron-client';

export function provideServiceBusClient(): (
| Provider
| EnvironmentProviders
)[] {
return [
{
provide: ServiceBusElectronClient,
useClass: ServiceBusElectronClient
}
];
}
6 changes: 6 additions & 0 deletions libs/service-bus/angular-providers/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';

setupZoneTestEnv({
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
});
28 changes: 28 additions & 0 deletions libs/service-bus/angular-providers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"target": "es2022",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../../tsconfig.base.json",
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
17 changes: 17 additions & 0 deletions libs/service-bus/angular-providers/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": []
},
"exclude": [
"src/**/*.spec.ts",
"src/test-setup.ts",
"jest.config.ts",
"src/**/*.test.ts"
],
"include": ["src/**/*.ts"]
}
18 changes: 18 additions & 0 deletions libs/service-bus/angular-providers/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"target": "es2016",
"types": ["jest", "node"]
},
"files": [
"src/test-setup.ts"
],
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}
21 changes: 21 additions & 0 deletions libs/service-bus/clients/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# clients

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test clients` to execute the unit tests via [Jest](https://jestjs.io).


## library structure
```mermaid
graph TD;
cm[Connection Manager]
cc[Connection Client]
ac[Administration Client]
mc[Message Client]
cm --getConnection--> cc
cc --getMessageClient--> mc
cc --getAdministrationClient --> ac
```
3 changes: 3 additions & 0 deletions libs/service-bus/clients/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const baseConfig = require('../../../eslint.config.js');

module.exports = [...baseConfig];
10 changes: 10 additions & 0 deletions libs/service-bus/clients/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
displayName: 'clients',
preset: '../../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../coverage/libs/servicebus/clients',
};
6 changes: 6 additions & 0 deletions libs/service-bus/clients/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@service-bus-browser/service-bus-clients",
"version": "0.0.1",
"dependencies": {},
"private": true
}
16 changes: 16 additions & 0 deletions libs/service-bus/clients/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@service-bus-browser/service-bus-clients",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/servicebus/clients/src",
"projectType": "library",
"tags": [],
"targets": {
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/servicebus/clients/jest.config.ts"
}
}
}
}
1 change: 1 addition & 0 deletions libs/service-bus/clients/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/connection-manager';
Loading

0 comments on commit 6582f74

Please sign in to comment.