feat: app module implement guard, interceptor, error handler
parent
b2a172c47a
commit
e2e031a0fc
|
@ -0,0 +1,39 @@
|
||||||
|
import { Module, Scope } from '@nestjs/common';
|
||||||
|
import { RefreshTokenInterceptor, SessionModule } from './core/sessions';
|
||||||
|
import { AuthModule } from './auth/auth.module';
|
||||||
|
import { JWTGuard } from './core/guards';
|
||||||
|
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
|
||||||
|
import { HttpExceptionFilter, TransformInterceptor } from './core/response';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [SessionModule, AuthModule],
|
||||||
|
controllers: [],
|
||||||
|
providers: [
|
||||||
|
/**
|
||||||
|
* By default all request from client will protect by JWT
|
||||||
|
* if there is some endpoint/function that does'nt require authentication
|
||||||
|
* please add `@Unprotected()` decorator to the function
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
provide: APP_GUARD,
|
||||||
|
scope: Scope.REQUEST,
|
||||||
|
useClass: JWTGuard,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: APP_INTERCEPTOR,
|
||||||
|
scope: Scope.REQUEST,
|
||||||
|
useClass: RefreshTokenInterceptor,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: APP_INTERCEPTOR,
|
||||||
|
scope: Scope.REQUEST,
|
||||||
|
useClass: TransformInterceptor,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: APP_FILTER,
|
||||||
|
scope: Scope.REQUEST,
|
||||||
|
useClass: HttpExceptionFilter,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
Loading…
Reference in New Issue