1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/serverless-nodejs-template.adoc
2021-05-24 21:07:15 +00:00

36 lines
1.3 KiB
Plaintext

// Module included in the following assemblies
//
// * /serverless/functions/serverless-developing-nodejs-functions.adoc
[id="serverless-nodejs-template_{context}"]
= Node.js function template structure
When you create a Node.js function using the `kn` CLI, the project directory looks like a typical Node.js project, with the exception of an additional `func.yaml` configuration file.
Both `http` and `event` trigger functions have the same template structure:
.Template structure
[source,terminal]
----
.
├── func.yaml <1>
├── index.js <2>
├── package.json <3>
├── README.md
└── test <4>
├── integration.js
└── unit.js
----
<1> The `func.yaml` configuration file is used to determine the image name and registry.
<2> Your project must contain an `index.js` file which exports a single function.
<3> You are not restricted to the dependencies provided in the template `package.json` file. You can add additional dependencies as you would in any other Node.js project.
+
.Example of adding npm dependencies
[source,terminal]
----
npm install --save opossum
----
+
When the project is built for deployment, these dependencies are included in the created runtime container image.
<4> Integration and unit test scripts are provided as part of the function template.