Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* specify language as JavaScript * default template 'default' * mount current directory as 'function' * move simple template to default * use 'function' for user-app * prettify and remove duplicate in tests * default template updates Print event to log by default to enable demo of updating to return. Check for an invalid context to facilitate test examples. * default package.json dependencies etc. * default template tests * set health and liveness endpoints * simply log the context on invocation * explicitly set run and debug kill to true
- Loading branch information
Showing
12 changed files
with
71 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
FROM node:12 | ||
|
||
ENV APPSODY_PROJECT_DIR=/project | ||
ENV APPSODY_MOUNTS=/:/project/user-app | ||
ENV APPSODY_DEPS=/project/user-app/node_modules | ||
ENV APPSODY_MOUNTS=.:/project/function | ||
ENV APPSODY_DEPS=/project/function/node_modules | ||
|
||
ENV APPSODY_WATCH_DIR=/project/user-app | ||
ENV APPSODY_WATCH_IGNORE_DIR=/project/user-app/node_modules | ||
ENV APPSODY_WATCH_DIR=/project/function | ||
ENV APPSODY_WATCH_IGNORE_DIR=/project/function/node_modules | ||
ENV APPSODY_WATCH_REGEX="^.*.js$" | ||
|
||
ENV APPSODY_TEST="npm test && npm test --prefix function" | ||
ENV APPSODY_TEST_ON_CHANGE="" | ||
ENV APPSODY_TEST_KILL=false | ||
|
||
ENV APPSODY_RUN="npm start" | ||
ENV APPSODY_RUN_ON_CHANGE="npm start" | ||
ENV APPSODY_RUN_ON_CHANGE="$APPSODY_RUN" | ||
ENV APPSODY_RUN_KILL=true | ||
|
||
ENV APPSODY_DEBUG="npm start --node-options --inspect=0.0.0.0" | ||
ENV APPSODY_DEBUG_ON_CHANGE="npm start --node-options --inspect=0.0.0.0" | ||
ENV APPSODY_DEBUG_ON_CHANGE="$APPSODY_DEBUG" | ||
ENV APPSODY_DEBUG_KILL=true | ||
|
||
ENV APPSODY_TEST="npm test && npm test --prefix user-app" | ||
ENV APPSODY_TEST_ON_CHANGE="" | ||
ENV APPSODY_TEST_KILL=false | ||
|
||
ENV APPSODY_PREP="npm install --prefix user-app && npm audit fix --prefix user-app" | ||
ENV APPSODY_PREP="npm install --prefix function && npm audit fix --prefix function" | ||
|
||
COPY ./LICENSE /licenses/ | ||
COPY ./project /project | ||
COPY ./config /config | ||
|
||
WORKDIR /project | ||
RUN npm install --no-package-lock | ||
|
||
ENV PORT=8080 | ||
ENV NODE_PATH=/project/user-app/node_modules | ||
ENV NODE_PATH=/project/function/node_modules | ||
|
||
EXPOSE 8080 | ||
EXPOSE 9229 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
name: Node.js Cloud Events | ||
name: JavaScript FaaS | ||
version: 0.0.1 | ||
description: Serverless Node.js function runtime for Cloud Events | ||
description: Node.js Function Runtime | ||
license: Apache-2.0 | ||
language: nodejs | ||
language: JavaScript | ||
maintainers: | ||
- name: Lance Ball | ||
email: lball@redhat.com | ||
github-id: lance | ||
default-template: simple | ||
default-template: default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = function(context) { | ||
context.log.info(context); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "event-handler", | ||
"version": "0.1.0", | ||
"description": "Node.js CloudEvent Handler", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "" | ||
}, | ||
"scripts": { | ||
"test": "node test/*.js" | ||
}, | ||
"devDependencies": { | ||
"tape": "^4.13.0", | ||
"cloudevents-sdk": "^1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const func = require('..'); | ||
const test = require('tape'); | ||
const cloudevents = require('cloudevents-sdk/v1'); | ||
|
||
// Ensure that the function completes cleanly when passed a valid event. | ||
test('Handles a valid event', t => { | ||
// A valid event includes id, type and source at a minimum. | ||
let e = cloudevents.event(); | ||
e.id('TEST-EVENT-01'); | ||
e.type('com.example.cloudevents.test'); | ||
e.source('http://localhost:8080/'); | ||
|
||
// Invoke the function with the valid event, which should compelte without error. | ||
func({ cloudevent: e }); | ||
t.end(); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.