fix: return JSON in Node.js event template (#211)

The event template was just returning a string, but the default response
content type is application/json so browsers were failing to parse the string
as JSON.

Signed-off-by: Lance Ball <lball@redhat.com>
This commit is contained in:
Lance Ball 2020-11-06 10:46:53 -05:00 committed by GitHub
parent 470ebb9da4
commit beb838ff43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -19,13 +19,15 @@ const { CloudEvent, HTTP } = require('cloudevents');
*
* const incomingEvent = context.cloudevent;
*
* @param {Context} context the invocation context
* @param {Object} user the CloudEvent data. If the data content type is application/json
* this will be converted to an Object via JSON.parse()
* @param {Context} context the invocation context
*/
function verifyUser(context, user) {
if (!context.cloudevent) {
return 'No cloud event received';
return {
message: 'No cloud event received'
};
}
context.log.info('Processing user', user);