Init
This commit is contained in:
commit
0029086b3f
148 changed files with 19047 additions and 0 deletions
19
packages/api/src/util/create-authenticated-handler.ts
Normal file
19
packages/api/src/util/create-authenticated-handler.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import serverless from 'serverless-http';
|
||||
import { APIGatewayProxyEventBase } from 'aws-lambda';
|
||||
import { Authorizer, RequestContext } from './request-context.type';
|
||||
import { Application } from 'express';
|
||||
|
||||
const createAuthenticatedHandler = (app: Application) => {
|
||||
const handler = serverless(app, {
|
||||
request(
|
||||
request: RequestContext,
|
||||
event: APIGatewayProxyEventBase<Authorizer>,
|
||||
) {
|
||||
request.context = event.requestContext;
|
||||
request.currentUserSub = `${request.context?.authorizer?.claims?.sub}`;
|
||||
},
|
||||
});
|
||||
return handler;
|
||||
};
|
||||
|
||||
export default createAuthenticatedHandler;
|
Loading…
Add table
Add a link
Reference in a new issue