edited swagger link
This commit is contained in:
parent
f70f614dd1
commit
546a77c8a8
16
src/main.ts
16
src/main.ts
@ -14,20 +14,16 @@ async function bootstrap() {
|
||||
|
||||
const port = configService.get<number>('app.port', 3000);
|
||||
app.setGlobalPrefix('api/v1');
|
||||
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle("P'titsPas API")
|
||||
.setVersion('1.0.0')
|
||||
.build();
|
||||
.setTitle("P'titsPas API")
|
||||
.setVersion('1.0.0')
|
||||
.build();
|
||||
|
||||
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);
|
||||
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 { AuthService } from './auth.service';
|
||||
import { Public } from 'src/common/decorators/public.decorator';
|
||||
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')
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
constructor(private readonly authService: AuthService) {}
|
||||
|
||||
@Public()
|
||||
@ApiOperation({ summary: 'Connexion' })
|
||||
@Post('login')
|
||||
async login(@Body() dto: LoginDto) {
|
||||
return this.authService.login(dto);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Post('register')
|
||||
@ApiOperation({ summary: 'Inscription' })
|
||||
async register(@Body() dto: RegisterDto) {
|
||||
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