Skip to content

Instantly share code, notes, and snippets.

View immatobi's full-sized avatar
💭
I may be slow to respond.

Oluwatobi Immanuel immatobi

💭
I may be slow to respond.
View GitHub Profile
@immatobi
immatobi / Auth-Middleware
Created April 21, 2023 02:21
A middleware that protects API endpoints and check if user is logged-in and authorized to access a route.
import ErrorResponse from '../utils/error.util';
import { Request, Response, NextFunction } from 'express'
import User from '../models/User.model'
import { IRedisConnOptions ,asyncHandler, protect as AuthCheck, authorize as Authorize } from '@btffamily/gamr-common';
declare global {
namespace Express{
interface Request{
user?: any;