-
Notifications
You must be signed in to change notification settings - Fork 3
/
handler.js
39 lines (34 loc) · 1.31 KB
/
handler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
// 사용할 모듈 선언
const dbModule = require('./module/db_module');
const redisModule = require('./module/redis_module');
const httpModule = require('./module/http_module');
// function hello
module.exports.hello = async event => {
const[redisResult, dbResult, httpResult] = await Promise.all([redisModule.setGetByRedis(), dbModule.getCommentByDB(), httpModule.getUsersByHttp()]);
console.log("1. REDIS RESULT");
console.log(redisResult);
console.log("2. DB RESULT");
if(dbResult) {
dbResult.forEach(comment => {
console.log("id = %d, comment = %s", comment.id, comment.comment);
});
}
console.log("3. HTTP RESULT");
if(httpResult) {
httpResult.forEach(user => {
console.log("id = %d, name = %s, email = %s", user.id, user.name, user.email);
});
}
};
// function user
module.exports.user = async event => {
if(event.headers)
console.log("Request Header -> User-Agent :", event.headers['User-Agent']);
if(event.body)
console.log("Request Body ->", event.body);
if(event.pathParameters && event.pathParameters.id)
console.log("Reqeust PathParameter -> id :", event.pathParameters.id);
if(event.queryStringParameters && event.queryStringParameters.isValid)
console.log("Request queryString -> isValid :",event.queryStringParameters.isValid);
};