-
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 #66 from donghquinn/dev
Dev
- Loading branch information
Showing
13 changed files
with
402 additions
and
358 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Body, Controller, Post } from '@nestjs/common'; | ||
import { | ||
searchEmailRequestValidator, | ||
searchPasswordRequestValidator, | ||
validatePasswordTempKeyRequestValidator, | ||
} from '@validators/client/search.validator'; | ||
import { SetErrorResponse, SetResponse } from 'dto/response.dto'; | ||
import { ClientSearchProvider } from 'providers/client/search.pvd'; | ||
import { SearchEmailRequest, SearchPasswordRequest, ValidatePasswordKeyRequest } from 'types/password.type'; | ||
|
||
@Controller('users/search') | ||
export class ClientSearchController { | ||
constructor(private readonly client: ClientSearchProvider) {} | ||
|
||
@Post('email') | ||
async searchEmailController(@Body() request: SearchEmailRequest) { | ||
try { | ||
const { name } = await searchEmailRequestValidator(request); | ||
|
||
const email = await this.client.searchEmail(name); | ||
|
||
return new SetResponse(200, { email }); | ||
} catch (error) { | ||
return new SetErrorResponse(error); | ||
} | ||
} | ||
|
||
@Post('password') | ||
async searchPasswordController(@Body() request: SearchPasswordRequest) { | ||
try { | ||
const { name, email } = await searchPasswordRequestValidator(request); | ||
|
||
const message = await this.client.searchPassword(email, name); | ||
|
||
return new SetResponse(200, { message }); | ||
} catch (error) { | ||
return new SetErrorResponse(error); | ||
} | ||
} | ||
|
||
@Post('password/validate') | ||
async validatePasswordTempKeyController(@Body() request: ValidatePasswordKeyRequest) { | ||
try { | ||
const { tempKey } = await validatePasswordTempKeyRequestValidator(request); | ||
|
||
const message = await this.client.validateSearchingPasswordKey(tempKey); | ||
|
||
return new SetResponse(200, { message }); | ||
} catch (error) { | ||
return new SetErrorResponse(error); | ||
} | ||
} | ||
} |
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,58 @@ | ||
import { Body, Controller, Post } from '@nestjs/common'; | ||
import { clientMyPageStarNewsValidator } from '@validators/client/mypage.validator'; | ||
import { SetErrorResponse, SetResponse } from 'dto/response.dto'; | ||
import { ClientStarProvider } from 'providers/client/star.pvd'; | ||
import { ClientMyPageStarNewsRequest } from 'types/client.type'; | ||
|
||
@Controller('users/star') | ||
export class ClientStarController { | ||
constructor(private readonly client: ClientStarProvider) {} | ||
|
||
@Post('star/hacker') | ||
async getHackerStarNewsController(@Body() request: ClientMyPageStarNewsRequest) { | ||
try { | ||
const { uuid, page } = await clientMyPageStarNewsValidator(request); | ||
|
||
const { totalPosts, hackerNews: hackerStarredNews } = await this.client.myStarredHackerNews(uuid, page); | ||
|
||
return new SetResponse(200, { | ||
totalPosts, | ||
hackerStarredNews, | ||
}); | ||
} catch (error) { | ||
return new SetErrorResponse(error); | ||
} | ||
} | ||
|
||
@Post('star/geek') | ||
async getGeekStarNewsController(@Body() request: ClientMyPageStarNewsRequest) { | ||
try { | ||
const { uuid, page } = await clientMyPageStarNewsValidator(request); | ||
|
||
const { totalPosts, resultNewsArray: geekStarredNews } = await this.client.myStarredGeekNews(uuid, page); | ||
|
||
return new SetResponse(200, { | ||
totalPosts, | ||
geekStarredNews, | ||
}); | ||
} catch (error) { | ||
return new SetErrorResponse(error); | ||
} | ||
} | ||
|
||
@Post('star/ml') | ||
async getMlStarNewsController(@Body() request: ClientMyPageStarNewsRequest) { | ||
try { | ||
const { uuid, page } = await clientMyPageStarNewsValidator(request); | ||
|
||
const { totalPosts, mlNews: mlStarredNews } = await this.client.myStarredMlNews(uuid, page); | ||
|
||
return new SetResponse(200, { | ||
totalPosts, | ||
mlStarredNews, | ||
}); | ||
} catch (error) { | ||
return new SetErrorResponse(error); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { ClientController } from '@controllers/client/client.ctl'; | ||
import { ClientSearchController } from '@controllers/client/search.ctl'; | ||
import { ClientStarController } from '@controllers/client/star.ctl'; | ||
import { MailerModule } from '@modules/mailer.module'; | ||
import { Module } from '@nestjs/common'; | ||
import { ClientProvider } from 'providers/client/client.pvd'; | ||
import { ClientSearchProvider } from 'providers/client/search.pvd'; | ||
import { ClientStarProvider } from 'providers/client/star.pvd'; | ||
import { AccountManagerModule } from './account.module'; | ||
import { ClientPrismaModule } from './client-prisma.module'; | ||
|
||
@Module({ | ||
providers: [ClientProvider], | ||
@Module( { | ||
controllers: [ClientController, ClientSearchController, ClientStarController], | ||
providers: [ClientProvider, ClientSearchProvider, ClientStarProvider], | ||
imports: [AccountManagerModule, ClientPrismaModule, MailerModule], | ||
controllers: [ClientController], | ||
}) | ||
export class ClientModule {} |
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
Oops, something went wrong.