forked from lemoncloud-io/lemon-hello-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.js
37 lines (32 loc) · 1.4 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
/**
* `handler.js`
* - handler to be exported for serverless.
* - ONLY FOR Lambda Deployment.
*
*
* @author Steve Jung <[email protected]>
* @date 2019-07-31 cleanup for ts support.
* @date 2019-08-09 optimized with `lemon-core#1.0.1`
* @date 2019-11-26 optimized with `lemon-core#2.0.0`
*
* @copyright (C) lemoncloud.io 2019 - All Rights Reserved.
*/
/** ********************************************************************************************************************
* Serverless API Handlers
* - optimized to export handler functions for serverless.
* - mainly export API handler which is includes in main loader.
** *******************************************************************************************************************/
//NOTE - 다음이 있어야, Error 발생시 ts파일에서 제대로된 스택 위치를 알려줌!!!.
require('source-map-support').install();
// COMMON ENVIRONMENT LOADER
const $env = process.env || {}; // NOTE! - serverless may initialize environment with opt.
//! SETUP TIMEZONE @2019/03/14
$env.TZ = 'Asia/Seoul';
//! TARGET SOURCE FOLDER.
const SRC = $env.SRC || './dist/';
//! load configuration.
const engine = require(`${SRC}index`).engine;
const $engine = engine();
if (!$engine || !$engine.lambda) throw new Error('.lambda is required! check lemon-core#2.0.0.');
//! export as serverless handlers.
module.exports = $engine;