-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (31 loc) · 1.23 KB
/
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
35
36
37
38
39
40
41
42
'use strict';
var moment = require('moment');
exports.handler = (event, context, callback) => {
var originURL = process.env.ORIGIN_URL || '*';
emitLambdaAge();
// This variable can be updated and checked in to your repository
// to update the number of SAM squirrels on the screen.
var samCount = 5;
// Or you can update your Lambda function's environment variable.
var samMultiplier = process.env.SAM_MULTIPLIER || 1;
var totalSAMs = samCount * samMultiplier;
console.log('The number of SAMs to show: ' + samCount);
console.log('Multiplier to apply to SAMs: ' + samMultiplier);
console.log('Total number of SAMs to show: ' + totalSAMs);
callback(null, {
"statusCode": 200,
"body": totalSAMs,
"headers":
{
"Access-Control-Allow-Headers": "Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token",
"Access-Control-Allow-Methods": "GET,OPTIONS",
"Access-Control-Allow-Origin": originURL
}
});
}
function emitLambdaAge() {
var now = moment();
var lambdaAnnouncement = moment('2014-11-04');
var daysOld = now.diff(lambdaAnnouncement, 'days');
console.log('Lambda is ' + daysOld + ' days old!');
}