Created
May 27, 2020 03:46
-
-
Save sofyan-ahmad/b6b1355c5aba6714b009d55a29647705 to your computer and use it in GitHub Desktop.
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
import {Body, Controller, Get, Post, Render} from '@nestjs/common'; | |
import {GoogleApiService} from './googleApi.service'; | |
@Controller() | |
export class GoogleApiController { | |
constructor(private readonly service: GoogleApiService) {} | |
@Get('authorize') | |
@Render('main') | |
authorize(): {message: string; link: string; view: string} { | |
return {...this.service.generateNewAuthUrl(), view: 'authorize'}; | |
} | |
@Post('authorize') | |
async setAuthorizationCode(@Body() body: {code: string}): Promise<string> { | |
await this.service.setNewToken(body.code); | |
return 'Google authorization code saved'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment