Skip to content

Commit 374bf29

Browse files
Merge pull request #10 from alkem-io/develop
Release v0.3.1
2 parents 1ae6ccb + b328dd3 commit 374bf29

17 files changed

+145
-52
lines changed

config.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ settings:
3737
collaboration:
3838
enabled: ${ENABLED}:true
3939
#
40-
port: ${PORT}:4002
40+
port: ${COLLABORATION_PORT}:4002
4141
# the window in which contributions are accepted to be counted towards a single contribution event;
4242
# time is in SECONDS
4343
contribution_window: ${CONTRIBUTION_WINDOW}:600
@@ -50,4 +50,7 @@ settings:
5050
# how often the inactivity timer is reset;
5151
# you want it to be large enough to not reset too frequently,
5252
# but small enough to be accurate
53-
reset_collaborator_mode_debounce: ${INACTIVITY_DEBOUNCE}:1000
53+
reset_collaborator_mode_debounce: ${INACTIVITY_DEBOUNCE}:1000
54+
rest:
55+
# the REST API
56+
port: ${REST_PORT}:4005

package-lock.json

+40-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "whiteboard-collaboration-service",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "Alkemio Whiteboard Collaboration Service for Excalidraw backend",
55
"author": "Alkemio Foundation",
66
"private": false,
@@ -31,7 +31,7 @@
3131
"reflect-metadata": "^0.2.0",
3232
"rxjs": "^7.8.1",
3333
"socket.io": "^4.7.5",
34-
"socket.io-adapter": "^2.5.4",
34+
"socket.io-adapter": "^2.5.5",
3535
"yaml": "^2.4.2"
3636
},
3737
"devDependencies": {

src/app.module.ts

+3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import { ConfigModule } from '@nestjs/config';
44
import { WinstonConfigService } from './config/winston.config';
55
import { ServerModule } from './excalidraw-backend/server.module';
66
import configuration from './config/configuration';
7+
import { HealthController } from './services/health/health.controller';
8+
import { HealthModule } from './services/health/health.module';
79

810
@Module({
911
imports: [
1012
ServerModule,
13+
HealthModule,
1114
ConfigModule.forRoot({
1215
envFilePath: ['.env'],
1316
isGlobal: true,

src/config/config.type.ts

+3
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@ export interface ConfigType {
2929
collaborator_inactivity: number;
3030
reset_collaborator_mode_debounce: number;
3131
};
32+
rest: {
33+
port: number;
34+
};
3235
};
3336
}

src/excalidraw-backend/get.excalidraw.base.server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const getExcalidrawBaseServerOrFail = (
1111
): SocketIoServer => {
1212
const httpServer = http.createServer();
1313
httpServer.listen(port, () => {
14-
logger.verbose?.(`Listening on port ${port}`);
14+
logger.verbose?.(`Collaboration endpoint Listening on port ${port}`);
1515
});
1616

1717
return new SocketIO(httpServer, {

src/main.ts

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { NestFactory } from '@nestjs/core';
22
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
33
import { AppModule } from './app.module';
4+
import { ConfigService } from '@nestjs/config';
5+
import { ConfigType } from './config';
46

57
(async () => {
68
const app = await NestFactory.create(AppModule, {
@@ -14,4 +16,12 @@ import { AppModule } from './app.module';
1416
});
1517
const logger = app.get(WINSTON_MODULE_NEST_PROVIDER);
1618
app.useLogger(logger);
19+
20+
const configService: ConfigService<ConfigType, true> = app.get(ConfigService);
21+
const port = configService.get('settings.rest.port', {
22+
infer: true,
23+
});
24+
await app.listen(port, () => {
25+
logger.verbose?.(`Rest endpoint running on port ${port}`);
26+
});
1727
})();
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Controller, Get, HttpException, HttpStatus } from '@nestjs/common';
2+
import { WhiteboardIntegrationService } from '../whiteboard-integration/whiteboard.integration.service';
3+
4+
@Controller('/health')
5+
export class HealthController {
6+
constructor(
7+
private readonly integrationService: WhiteboardIntegrationService,
8+
) {}
9+
@Get('/')
10+
public async healthCheck(): Promise<string> {
11+
if (!(await this.integrationService.isConnected())) {
12+
throw new HttpException('unhealthy!', HttpStatus.INTERNAL_SERVER_ERROR);
13+
}
14+
15+
return 'healthy!';
16+
}
17+
}

src/services/health/health.module.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Module } from '@nestjs/common';
2+
import { HealthController } from './health.controller';
3+
import { WhiteboardIntegrationModule } from '../whiteboard-integration/whiteboard.integration.module';
4+
5+
@Module({
6+
imports: [WhiteboardIntegrationModule],
7+
controllers: [HealthController],
8+
})
9+
export class HealthModule {}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export enum WhiteboardIntegrationMessagePattern {
2-
ACCESS_GRANTED = 'accessGranted',
32
WHO = 'who',
43
INFO = 'info',
4+
HEALTH_CHECK = 'health-check',
55
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export class BaseOutputData {
2+
constructor(public event: string) {}
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { BaseOutputData } from './base.output.data';
2+
3+
export class HealthCheckOutputData extends BaseOutputData {
4+
constructor(public healthy: boolean) {
5+
super('health-check-output');
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './info.output.data';
2+
export * from './health.check.output.data';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './rmq.connection.error';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export type RMQConnectionError = {
2+
err: {
3+
stack: string;
4+
message: string;
5+
};
6+
url: {
7+
protocol: string;
8+
hostname: string;
9+
username: string;
10+
password: string;
11+
port: number;
12+
heartbeat: number;
13+
};
14+
};

0 commit comments

Comments
 (0)