@netflix-clone/common
v1.2.0
Published
Shared filters, interceptors, decorators, guards, and exception handlers for Netflix Clone
Maintainers
Readme
@netflix-clone/common
Shared Guards, Interceptors, Decorators, and Exception Filters for Netflix Clone
A reusable NestJS package to keep your microservices consistent and DRY (Don’t Repeat Yourself).
Features
- Guards: JWT Auth Guard, Local Auth Guard
- Decorators:
@Public(),@SkipCheckPermission(),@User() - Interceptors: Logging, Caching, Transform response
- Filters: Global exception filter (support both HTTP & RPC)
- Designed for NestJS microservices architecture
Installation
npm install @netflix-clone/common
# or
yarn add @netflix-clone/commonPeer dependencies (must be installed in your NestJS project):
npm install @nestjs/common @nestjs/core @nestjs/passport @nestjs/microservices @nestjs/cache-manager rxjsUsage
- Guards
import { JwtAuthGuard, LocalAuthGuard } from '@netflix-clone/common';
import { Controller, Get, UseGuards } from '@nestjs/common';
@Controller('profile')
export class ProfileController {
@UseGuards(JwtAuthGuard)
@Get()
getProfile() {
return { message: 'Protected route with JWT!' };
}
}- Decorators
import { Controller, Get } from '@nestjs/common';
import { Public, User } from '@netflix-clone/common';
@Controller('auth')
export class AuthController {
@Public()
@Get('login')
login() {
return { message: 'Public endpoint (no JWT required)' };
}
@Get('me')
getMe(@User() user: any) {
return user;
}
}
- Interceptors
import { Controller, Get, UseInterceptors } from '@nestjs/common';
import { LoggingInterceptor, TransformInterceptor, CacheInterceptor } from '@netflix-clone/common';
@Controller('movies')
@UseInterceptors(LoggingInterceptor, TransformInterceptor, CacheInterceptor)
export class MovieController {
@Get()
findAll() {
return [{ id: 1, title: 'Inception' }];
}
}- Exception Filters
import { AllExceptionsFilter } from '@netflix-clone/common';
import { APP_FILTER } from '@nestjs/core';
@Module({
providers: [
{
provide: APP_FILTER,
useClass: AllExceptionsFilter,
},
],
})
export class AppModule {}License
MIT © 2025 Cao Nguyen Tri Ngoc 😎.
