Skip to content

Commit 79f6f59

Browse files
weltekialexellis
authored andcommitted
Update version of node template
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
1 parent 74f14e4 commit 79f6f59

File tree

7 files changed

+23
-28
lines changed

7 files changed

+23
-28
lines changed

docs/architecture/invocations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ Whenever you run `faas-cli build` or `faas-cli publish` using one of the OpenFaa
2222
Templates tend to abstract away the Dockerfile and entry-point HTTP server from you, so that you can focus on writing a HTTP or function handler, they are still there however and you can look into the "template" folder to find them after running `faas-cli template store pull`
2323

2424
```bash
25-
$ faas-cli template store pull node20
26-
$ ls template/node20
25+
$ faas-cli template store pull node22
26+
$ ls template/node22
2727
Dockerfile function index.js package.json template.yml
2828

29-
$ ls template/node20/
29+
$ ls template/node22/
3030
handler.js package.json
3131
```
3232

docs/cli/build.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ Create a function:
152152

153153
```bash
154154
export OPENFAAS_PREFIX=openfaasltd
155-
faas-cli template store pull node20
156-
faas-cli new --lang node20 withprivatenpm
155+
faas-cli template store pull node22
156+
faas-cli new --lang node22 withprivatenpm
157157
```
158158

159159
You will need to create an authentication token to install private npm modules. These instructions will differ depending on the registry you want to use:
@@ -186,7 +186,7 @@ provider:
186186
gateway: http://127.0.0.1:8080
187187
functions:
188188
withprivatenpm:
189-
lang: node20
189+
lang: node22
190190
handler: ./withprivatenpm
191191
image: openfaasltd/withprivatenpm:latest
192192
build_secrets:
@@ -199,7 +199,7 @@ Run a build with:
199199
faas-cli pro build -f stack.yml
200200
```
201201

202-
You'll also need an updated version of the node template to mount the secret passed in from the OpenFaaS Pro plugin. Update `template/node20/Dockerfile` and replace the second `npm i` command with:
202+
You'll also need an updated version of the node template to mount the secret passed in from the OpenFaaS Pro plugin. Update `template/node22/Dockerfile` and replace the second `npm i` command with:
203203

204204
```Dockerfile
205205
RUN --mount=type=secret,id=npmrc,mode=0666,dst=/home/app/.npmrc npm i

docs/cli/templates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ dockerfile [x] openfaas Classic Dockerfile templ
5656
dotnet8-csharp [x] openfaas C# template using WebApplication
5757
golang-middleware [x] openfaas HTTP middleware interface in Go
5858
java11-vert-x [x] openfaas Java 11 Vert.x template
59-
node20 [x] openfaas HTTP-based Node 18 template
59+
node22 [x] openfaas HTTP-based Node 22 template
6060
php8 [x] openfaas Classic PHP 8 template
6161
python3-http [x] openfaas Python 3 with Flask and HTTP
6262
python3-http-debian [x] openfaas Python 3 with Flask and HTTP based on Debian

docs/languages/custom.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This will include code submitted by a third party. It may or may not be kept up
3030

3131
### Make your own template
3232

33-
The easiest way to write a template for OpenFaaS it to copy an official template, and to modify it. This example creates a template using Bun and Express.js which is based upon the official node20 template.
33+
The easiest way to write a template for OpenFaaS it to copy an official template, and to modify it. This example creates a template using Bun and Express.js which is based upon the official 22 template.
3434

3535
Create a new folder called my-templates, it should have a sub-directory within it called `template`.
3636

