Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Mhirii committed Aug 27, 2023
2 parents aba434d + fa3237c commit b7d5d10
Show file tree
Hide file tree
Showing 48 changed files with 1,309 additions and 212 deletions.
216 changes: 215 additions & 1 deletion backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"@nestjs/mongoose": "^10.0.0",
"@nestjs/passport": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/platform-socket.io": "^10.2.1",
"@nestjs/swagger": "^7.1.4",
"@nestjs/websockets": "^10.2.1",
"@types/bcrypt": "^5.0.0",
"bcrypt": "^5.1.0",
"class-transformer": "^0.5.1",
Expand All @@ -37,7 +39,8 @@
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1"
"rxjs": "^7.8.1",
"socket.io-client": "^4.7.2"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
Expand Down
2 changes: 2 additions & 0 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AuthModule } from './auth/auth.module';
import { AccessTokenGuard } from './common/guards/accessToken.guard';
import { APP_GUARD } from '@nestjs/core';
import { UserModule } from './user/user.module';
import { GatewayModule } from './gateway/gateway.module';

@Module({
imports: [
Expand All @@ -19,6 +20,7 @@ import { UserModule } from './user/user.module';
ProjectsModule,
AuthModule,
UserModule,
GatewayModule,
],
controllers: [AppController],
providers: [
Expand Down
7 changes: 7 additions & 0 deletions backend/src/gateway/gateway.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { SocketGateway } from './socket.Gateway';

@Module({
providers: [SocketGateway],
})
export class GatewayModule {}
34 changes: 34 additions & 0 deletions backend/src/gateway/socket.Gateway.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {
MessageBody,
SubscribeMessage,
WebSocketGateway,
WebSocketServer,
} from '@nestjs/websockets';
import { Server } from 'socket.io';
import { OnModuleInit } from '@nestjs/common';

@WebSocketGateway({
cors: {
origin: ['http://localhost:5173'],
},
})
export class SocketGateway implements OnModuleInit {
@WebSocketServer()
server: Server;

onModuleInit(): any {
this.server.on('connection', (socket) => {
console.log(socket.id);
console.log('Connected');
});
}

@SubscribeMessage('message')
onNewMessage(@MessageBody() body: any) {
console.log(body);
this.server.emit('onMessage', {
msg: 'new Message',
content: body,
});
}
}
18 changes: 18 additions & 0 deletions backend/src/gateway/socket.gateway.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { SocketGateway } from './socket.Gateway';

describe('GatewayGateway', () => {
let gateway: SocketGateway;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [SocketGateway],
}).compile();

gateway = module.get<SocketGateway>(SocketGateway);
});

it('should be defined', () => {
expect(gateway).toBeDefined();
});
});
Loading

1 comment on commit b7d5d10

@vercel
Copy link

@vercel vercel bot commented on b7d5d10 Aug 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployment failed with the following error:

If `rewrites`, `redirects`, `headers`, `cleanUrls` or `trailingSlash` are used, then `routes` cannot be present.

Learn More: https://vercel.link/mix-routing-props

Please sign in to comment.