UNPKG

generator-kube-microservice-node

Version:

A k8s micro-service generator with deployment, service, Dockerfile. Built with express/mongo/redis

29 lines (26 loc) 856 B
import { Request, Response } from 'express'; import env from '../config/env'; import AuthException from '../shared/exceptions/AuthException'; import injectionContainer from '../config/inversify.config'; import RemoteController from '../shared/class/RemoteController'; import REFERENCES from '../config/inversify.references'; const remoteController = injectionContainer.get<RemoteController>( REFERENCES.RemoteController, ); export default async (req: Request, res: Response, next) => { const { authorization } = req.headers; try { if (req.originalUrl.includes('/health')) { next(); return; } await remoteController.get(`${env.service_auth}/auth`, { headers: { Authorization: authorization, }, }); next(); } catch (e) { next(new AuthException(AuthException.JWTExpiredOrNotReceived)); } };