-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils.ts
More file actions
24 lines (20 loc) · 676 Bytes
/
Copy pathutils.ts
File metadata and controls
24 lines (20 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { Handler, Context, APIGatewayEvent } from 'aws-lambda'
import querystring from 'querystring'
export const requestParser = (event, context: Context) => {
let params: querystring.ParsedUrlQuery = {}
if (event?.pathParameters?.params)
params = querystring.parse(event.pathParameters.params)
let body: any = {}
if (event.body) body = JSON.parse(event.body)
return {
params,
body,
}
}
export const corsAllowHeader = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true,
'Content-type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Headers':
'Origin, X-Requested-With, Content-Type, Accept',
}