Skip to content

Commit

Permalink
fix: dashboard various fixes (#78)
Browse files Browse the repository at this point in the history
* 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
adelinaenache authored May 27, 2024
1 parent 6fe638b commit fd45bbe
Show file tree
Hide file tree
Showing 35 changed files with 1,602 additions and 743 deletions.
6 changes: 5 additions & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"testEnvironment": "node",
"testPathIgnorePatterns": [".*.e2e.spec.ts"],
"transform": {
"^.+\\.[tj]s$": ["ts-jest", { "tsconfig": "<rootDir>/tsconfig.spec.json" }]
"^.+\\.[tj]s$": ["ts-jest", { "tsconfig": "<rootDir>/tsconfig.spec.json" },
{ "astTransformers": {
"before": ["./utils/e2e-plugin.ts"]
}
}]
},
"moduleFileExtensions": ["ts", "js", "html"],
"coverageDirectory": "./coverage-e2e"
Expand Down
6 changes: 5 additions & 1 deletion jest.e2e-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"testEnvironment": "node",
"testMatch": ["**/*.e2e.spec.ts"],
"transform": {
"^.+\\.[tj]s$": ["ts-jest", { "tsconfig": "<rootDir>/tsconfig.spec.json" }]
"^.+\\.[tj]s$": ["ts-jest", { "tsconfig": "<rootDir>/tsconfig.spec.json" },
{ "astTransformers": {
"before": ["./utils/e2e-plugin.ts"]
}
}]
},
"moduleFileExtensions": ["ts", "js", "html"],
"coverageDirectory": "./coverage-e2e"
Expand Down
11 changes: 10 additions & 1 deletion nest-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
"deleteOutDir": true,
"plugins":[
{
"name": "@nestjs/swagger",
"options": {
"classValidatorShim": false,
"introspectComments": true
}
}
]
}
}
17 changes: 0 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,5 @@
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
13 changes: 11 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Module } from '@nestjs/common';
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { AppController } from './app.controller';
import { AuthModule } from '../auth/auth.module';
import { UserModule } from '../user/user.module';
Expand All @@ -9,6 +9,9 @@ import { AuthGuard } from '../auth/guard/auth/auth.guard';
import { PrismaModule } from '../prisma/prisma.module';
import { MailModule } from '../mail/mail.module';
import { ProviderModule } from '../provider/provider.module';
import { ReviewsModule } from '../../src/reviews/reviews.module';
import { ConnectionsModule } from '../../src/connections/connections.module';
import { AppLoggerMiddleware } from '../../src/middlewares/logger.middleware';
import { CommonModule } from '../common/common.module';

@Module({
Expand All @@ -23,6 +26,8 @@ import { CommonModule } from '../common/common.module';
PrismaModule,
MailModule,
ProviderModule,
ReviewsModule,
ConnectionsModule,
],
controllers: [AppController],
providers: [
Expand All @@ -32,4 +37,8 @@ import { CommonModule } from '../common/common.module';
},
],
})
export class AppModule {}
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer): void {
consumer.apply(AppLoggerMiddleware).forRoutes('*');
}
}
21 changes: 21 additions & 0 deletions src/connections/connections.controller.spec.ts
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();
});
});
97 changes: 97 additions & 0 deletions src/connections/connections.controller.ts
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);
}
}
9 changes: 9 additions & 0 deletions src/connections/connections.module.ts
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 {}
19 changes: 19 additions & 0 deletions src/connections/connections.service.spec.ts
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();
});
});
Loading

0 comments on commit fd45bbe

Please sign in to comment.