-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (29 loc) · 882 Bytes
/
index.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
'use strict';
var PGExport = require('./lib/pg-export');
exports.handler = function (event, context, callback) {
var options = {
bucket: 'pgexport-awslambda',
key: event.key,
rds: event.rds,
filters: event.filters || {},
pgurl: event.pgurl
};
var pgExport = new PGExport(options);
var actions = {
exportData: function () {
return pgExport.exportData(event.queries);
},
getExports: function (event) {
return pgExport.getExports(event.prefix);
},
getExportSignedUrl: function (event) {
return pgExport.getExportSignedUrl(event.key);
}
};
actions[event.action](event)
.then(function (result) {
console.log(event.action + ' succeeded ');
callback(null, result);
})
.fail(callback);
};