Skip to content

Commit

Permalink
Made azure template boilerplate code consistent in serverless as per s…
Browse files Browse the repository at this point in the history
  • Loading branch information
cmatskas committed May 3, 2017
1 parent 862ecb5 commit 7a2fb88
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/plugins/create/templates/azure-nodejs/handler.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
'use strict';

module.exports.hello = function (context, req) {
// Add any necessary telemetry to support diagnosing your function
context.log('HTTP trigger occured!');
context.log('JavaScript HTTP trigger function processed a request.');

// Read properties from the incoming request, and respond as appropriate.
const name = req.query.name || (req.body && req.body.name) || 'World';
context.done(null, { body: `Hello ${name}` });
if (req.query.name || (req.body && req.body.name)) {
context.res = {
// status: 200, /* Defaults to 200 */
body: "Hello " + (req.query.name || req.body.name)
};
}
else {
context.res = {
status: 400,
body: "Please pass a name on the query string or in the request body"
};
}
context.done();
};

0 comments on commit 7a2fb88

Please sign in to comment.