Skip to content

Instantly share code, notes, and snippets.

@s-barrah
Created January 25, 2021 22:05
Show Gist options
  • Save s-barrah/6d646efed3e1998c2fe5ab72808d665e to your computer and use it in GitHub Desktop.
Save s-barrah/6d646efed3e1998c2fe5ab72808d665e to your computer and use it in GitHub Desktop.
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