Skip to content

Instantly share code, notes, and snippets.

@harbirchahal
harbirchahal / app.module.ts
Created May 15, 2019 11:54
Request Timeout HTTP Interceptor (Header)
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { RequestTimeoutHttpInterceptor, DEFAULT_TIMEOUT } from './interceptors';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule,
HttpClientModule,
@harbirchahal
harbirchahal / timeout.interceptor.ts
Last active May 14, 2019 14:15
Request Timeout HTTP Interceptor
import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
import { empty, TimeoutError } from 'rxjs';
import { timeout, catchError } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class RequestTimeoutHttpInterceptor implements HttpInterceptor {
@harbirchahal
harbirchahal / unauthorized.interceptor.ts
Last active May 14, 2019 14:15
Unauthorized Request HTTP Interceptor
import { Injectable } from '@angular/core';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { tap } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class UnauthorizedHttpInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler) {
@harbirchahal
harbirchahal / nginx_restart.bat
Last active April 28, 2021 10:39
Restart Nginx Process
@echo off
cd /nginx
taskkill /f /IM nginx.exe
start nginx
exit
@harbirchahal
harbirchahal / nginx_stop.bat
Last active April 28, 2021 10:39
Stop Nginx Process
@echo off
cd /nginx
taskkill /f /IM nginx.exe
exit
import { Injectable } from '@angular/core';
import { BehaviorSubject, Subscription, Observable } from 'rxjs';
import { interval } 'rxjs/operators';
@Injectable()
export class IntervalService {
private subject = new BehaviorSubject<number>(-1);
private subscription: Subscription;
readonly observable$ = this.subject.asObservable();