-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add joined at date for searched user * Update user search query to respect respect http standards * Correct relations * Check if users are connected when doing an user search * fix db structure * Fix: is connection should be true when userId is in the followers * Do not use mutler for uploading profile pics * Context: React native web sends base64 images that cannot be parsed by mutler * update review properties * add get user endpoint * use headline insted of jobtitle * remove console logs * remove console log * Move reviwes in dedicated controller. * Rename ratings to reviews * Use ratings only for professionalism/communication/reliability * Create reviews controller and service * Remove route with */self. * enable swagger plugin * review db structure changes: * change id from int to string * add state * add favorite review model * Add ability to like/unlike reviews and review state * add ability to modify and update own review * feat: add connections controller and move specific endpoints from user controller here * fix: review annonymous property * fix: add isEmailVerified to connection * fix rebase errors * Move search by profile url in connections. * Add authType property on connectionDto * remove jobTitle property. Use headline everywhere * Return transformed user when social account is already existen * add logging * fix reviews issues * rename dto folder * rename methods * make only one DB query for craeting a connection * change DTO folder to a random name (because gh is not case sensitive and doesn't see lowering the case of the file as an actual change) * rename dto folder * squash migrations * fix tests
- Loading branch information
1 parent
6fe638b
commit fd45bbe
Showing
35 changed files
with
1,602 additions
and
743 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
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
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,21 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { ConnectionsController } from './connections.controller'; | ||
import { ConnectionsService } from './connections.service'; | ||
import { PrismaService } from '../../src/prisma/prisma.service'; | ||
|
||
describe('ConnectionsController', () => { | ||
let controller: ConnectionsController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [ConnectionsController], | ||
providers: [ConnectionsService, PrismaService], | ||
}).compile(); | ||
|
||
controller = module.get<ConnectionsController>(ConnectionsController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
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,97 @@ | ||
import { Controller, Delete, Get, Param, Post } from '@nestjs/common'; | ||
import { CurrentUser } from '../../src/decorators/current-user.decorator'; | ||
import { ConnectionsService } from './connections.service'; | ||
import { ConnectionDto } from './dto/Connection.dto'; | ||
import { | ||
ApiBadRequestResponse, | ||
ApiBearerAuth, | ||
ApiNotFoundResponse, | ||
} from '@nestjs/swagger'; | ||
import { User } from '@prisma/client'; | ||
import { Public } from '../../src/decorators/public.decorator'; | ||
|
||
@ApiBearerAuth() | ||
@Controller('connections') | ||
export class ConnectionsController { | ||
constructor(private connectionsService: ConnectionsService) {} | ||
/** | ||
* | ||
* Get all of the current user's connections | ||
*/ | ||
@Get() | ||
async getAllConnections(@CurrentUser() user: User): Promise<ConnectionDto[]> { | ||
return this.connectionsService.getUserConnections(user.id); | ||
} | ||
|
||
/** | ||
* Get "suggested for review" connections. | ||
*/ | ||
@Get('/suggested') | ||
async getSuggestedConnections( | ||
@CurrentUser() user: User, | ||
): Promise<ConnectionDto[]> { | ||
return this.connectionsService.getUserConnections(user.id); | ||
} | ||
|
||
/** | ||
* Search an user by query. | ||
*/ | ||
@Get('/search/:query') | ||
@Public() | ||
@ApiBadRequestResponse() | ||
async searchUser( | ||
@Param('query') query: string, | ||
@CurrentUser() user?: User, | ||
): Promise<ConnectionDto[]> { | ||
return this.connectionsService.searchUsers(user?.id, query); | ||
} | ||
|
||
/** | ||
* Create a connection between current User and another user. | ||
*/ | ||
@Post('/connect/:userId') | ||
async connectWithUser( | ||
@CurrentUser() user: User, | ||
@Param('userId') userId: string, | ||
): Promise<ConnectionDto> { | ||
return this.connectionsService.addConnection(user.id, userId); | ||
} | ||
/** | ||
* | ||
* Remove connection between current user and another user. | ||
*/ | ||
@Delete('/connect/:userId') | ||
async unconnectWithUser( | ||
@CurrentUser() user: User, | ||
@Param('userId') userId: string, | ||
): Promise<ConnectionDto> { | ||
return this.connectionsService.removeConnection(user.id, userId); | ||
} | ||
|
||
/** | ||
* Search for users by external profile URL | ||
* @param profileUrlBase64 | ||
*/ | ||
|
||
@Public() | ||
@Get('search-by-external-profile/:profileUrl') | ||
async searchUsersByExternalProfile( | ||
@Param('profileUrl') profileUrlBase64: string, | ||
) { | ||
return this.connectionsService.searchUserByExternalProfile( | ||
profileUrlBase64, | ||
); | ||
} | ||
|
||
/** | ||
* Get a connection. | ||
*/ | ||
@Get('/:userId') | ||
@ApiNotFoundResponse() | ||
async getUser( | ||
@CurrentUser() user: User, | ||
@Param('userId') userId: string, | ||
): Promise<ConnectionDto> { | ||
return this.connectionsService.getConnection(userId, user.id); | ||
} | ||
} |
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,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ConnectionsService } from './connections.service'; | ||
import { ConnectionsController } from './connections.controller'; | ||
|
||
@Module({ | ||
providers: [ConnectionsService], | ||
controllers: [ConnectionsController], | ||
}) | ||
export class ConnectionsModule {} |
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,19 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { ConnectionsService } from './connections.service'; | ||
import { PrismaService } from '../../src/prisma/prisma.service'; | ||
|
||
describe('ConnectionsService', () => { | ||
let service: ConnectionsService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ConnectionsService, PrismaService], | ||
}).compile(); | ||
|
||
service = module.get<ConnectionsService>(ConnectionsService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.