-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from morteza-mortezai/rabbit-gateway
Rabbit gateway
- Loading branch information
Showing
128 changed files
with
6,298 additions
and
1,342 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
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,3 @@ | ||
{ | ||
"vue.codeActions.enabled": 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
APP_PORT=3000 | ||
|
||
MONGODB_URI=mongodb://localhost:27017/orderApp | ||
|
||
RMQ_URI=amqp://localhost:5672 | ||
RMQ_USERS_QUEUE=users | ||
RMQ_USERS_QUEUE=users | ||
|
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 was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
apps/gateway/src/infrastructure/controllers/controller.module.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,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { UserController } from './user.controller'; | ||
import { RabbitmqModule } from '../rabbit-mq/rabbit-mq.module'; | ||
|
||
@Module({ | ||
imports: [RabbitmqModule], | ||
controllers: [ | ||
UserController | ||
], | ||
providers: [] | ||
}) | ||
export class ControllerModule { } |
10 changes: 0 additions & 10 deletions
10
apps/gateway/src/infrastructure/controllers/controllers.module.ts
This file was deleted.
Oops, something went wrong.
58 changes: 24 additions & 34 deletions
58
apps/gateway/src/infrastructure/controllers/user.controller.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 |
---|---|---|
@@ -1,42 +1,32 @@ | ||
import { Controller, Get, Param, ParseIntPipe, Post, Body, Delete } from '@nestjs/common'; | ||
import { UsersService } from '../services/users.service'; | ||
import { CreateUserDto } from '../dto/createUser.dto'; | ||
import { Controller, Post, Get, Inject, ParseIntPipe, Param, Delete, Body } from '@nestjs/common'; | ||
import { ClientProxy } from '@nestjs/microservices' | ||
import { CreateUserDto } from '../dto/create-user.dto'; | ||
import { RMQ_SERVICES, RMQ_CMD } from '@app/common/constants/rmq.constant'; | ||
import { lastValueFrom } from 'rxjs' | ||
|
||
@Controller() | ||
export class UserController { | ||
constructor(private readonly usersService: UsersService) { } | ||
constructor( | ||
@Inject(RMQ_SERVICES.USERS) private readonly usersClient: ClientProxy | ||
) { } | ||
|
||
@Post('users') | ||
async create(@Body() createUserDto: CreateUserDto) { | ||
return this.usersService.createUser(createUserDto); | ||
} | ||
@Post('users') | ||
createUser(@Body() createUser: CreateUserDto) { | ||
return lastValueFrom(this.usersClient.send(RMQ_CMD.CREATE_NEW_USER, createUser)) | ||
} | ||
|
||
@Get('user/:id') | ||
getUserById(@Param('id', ParseIntPipe) id: number) { | ||
return this.usersService.getUserById(id); | ||
} | ||
@Get('user/:userId') | ||
async getUserById(@Param('userId', ParseIntPipe) userId: number) { | ||
return lastValueFrom(this.usersClient.send(RMQ_CMD.GET_USER_BY_ID, userId)) | ||
} | ||
|
||
@Get('user/:userId/avatar') | ||
async getAvatarByUserId(@Param('userId', ParseIntPipe) userId: number) { | ||
return lastValueFrom(this.usersClient.send(RMQ_CMD.GET_AVATAR_BY_ID, userId)) | ||
} | ||
|
||
// @Get('user/:id/avatar') | ||
// async getAvatar(@Param('id', ParseIntPipe) id: number): Promise<any> { | ||
// try { | ||
// // check if it exists already | ||
// let fileName = await this.avatarService.avatarExist(id) | ||
// if (!fileName) { | ||
// //get user | ||
// const user = await this.usersService.findOne(id) | ||
// // get and save avatar | ||
// fileName = await this.avatarService.getAndSaveAvatar(user) | ||
// } | ||
// return this.avatarService.readFile(fileName as string) | ||
|
||
// } catch (error) { | ||
// return error | ||
// } | ||
// } | ||
|
||
// @Delete('user/:id/avatar') | ||
// async delete(@Param('id', ParseIntPipe) id: number) { | ||
// return this.avatarService.delete(id); | ||
// } | ||
@Delete('user/:userId/avatar') | ||
async deleteAvatar(@Param('userId', ParseIntPipe) userId: number) { | ||
return lastValueFrom(this.usersClient.send(RMQ_CMD.DELETE_AVATAR_BY_ID, userId)) | ||
} | ||
} |
File renamed without changes.
18 changes: 0 additions & 18 deletions
18
apps/gateway/src/infrastructure/environment/environment.service.spec.ts
This file was deleted.
Oops, something went wrong.
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
7 changes: 3 additions & 4 deletions
7
...nfrastructure/rabbitmq/rabbitmq.module.ts → ...rastructure/rabbit-mq/rabbit-mq.module.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
11 changes: 0 additions & 11 deletions
11
apps/gateway/src/infrastructure/services/services.module.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.