Skip to content

Netflix-Nest/Netflix-Common

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@netflix-clone/common

npm version npm downloads license

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/common

Peer dependencies (must be installed in your NestJS project):

npm install @nestjs/common @nestjs/core @nestjs/passport @nestjs/microservices @nestjs/cache-manager rxjs

Usage

  1. 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!' };
  }
}
  1. 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;
  }
}
  1. 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' }];
  }
}
  1. 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 😎.

About

Shared Guards, Interceptors, Decorators, and Exception Filters for Netflix Clone

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors