HM-110. Научили свагер работать с токенами
This commit is contained in:
@ -13,7 +13,7 @@ const initAdmin = async () => {
|
|||||||
password: String,
|
password: String,
|
||||||
is_admin: Boolean,
|
is_admin: Boolean,
|
||||||
});
|
});
|
||||||
|
|
||||||
const Model = mongoose.model('users', schema);
|
const Model = mongoose.model('users', schema);
|
||||||
await Model.deleteOne({login: 'admin'});
|
await Model.deleteOne({login: 'admin'});
|
||||||
const salt = await bcrypt.genSalt(10);
|
const salt = await bcrypt.genSalt(10);
|
||||||
@ -33,6 +33,11 @@ async function bootstrap() {
|
|||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
|
|
||||||
const options = new DocumentBuilder()
|
const options = new DocumentBuilder()
|
||||||
|
.addSecurity('apiKey', {
|
||||||
|
type: 'apiKey',
|
||||||
|
in: 'header',
|
||||||
|
name: 'Authorization',
|
||||||
|
})
|
||||||
.setTitle('Auth API')
|
.setTitle('Auth API')
|
||||||
.setDescription('API для авторизации приложений и работы с пользователями')
|
.setDescription('API для авторизации приложений и работы с пользователями')
|
||||||
.setVersion('1.0.0')
|
.setVersion('1.0.0')
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import {Controller, Get, Req, Post, Options, Header, Delete, HttpCode, Put} from '@nestjs/common';
|
import {Controller, Get, Req, Post, Options, Header, Delete, HttpCode, Put} from '@nestjs/common';
|
||||||
|
|
||||||
import {ApiResponse, ApiTags, ApiParam, ApiBody} from '@nestjs/swagger';
|
import {ApiResponse, ApiTags, ApiParam, ApiBody, ApiSecurity} from '@nestjs/swagger';
|
||||||
import {
|
import {
|
||||||
ALLOW_ORIGIN_ALL,
|
ALLOW_ORIGIN_ALL,
|
||||||
ALLOW_METHOD,
|
ALLOW_METHOD,
|
||||||
@ -37,6 +37,7 @@ import {
|
|||||||
} from './users.responses';
|
} from './users.responses';
|
||||||
import {AuthService} from 'src/auth/auth.service';
|
import {AuthService} from 'src/auth/auth.service';
|
||||||
|
|
||||||
|
@ApiSecurity('apiKey')
|
||||||
@Controller(USERS_CONTROLLER)
|
@Controller(USERS_CONTROLLER)
|
||||||
@ApiTags(USERS_CONTROLLER)
|
@ApiTags(USERS_CONTROLLER)
|
||||||
export class UsersController {
|
export class UsersController {
|
||||||
|
|||||||
Reference in New Issue
Block a user