node.js

nestjs swagger ๋ณด์•ˆ์„ค์ •ํ•˜๊ธฐ

dev_summer 2022. 4. 6. 14:47

main.ts

const basicAuth = require('express-basic-auth');
  app.use(
    ['/api'],
    basicAuth({
      challenge: true,
      users: {
        [process.env.SWAGGER_USER]: process.env.SWAGGER_PASSWORD,
      },
    }),
  );

 

ํŠน์ •ํ•œ url์— ์•„๋ž˜์™€ ๊ฐ™์€ ๋ณด์•ˆ์„ ์„ค์ •ํ• ์ˆ˜์žˆ๋Š” ๋ชจ๋“ˆ๊ณผ ์ฝ”๋“œ

์Šค์›จ๊ฑฐ๋ฅผ ์„ค์ •ํ• ๋•Œ  api๊ฐ€ ๊ธฐ๋ณธ ๊ฒฝ๋กœ๊ธฐ๋•Œ๋ฌธ์— ์ด ๊ฒฝ๋กœ์ผ๋•Œ  ์•„๋ž˜์™€ ๊ฐ™์€ ๋ณด์•ˆ์ด ๊ฑธ๋ฆฌ๊ฒŒ๋œ๋‹ค.

๋ณดํ†ต ์ด๋Š” ํ™˜๊ฒฝ๋ณ€์ˆ˜ํŒŒ์ผ์—์„œ ์„ค์ •ํ•˜์—ฌ ๋ถˆ๋Ÿฌ์™€์„œ ์‚ฌ์šฉ ํ•˜๋ฉด ๋œ๋‹ค.