📦 EqualifyEverything / equalify

📄 event.ts · 20 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20export let event = {
    httpMethod: '',
    path: '',
    queryStringParameters: {},
    body: {},
    requestContext: {},
};

export const setEvent = (rawEvent) => {
    try {
        rawEvent.body ? rawEvent.rawBody = rawEvent.body : null;
        rawEvent.body ? rawEvent.body = JSON.parse(rawEvent.body) : null;
        rawEvent.rawPath ? rawEvent.path = rawEvent.rawPath : null;
        !rawEvent.httpMethod ? rawEvent.httpMethod = rawEvent.requestContext?.http?.method : null;
    }
    catch { }

    event = rawEvent;
    return event;
}