Skip to content

Commit 0e99e9e

Browse files
committed
add inspect function
1 parent b1c1ced commit 0e99e9e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

index.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var _getAllFilesFromFolder = function (dir) {
2+
var filesystem = require("fs");
3+
var results = [];
4+
5+
filesystem.readdirSync(dir).forEach(function (file) {
6+
file = dir + "/" + file;
7+
var stat = filesystem.statSync(file);
8+
9+
if (stat && stat.isDirectory()) {
10+
results = results.concat(_getAllFilesFromFolder(file));
11+
} else results.push(file);
12+
});
13+
14+
return results;
15+
};
16+
17+
module.exports.handler = async (event) => {
18+
const dir = event.dir || "/";
19+
return {
20+
statusCode: 200,
21+
body: JSON.stringify(
22+
{
23+
message: JSON.stringify(_getAllFilesFromFolder(dir)),
24+
input: event,
25+
},
26+
null,
27+
2
28+
),
29+
};
30+
};

serverless.yml

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ provider:
3535
STAGE: ${self:provider.stage}
3636

3737
functions:
38+
inspect:
39+
handler: index.handler
3840
github:
3941
handler: src/lambda.handler
4042
timeout: 29

0 commit comments

Comments
 (0)