Skip to content

Commit

Permalink
feat: add support for nodejs22.x runtime to v13 (#1838)
Browse files Browse the repository at this point in the history
* feat: add support for nodejs22.x runtime

* fix: fix tests
  • Loading branch information
bchew authored Dec 5, 2024
1 parent 63f4199 commit 3f2056a
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/config/supportedRuntimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const supportedRuntimesArchitecture = {
"nodejs16.x": [ARM64, X86_64],
"nodejs18.x": [ARM64, X86_64],
"nodejs20.x": [ARM64, X86_64],
"nodejs22.x": [ARM64, X86_64],
"python3.7": [X86_64],
"python3.8": [ARM64, X86_64],
"python3.9": [ARM64, X86_64],
Expand Down Expand Up @@ -46,6 +47,7 @@ export const supportedNodejs = new Set([
"nodejs16.x",
"nodejs18.x",
"nodejs20.x",
"nodejs22.x",
])

// PROVIDED
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import assert from "node:assert"
import { env } from "node:process"
import { join } from "desm"
import { setup, teardown } from "../../../../_testHelpers/index.js"
import { BASE_URL } from "../../../../config.js"

describe("Node.js 22.x with Docker tests", function desc() {
beforeEach(() =>
setup({
servicePath: join(import.meta.url),
}),
)

afterEach(() => teardown())
;[
{
description: "should work with nodejs22.x in docker container",
expected: {
message: "Hello Node.js 22.x!",
},
path: "/dev/hello",
},
].forEach(({ description, expected, path }) => {
it(description, async function it() {
// "Could not find 'Docker', skipping tests."
if (!env.DOCKER_DETECTED) {
this.skip()
}

const url = new URL(path, BASE_URL)
const response = await fetch(url)
const json = await response.json()

assert.equal(json.message, expected.message)
})
})
})
16 changes: 16 additions & 0 deletions tests/integration/docker/nodejs/nodejs22.x/handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use strict"

// eslint-disable-next-line unicorn/prefer-node-protocol
const { versions } = require("process")

const { stringify } = JSON

module.exports.hello = async () => {
return {
body: stringify({
message: "Hello Node.js 22.x!",
version: versions.node,
}),
statusCode: 200,
}
}
30 changes: 30 additions & 0 deletions tests/integration/docker/nodejs/nodejs22.x/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
service: docker-nodejs22-x-test

configValidationMode: warn
deprecationNotificationMode: error

plugins:
- ../../../../../src/index.js

provider:
architecture: x86_64
deploymentMethod: direct
memorySize: 1024
name: aws
region: us-east-1
runtime: nodejs22.x
stage: dev
versionFunctions: false

custom:
serverless-offline:
noTimeout: true
useDocker: true

functions:
hello:
events:
- http:
method: get
path: hello
handler: handler.hello

0 comments on commit 3f2056a

Please sign in to comment.