Last active
May 18, 2019 14:45
-
-
Save seanpmaxwell/2cc9328ffabf23f52833eedb98acc167 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller, Middleware, Get } from '@overnightjs/core' | |
import { jwt, jwtmiddleware, SecureRequest } from '@overnightjs/jwt' | |
import { Request, Response } from 'express' | |
import { ParentController } from './ParentController' | |
@Controller('api/jwt') | |
export class UserController extends ParentController { | |
@Get('getjwt/:email') | |
private getJwt(req: Request, res: Response): void { | |
let jwtStr = jwt({ | |
email: req.params.email | |
}); | |
res.status(200).json({jwt: jwtStr}); | |
} | |
@Get('callProtectedRoute') | |
@Middleware(jwtmiddleware) | |
private callProtectedRoute(req: SecureRequest, res: Response): void { | |
res.status(200).json({email: req.payload.email}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment