Skip to content

Commit 78b0c1e

Browse files
authored
Merge pull request #201 from import-ai/feat/ws
Feat/ws
2 parents 1c22de7 + 7b68a12 commit 78b0c1e

File tree

14 files changed

+359
-35
lines changed

14 files changed

+359
-35
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
env:
111111
OBB_POSTGRES_URL: postgres://omnibox:omnibox@postgres:5432/omnibox
112112
OBB_MINIO_URL: http://username:password@minio:9000/omnibox
113-
OBB_LOG_LEVELS:
113+
OBB_LOG_LEVELS: ""
114114

115115
- name: Print coverage report
116116
run: |

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@
5858
"@nestjs/jwt": "^11.0.0",
5959
"@nestjs/passport": "^11.0.5",
6060
"@nestjs/platform-express": "^11.1.5",
61+
"@nestjs/platform-socket.io": "^11.1.6",
6162
"@nestjs/swagger": "^11.2.0",
6263
"@nestjs/typeorm": "^11.0.0",
64+
"@nestjs/websockets": "^11.1.6",
6365
"@opentelemetry/api": "^1.9.0",
6466
"@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
6567
"@opentelemetry/instrumentation-express": "^0.52.0",
@@ -92,8 +94,9 @@
9294
"redis": "^4.7.1",
9395
"reflect-metadata": "^0.2.2",
9496
"rxjs": "^7.8.2",
97+
"socket.io": "^4.8.1",
9598
"typeorm": "^0.3.25",
9699
"typeorm-naming-strategies": "^4.1.0"
97100
},
98-
"packageManager": "pnpm@10.13.1"
101+
"packageManager": "pnpm@10.17.1"
99102
}

pnpm-lock.yaml

Lines changed: 195 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { ApplicationsModule } from 'omniboxd/applications/applications.module';
5353
import { FeedbackModule } from 'omniboxd/feedback/feedback.module';
5454
import { Feedback1757100000000 } from 'omniboxd/migrations/1757100000000-feedback';
5555
import { UserInterceptor } from 'omniboxd/interceptor/user.interceptor';
56+
import { WebSocketModule } from 'omniboxd/websocket/websocket.module';
5657

5758
@Module({})
5859
export class AppModule implements NestModule {
@@ -110,6 +111,7 @@ export class AppModule implements NestModule {
110111
TraceModule,
111112
FeedbackModule,
112113
ApplicationsModule,
114+
WebSocketModule,
113115
// CacheModule.registerAsync({
114116
// imports: [ConfigModule],
115117
// inject: [ConfigService],

src/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ async function bootstrap() {
88
// Start OpenTelemetry SDK before creating the NestJS app
99
if (otelSDK) {
1010
otelSDK.start();
11-
console.log('OpenTelemetry tracing initialized');
1211
}
1312
const app = await NestFactory.create(AppModule.forRoot([]), {
1413
cors: true,

src/messages/messages.controller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Body, Controller, Delete, Param, Post, Req } from '@nestjs/common';
22
import { MessagesService } from './messages.service';
33
import { CreateMessageDto } from './dto/create-message.dto';
4+
import { UserId } from 'omniboxd/decorators/user-id.decorator';
45

56
@Controller(
67
'api/v1/namespaces/:namespaceId/conversations/:conversationId/messages',
@@ -10,15 +11,15 @@ export class MessagesController {
1011

1112
@Post()
1213
async create(
13-
@Req() req,
14+
@UserId() userId: string,
1415
@Param('namespaceId') namespaceId: string,
1516
@Param('conversationId') conversationId: string,
1617
@Body() dto: CreateMessageDto,
1718
) {
1819
return await this.messagesService.create(
1920
namespaceId,
2021
conversationId,
21-
req.user,
22+
userId,
2223
dto,
2324
);
2425
}

src/messages/messages.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,22 @@ export class MessagesService {
4646
async create(
4747
namespaceId: string,
4848
conversationId: string,
49-
user: User,
49+
userId: string,
5050
dto: CreateMessageDto,
5151
index: boolean = true,
5252
): Promise<Message> {
5353
const message = this.messageRepository.create({
5454
message: dto.message,
5555
conversationId,
56-
userId: user.id,
56+
userId: userId,
5757
parentId: dto.parentId,
5858
attrs: dto.attrs,
5959
});
6060
return await this.dataSource.transaction(async (manager) => {
6161
const savedMsg = await manager.save(message);
6262
await this.index(
6363
index,
64-
user.id,
64+
userId,
6565
namespaceId,
6666
conversationId,
6767
savedMsg,

src/namespaces/namespaces.controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
Patch,
1010
Delete,
1111
Controller,
12-
ValidationPipe,
1312
} from '@nestjs/common';
1413
import { UserId } from 'omniboxd/decorators/user-id.decorator';
1514
import { CreateNamespaceDto } from './dto/create-namespace.dto';

src/namespaces/namespaces.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import each from 'omniboxd/utils/each';
21
import { InjectRepository } from '@nestjs/typeorm';
32
import { Namespace } from './entities/namespace.entity';
43
import { Resource } from 'omniboxd/resources/entities/resource.entity';

src/websocket/websocket.module.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Module } from '@nestjs/common';
2+
import { WizardGateway } from 'omniboxd/websocket/wizard.gateway';
3+
import { WsJwtGuard } from 'omniboxd/websocket/ws-jwt.guard';
4+
import { WizardModule } from 'omniboxd/wizard/wizard.module';
5+
import { AuthModule } from 'omniboxd/auth';
6+
7+
@Module({
8+
imports: [WizardModule, AuthModule],
9+
providers: [WizardGateway, WsJwtGuard],
10+
exports: [WizardGateway, WsJwtGuard],
11+
})
12+
export class WebSocketModule {}

0 commit comments

Comments
 (0)