forked from Ynov/ptitspas-ynov-back
edited swagger link
This commit is contained in:
parent
f70f614dd1
commit
546a77c8a8
@ -21,13 +21,9 @@ async function bootstrap() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
const document = SwaggerModule.createDocument(app, config);
|
const document = SwaggerModule.createDocument(app, config);
|
||||||
SwaggerModule.setup('api/docs', app, document);
|
SwaggerModule.setup('api-docs', app, document);
|
||||||
|
|
||||||
|
|
||||||
const reflector = app.get(Reflector);
|
|
||||||
app.useGlobalGuards(
|
|
||||||
new AuthGuard(app.get(JwtService), app.get(Reflector)),
|
|
||||||
new RolesGuard(app.get(Reflector))
|
|
||||||
);
|
|
||||||
|
|
||||||
await app.listen(port);
|
await app.listen(port);
|
||||||
console.log(`✅ P'titsPas API is running on: ${await app.getUrl()}`);
|
console.log(`✅ P'titsPas API is running on: ${await app.getUrl()}`);
|
||||||
|
|||||||
@ -1,24 +1,39 @@
|
|||||||
import { Body, Controller, Post } from '@nestjs/common';
|
import { Body, Controller, Post, UseGuards } from '@nestjs/common';
|
||||||
import { LoginDto } from '../user/dto/login.dto';
|
import { LoginDto } from '../user/dto/login.dto';
|
||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
import { Public } from 'src/common/decorators/public.decorator';
|
import { Public } from 'src/common/decorators/public.decorator';
|
||||||
import { RegisterDto } from '../user/dto/register.dto';
|
import { RegisterDto } from '../user/dto/register.dto';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { AuthGuard } from 'src/common/guards/auth.guard';
|
||||||
|
|
||||||
@ApiTags('Authentification')
|
@ApiTags('Authentification')
|
||||||
@Controller('auth')
|
@Controller('auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
constructor(private readonly authService: AuthService) {}
|
constructor(private readonly authService: AuthService) {}
|
||||||
|
|
||||||
@Public()
|
@ApiOperation({ summary: 'Connexion' })
|
||||||
@Post('login')
|
@Post('login')
|
||||||
async login(@Body() dto: LoginDto) {
|
async login(@Body() dto: LoginDto) {
|
||||||
return this.authService.login(dto);
|
return this.authService.login(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Public()
|
|
||||||
@Post('register')
|
@Post('register')
|
||||||
|
@ApiOperation({ summary: 'Inscription' })
|
||||||
async register(@Body() dto: RegisterDto) {
|
async register(@Body() dto: RegisterDto) {
|
||||||
return this.authService.register(dto);
|
return this.authService.register(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('refresh')
|
||||||
|
@ApiOperation({ summary: 'Rafraichir les tokens' })
|
||||||
|
async refresh(@Body('refresh_token') refreshToken: string) {
|
||||||
|
return this.authService.refreshTokens(refreshToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Get('me')
|
||||||
|
// @UseGuards(AuthGuard)
|
||||||
|
// @ApiBearerAuth('access-token')
|
||||||
|
// @ApiOperation({ summary: "Recuperer le profil de l'utilisateur connecte"})
|
||||||
|
// getProfile(@Request() req) {
|
||||||
|
// return req.user;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user