Created
January 25, 2021 22:05
-
-
Save s-barrah/6d646efed3e1998c2fe5ab72808d665e to your computer and use it in GitHub Desktop.
This file contains 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 { | |
APIGatewayAuthorizerEvent, | |
Context, | |
Callback | |
} from 'aws-lambda'; | |
import AuthService from "../../services/auth.service"; | |
export const jwtAuth = async (event: APIGatewayAuthorizerEvent, _context: Context, callback: Callback) => { | |
const authService = new AuthService(); | |
let response; | |
try { | |
response = await authService.authenticate(event); | |
} | |
catch (err) { | |
callback("Unauthorized"); // Return a 401 Unauthorized response | |
} | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment