-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lambda.js
35 lines (30 loc) · 991 Bytes
/
lambda.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
const { createServer, proxy } = require('aws-serverless-express');
const { init } = require('./dist/app');
const { Pool } = require('@churchapps/apihelper');
const { Environment } = require('./dist/helpers/Environment');
const { ScheduleHelper } = require('./dist/helpers/ScheduleHelper');
const checkPool = async () => {
if (!Environment.connectionString) {
await Environment.init(process.env.APP_ENV)
Pool.initPool();
}
}
const universal = function universal(event, context) {
checkPool().then(() => {
init().then(app => {
const server = createServer(app);
return proxy(server, event, context);
});
});
}
const nightly = async (event, context) => {
await checkPool();
await ScheduleHelper.handleAutoImports();
}
const timer2Monday = async (event, context) => {
await checkPool();
await ScheduleHelper.updateServiceTimes();
}
module.exports.universal = universal;
module.exports.nightly = nightly;
module.exports.timer2Monday = timer2Monday;