@@ -57,12 +57,12 @@ Next, create a Dockerfile which should download and make available the OpenFaaS
5757
5858
There are two watchdogs available, the [Classic Watchdog](https://github.com/openfaas/classic-watchdog), meant for processes which do not have their own HTTP server, the process will be forked for each request, and the [of-watchdog](https://github.com/openfaas/of-watchdog) for when a HTTP server is available. Since Bun used with Express.js provides a HTTP server, we'll be using the of-watchdog.
5959
60-
The following Dockerfile is based upon the node20 template, adapted for Bun.
60+
The following Dockerfile is based upon the node22 template, adapted for Bun.
6161
6262
The `--platform=${TARGETPLATFORM:-linux/amd64}` directive is required for multi-arch support, to make the template work for 64-bit Arm as well as regular *x86_64* machines. Most images that you find on the Docker Hub will already have multi-arch support, and it's strongly recommended to keep it in place.
6363

6464
```Dockerfile
65-
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.11 as watchdog
65+
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.9 as watchdog
6666
FROM --platform=${TARGETPLATFORM:-linux/amd64} oven/bun:alpine as ship
6767
6868
ARG TARGETPLATFORM
@@ -254,12 +254,7 @@ const middleware = async (req, res) => {
254254
});
255255
};
256256
257-
app.post('/*', middleware);
258-
app.get('/*', middleware);
259-
app.patch('/*', middleware);
260-
app.put('/*', middleware);
261-
app.delete('/*', middleware);
262-
app.options('/*', middleware);
257+
app.use(middleware)
263258
264259
const port = process.env.http_port || 3000;
265260

docs/languages/node.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The [Node.js](https://nodejs.org/en) template for OpenFaaS uses [Express.js](htt
44

55
!!! info "Do you need to customise this template?"
66

7-
You can customise the official templates, or provide your own. The code for this templates is available on GitHub: [openfaas/templates](https://github.com/openfaas/templates/tree/master/template/node20).
7+
You can customise the official templates, or provide your own. The code for this templates is available on GitHub: [openfaas/templates](https://github.com/openfaas/templates/tree/master/template/node22).
88

99
The event is used to obtain the original HTTP request, and the context is used to set the HTTP response. The underlying Express.js object is an implementation detail, and so is not available to the function author.
1010

@@ -20,7 +20,7 @@ Create a new function using the template:
2020

2121
```bash
2222
faas-cli template pull
23-
faas-cli new --lang node20 echo
23+
faas-cli new --lang node22 echo
2424
```
2525

2626
You'll find a new folder called `echo` with a `handler.js` and `package.json` file inside.
@@ -68,7 +68,7 @@ Or to combine the `context.status()` method with the `context.succeed()` method
6868
To install packages, `cd` into the function folder and run `npm install --save`:
6969

7070
```bash
71-
faas-cli new --lang node20 http-req
71+
faas-cli new --lang node22 http-req
7272
cd http-req
7373

7474
npm install --save axios
@@ -132,12 +132,12 @@ Then create a new secret in OpenFaaS:
132132
faas-cli secret create node-fn-token --from-file node-fn-token.txt
133133
```
134134

135-
Create a new function using the *node20* template:
135+
Create a new function using the *node22* template:
136136

137137
```bash
138138
export OPENFAAS_PREFIX=ttl.sh/fns
139139

140-
faas-cli new --lang node20 node-fn
140+
faas-cli new --lang node22 node-fn
141141
```
142142

143143
Then edit the `node-fn/handler.js`:
@@ -176,7 +176,7 @@ Edit `node-fn.yml` and add the `secrets` section:
176176
```diff
177177
functions:
178178
node-fn:
179-
lang: node20
179+
lang: node22
180180
handler: ./node-fn
181181
image: ttl.sh/fns/node-fn:latest
182182
+ secrets:
@@ -210,7 +210,7 @@ When you test the function with `faas-cli up`, make sure you use the function's
210210

211211
Unit tests provide a quick and efficient way to exercise your code on your local computer, without needing to run `faas-cli build` or to deploy the function to a remote cluster.
212212

213-
With the node20 template, any unit tests that you provide will be run automatically upon each invocation of `faas-cli build`.
213+
With the node22 template, any unit tests that you provide will be run automatically upon each invocation of `faas-cli build`.
214214

215215

216216
By default, an empty test step is written to package.json inside your function's handler folder, you can override this with your own command or test runner.
@@ -305,7 +305,7 @@ The OpenTelemetry agent can be configured using environment variables on the fun
305305
```diff
306306
functions:
307307
echo:
308-
lang: node20
308+
lang: node22
309309
handler: ./node
310310
image: echo:latest
311311
+ environment:

docs/openfaas-pro/builder.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ mkdir -p /tmp/functions
119119
cd /tmp/functions
120120

121121
# Create a new function
122-
faas-cli new --lang node20 hello-world
122+
faas-cli new --lang node22 hello-world
123123

124124
# The shrinkwrap command performs the templating
125125
# stage, then stops before running "docker build"
@@ -278,7 +278,7 @@ You may need to enable build arguments for the Dockerfile, these can be passed t
278278
{
279279
"image": "ttl.sh/alexellis/test-image:0.1.0",
280280
"buildArgs": {
281-
"BASE_IMAGE": "gcr.io/quiet-mechanic-140114/openfaas-base/node20"
281+
"BASE_IMAGE": "gcr.io/quiet-mechanic-140114/openfaas-base/node22"
282282
}
283283
}
284284
```

docs/openfaas-pro/kafka-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Most templates make these variables available through their request or context o
7777

7878
* [golang-middleware](/languages/go/)
7979
* [python3-http](/languages/python/)
80-
* [node20](/languages/node/)
80+
* [node22](/languages/node/)
8181

8282
For detailed examples with Node.js, see: [Serverless For Everyone Else](http://store.openfaas.com/l/serverless-for-everyone-else)
8383

0 commit comments

Comments
 (0)