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-typescript-template.adoc
Maxim Svistunov 7dd561f457 Add docs on developing TypeScript functions
Fix section ID

Move TypeScript context object reference to the proper guide

Fix function header

Co-authored-by: Lance Ball <lball@redhat.com>

Fix another function header

Co-authored-by: Lance Ball <lball@redhat.com>

Improve wording

Co-authored-by: Lance Ball <lball@redhat.com>

Fix yet another function header

Co-authored-by: Lance Ball <lball@redhat.com>

Fix broken list

Add the step of installing dependencies

Substitute curl commands with kn func emit commands

Improve kn func emit examples

Several stylistic improvements

Make paragraph more precise

Co-authored-by: jrangelramos <jrangelramos@gmail.com>

Add a comma

Use updated TypeScript code examples

Co-authored-by: Lance Ball <lball@redhat.com>

Improvements to TypeScript code

Improve TypeScript code

Co-authored-by: jrangelramos <jrangelramos@gmail.com>
2021-09-01 16:30:44 +00:00

35 lines
1.3 KiB
Plaintext

[id="serverless-typescript-template_{context}"]
= TypeScript function template structure
When you create a TypeScript function using the `kn` CLI, the project directory looks like a typical TypeScript 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>
├── package.json <2>
├── package-lock.json
├── README.md
├── src
│   └── index.ts <3>
├── test <4>
│   ├── integration.ts
│   └── unit.ts
└── tsconfig.json
----
<1> The `func.yaml` configuration file is used to determine the image name and registry.
<2> 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 TypeScript 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.
<3> Your project must contain an `src/index.js` file which exports a function named `handle`.
<4> Integration and unit test scripts are provided as part of the function template.