nestjs-basic-auth
v0.1.0
Published
HTTP basic auth middleware for NestJS
Downloads
14
Readme
Overview
By using this package, you can place a basic auth on any address in the NestJS framework to prevent unauthorized access.
For example, you can set a username and password to the Swagger document.
Getting Started
npm install nestjs-basic-auth
or
yarn add nestjs-basic-auth
Example
The module exports a function that, when called with an options object, returns the middleware.
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { basicAuth } from 'nestjs-basic-auth';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.use(
['/docs'],
basicAuth({
challenge: true,
users: { admin: 'password' },
}),
);
await app.listen(3000);
}
bootstrap();