-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.js
More file actions
55 lines (48 loc) · 1.4 KB
/
handler.js
File metadata and controls
55 lines (48 loc) · 1.4 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
const { migrateDB } = require('./app');
const { importStatement, exportStatement } = require('./app');
/*
* Migrate database tables
*/
module.exports.migrateDB = (event, context, callback) => {
// run database migrations with force param
migrateDB(true)
.then(response => {
callback(null, { statusCode: 200, body: JSON.stringify(response) });
})
.catch(err => {
callback(null, { statusCode: 500, body: JSON.stringify(err) });
});
};
/*
* Import monthly statements
*/
module.exports.importStatement = (event, context, callback) => {
// set parameters
const account = event.pathParameters.account;
const date = event.pathParameters.date;
// import statement
importStatement(account, date)
.then(response => {
callback(null, { statusCode: 200, body: JSON.stringify(response) });
})
.catch(err => {
callback(null, { statusCode: 500, body: JSON.stringify(err) });
});
};
/*
* Export monthly statements
*/
module.exports.exportStatement = (event, context, callback) => {
// set parameters
const account = event.pathParameters.account;
const date = event.pathParameters.date;
// export statement
exportStatement(account, date)
.then(response => {
callback(null, { statusCode: 200, body: JSON.stringify(response) });
})
.catch(err => {
callback(null, { statusCode: 500, body: JSON.stringify(err) });
});
};