Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
ecklf-tmp-runtime-test
Advanced tools
First, you'll need a vercel.json
file in your project:
{
"functions": {
"api/**/*.rs": {
"runtime": "vercel-rust@3.1.2"
}
}
}
A Vercel Function will be created for every file that matches api/**/*.rs
.
api/handler.rs
:
use serde_json::json;
use vercel_runtime::{
lambda_http::{http::StatusCode, Error as LambdaError, Response},
run, IntoResponse, ProxyError, ProxyRequest,
};
#[tokio::main]
async fn main() -> Result<(), LambdaError> {
run(handler).await?;
Ok(())
}
pub async fn handler(_req: ProxyRequest) -> Result<impl IntoResponse, ProxyError> {
let response = Response::builder()
.status(StatusCode::OK)
.header("Content-Type", "application/json")
.body(
json!({
"message": "你好,世界"
})
.to_string(),
)?;
Ok(response)
}
Finally we need a Cargo.toml
file at the root of your repository.
# You can specify a library for shared logic here (optional)
# [lib]
# path = "src-rs/lib.rs"
# Each handler has to be specified as [[bin]]
[[bin]]
name = "handler"
path = "api/handler.rs"
This Builder supports installing dependencies defined in the Cargo.toml
file.
Furthermore, more system dependencies can be installed at build time with the presence of a shell build.sh
file in the same directory as the entrypoint file.
With vercel dev
and vercel-rust
, you can develop your Rust-based lambdas on your own machine.
During local development with vercel dev
, ensure rust
and cargo
are already installed and available in your PATH
, since they will not be installed automatically. The recommended way to install is with rustup.
Since this project contains both Rust and Node.js code, you need to install the relevant dependencies. If you're only working on the JavaScript side, you only need to install those dependencies (and vice-versa).
# install node dependencies
npm install
# install cargo dependencies
cargo fetch
graph TD
A["Lambda Invocation"] --> |"process_request(event: LambdaEvent<VercelEvent>) → ProxyRequest"| B[ProxyRequest]
B --> |"handler_fn(req: ProxyRequest) → Future<Output = Result<impl IntoResponse, ProxyError>>"| C["Runtime calls handler_fn"]
C --> |"Ok(r) => process_response(r)"| D["ProxyResponse"]
C --> |"Err(e) => process_error(e)"| E["ProxyError"]
Upon a request a LambdaEvent
containing a VercelEvent
is mapped to a ProxyRequest
which can be consumed in the handler function. The Result
of the handler function will be mapped into a ProxyResponse
or ProxyError
.
Cargo.toml
is setting up the workspaces for the endpoints.api/**/handler.rs
) export a function with the signature: pub async fn handler(_req: ProxyRequest) -> Result<impl IntoResponse, ProxyError>
. .
├── api
│ ├── endpoint_1
│ │ ├── Cargo.toml
│ │ └── src
│ │ └── main.rs
│ └── endpoint_2
│ ├── Cargo.toml
│ └── src
│ └── main.rs
├── Cargo.lock
└── Cargo.toml
# Show `debug` statements in logs
VERCEL_BUILDER_DEBUG=true
entry
package in the workspace that imports all endpoint handler
fn (proc macro) with runtime initialization and routing logic.[https://github.com/awslabs/aws-lambda-rust-runtime/releases/tag/v0.3.0](Base Lambda Runtime Release Notes)
files: {
"files": {
"api/Cargo.lock": {
"type": "FileFsRef",
"mode": 33188,
"fsPath": "/vercel/path0/api/Cargo.lock"
},
"api/Cargo.toml": {
"type": "FileFsRef",
"mode": 33188,
"fsPath": "/vercel/path0/api/Cargo.toml"
},
"api/user.rs": {
"type": "FileFsRef",
"mode": 33188,
"fsPath": "/vercel/path0/api/user.rs"
},
".vercelignore": {
"type": "FileFsRef",
"mode": 33188,
"fsPath": "/vercel/path0/.vercelignore"
},
"package.json": {
"type": "FileFsRef",
"mode": 33188,
"fsPath": "/vercel/path0/package.json"
},
"pnpm-lock.yaml": {
"type": "FileFsRef",
"mode": 33188,
"fsPath": "/vercel/path0/pnpm-lock.yaml"
},
"vercel.json": {
"type": "FileFsRef",
"mode": 33188,
"fsPath": "/vercel/path0/vercel.json"
}
},
"entrypoint": "api/user.rs",
"workPath": "/vercel/path0",
"repoRootPath": "/vercel/path0",
"config": {
"zeroConfig": true,
"functions": {
"api/**/*.rs": {
"runtime": "ecklf-tmp-runtime-test@1.0.4"
}
},
"projectSettings": {
"createdAt": 1674047862614,
"installCommand": null,
"buildCommand": null,
"devCommand": null,
"outputDirectory": null,
"rootDirectory": null,
"framework": null,
"nodeVersion": "18.x"
},
"framework": null,
"nodeVersion": "18.x"
},
"meta": {
"skipDownload": true,
"cliVersion": "28.12.7"
}
}
FAQs
Rust runtime for Vercel Functions.
The npm package ecklf-tmp-runtime-test receives a total of 18 weekly downloads. As such, ecklf-tmp-runtime-test popularity was classified as not popular.
We found that ecklf-tmp-runtime-test demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.