- First set up NestJS TypeScrip basic project.
- Install express-basic-auth module using this command: npm i express-basic-auth
- import module on main.ts file
- Full example of main.ts file:
// import auth module
import * as basicAuth from 'express-basic-auth';
// Add HTTP Basic Auth
app.use(
basicAuth({
challenge: true,
users: {
defineUserName: 'passwrd here',
},
}),
);
// Main Code
const options = new DocumentBuilder()
.setTitle('First App')
.setSchemes('https')
.setDescription('Firsy App API documentation')
.setVersion('1.0')
.build()
const document = SwaggerModule.createDocument(app, options)
SwaggerModule.setup('docs', app, document, {
customSiteTitle: 'First App documentation',
});
Enjoy!
Web Development Course in Noida
ReplyDeletehttps://aptronsolutions.home.blog/2022/08/09/web-development-institute-in-noida-web-development-trainng-in-noida/
Great post..Rob Tech World is one of the leading and dependable Web Designer In Punjab. Website Designing Company In Zirakpur
ReplyDeleteNice Post!!
ReplyDeletePlease look here at Content Writing Services in Bangalore
Thanks for this wonderful information AWeb Developer is a professional who is responsible for the design and construction of websites.
ReplyDeleteGreat information, thank you for sharing with us.
ReplyDeleteBest Application Development Company/a>