-
Notifications
You must be signed in to change notification settings - Fork 235
/
Copy pathapi.js
41 lines (36 loc) · 1.07 KB
/
api.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
/*global module, require */
var ApiBuilder = require('claudia-api-builder'),
ask = require('./ask'),
EventLogger = require('./eventlogger'),
api = new ApiBuilder();
module.exports = api;
api.get('/', function (request) {
'use strict';
var logger = new EventLogger(request, request.env.analyticsAppId),
name = request.queryString.name || '';
return logger.logEvent('executed', { name: name }, { length: name.length }).then(function () {
if (name) {
return 'Logged for ' + name;
} else {
return 'Logged empty request. Specify ?name= to log with a name';
}
});
});
api.addPostDeployStep('analyticsConfig', function (options, lambdaDetails, utils) {
'use strict';
if (options['configure-analytics']) {
return ask('Mobile Analytics ID', utils.Promise)
.then(function (appId) {
var deployment = {
restApiId: lambdaDetails.apiId,
stageName: lambdaDetails.alias,
variables: {
analyticsAppId: appId
}
};
return utils.apiGatewayPromise.createDeploymentPromise(deployment).then(function () {
return appId;
});
});
}
});