Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for serverless v4 and typescript #1806

Merged
merged 15 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/coverage
/src/lambda/handler-runner/in-process-runner/aws-lambda-ric/UserFunction.js
/coverage
3 changes: 2 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ on:
env:
FORCE_COLOR: 1
PRINT_OFFLINE_OUTPUT: 1
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}

jobs:
build:
name: "[${{ matrix.os }}] node.js v${{ matrix.node-version }}"
runs-on: ${{ matrix.os }}

timeout-minutes: 40
strategy:
fail-fast: false
matrix:
Expand Down
15,733 changes: 5,632 additions & 10,101 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
"luxon": "^3.4.4",
"node-schedule": "^2.1.1",
"p-memoize": "^7.1.1",
"tree-kill": "^1.2.2",
"tsx": "^4.16.2",
"velocityjs": "^2.0.6",
"ws": "^8.18.0"
},
Expand All @@ -113,9 +115,9 @@
"mocha": "^10.6.0",
"nyc": "^17.0.0",
"prettier": "^3.3.2",
"serverless": "^3.39.0"
"serverless": "^4.1.18"
},
"peerDependencies": {
"serverless": "^3.2.0"
"serverless": "^4.0.0"
}
}
1 change: 1 addition & 0 deletions src/config/supportedRuntimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const supportedPython = new Set([
"python3.9",
"python3.10",
"python3.11",
"python3.12",
])

// RUBY
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable max-classes-per-file */
/**
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* This code was copied from:
* https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/blob/main/src/Errors.js
*
* Defines custom error types throwable by the runtime.
*/

"use strict"

const errorClasses = [
class ImportModuleError extends Error {},
class HandlerNotFound extends Error {},
class MalformedHandlerName extends Error {},
class UserCodeSyntaxError extends Error {},
class MalformedStreamingHandler extends Error {},
class InvalidStreamingOperation extends Error {},
class UnhandledPromiseRejection extends Error {
constructor(reason, promise) {
super(reason)
this.reason = reason
this.promise = promise
}
},
]

errorClasses.forEach((e) => {
module.exports[e.name] = e
e.prototype.name = `Runtime.${e.name}`
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-param-reassign */
/**
* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* This code was copied from:
* https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/blob/main/src/HttpResponseStream.js
*
* HttpResponseStream is NOT used by the runtime.
* It is only exposed in the `awslambda` variable for customers to use.
*/

"use strict"

const METADATA_PRELUDE_CONTENT_TYPE =
"application/vnd.awslambda.http-integration-response"
const DELIMITER_LEN = 8

// Implements the application/vnd.awslambda.http-integration-response content type.
class HttpResponseStream {
static from(underlyingStream, prelude) {
underlyingStream.setContentType(METADATA_PRELUDE_CONTENT_TYPE)

// JSON.stringify is required. NULL byte is not allowed in metadataPrelude.
const metadataPrelude = JSON.stringify(prelude)

underlyingStream._onBeforeFirstWrite = (write) => {
write(metadataPrelude)

// Write 8 null bytes after the JSON prelude.
write(new Uint8Array(DELIMITER_LEN))
}

return underlyingStream
}
}

module.exports.HttpResponseStream = HttpResponseStream
Loading
Loading