
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
fc-toolkit
Advanced tools
主要功能:
npm install fc-toolkit
在函数代码目录 ~/.fc-config.json 里写入自己的 fc 配置,格式如下:
{
"fc": {
"accountId": "<account id>",
"accessKeyID": "<access key id>",
"accessKeySecret": "<access key secret>",
"region": "cn-shanghai",
"timeout": 50000
},
"EnvironmentVariables": {
"OSS_ID": "<Your accessKeyId>",
"OSS_SECRET": "<Your accessKeySecret>",
"OSS_BUCKET": "<Your bucket name>",
"OSS_ENDPOINT": "<oss endpoint>",
},
"oss": {
"endpoint": "<oss endpoint>",
"accessKeyId": "<Your accessKeyId>",
"accessKeySecret": "<Your accessKeySecret>",
"bucket": "<Your bucket name>"
},
"aws": {
"accessKeyId": "< your access key ID>",
"secretAccessKey": "<your secret access key>",
"bucket": "<your bucket>",
"region": "<cn-north-1>",
"endpoint": "<your endpoint>",
"s3ForcePathStyle": true
},
"serviceName": "yourFcServiceName",
"handler": "index.handler",
"memorySize": 1024,
"runtime": "nodejs10",
"timeout": 300,
"name": "yourFcFunctionNamePrefix",
"version": "1.0.0,1.0.1",
"intall": "yarn install --production",
"zip": "zip -qr ${filepath} ./ -x *.git*",
}
上传命令:npx fc-publish
Notes:
handler
,memorySize
,runtime
,timeout
为可选项;install
, zip
为可选项, 可以自定义install和zip命令, 如使用yarn install, zip时忽略特定目录-internal
,在函数计算执行时-internal
会自动带上;// using oss
const invoke = require('fc-toolkit').initInvoker({
oss: {
endpoint: "<oss endpoint>",
accessKeyId: "<Your accessKeyId>",
accessKeySecret: "<Your accessKeySecret>",
bucket: "<Your bucket name>"
},
fc: {
accountId: "<account id>",
accessKeyID: "<access key id>",
accessKeySecret: "<access key secret>",
region: "cn-shanghai",
timeout: 50000
},
})
// or using minio
const invoke = require('fc-toolkit').initInvoker({
aws: {
"accessKeyId": "< your access key ID>",
"secretAccessKey": "<your secret access key>",
"bucket": "<your bucket>",
"region": "<cn-north-1>",
"endpoint": "<your endpoint>",
"s3ForcePathStyle": true
},
fc: {
accountId: "<account id>",
accessKeyID: "<access key id>",
accessKeySecret: "<access key secret>",
region: "cn-shanghai",
timeout: 50000
}
})
// 由于经 OSS 中转会丢失格式,body 需要为字符串格式
const result = await invoke(serviceName, functionName, body)
如果发送的大小或者函数计算返回的结果超过了函数计算的大小限制,会自动使用 OSS 转发和收取;
// 函数计算里执行的代码
const { receive, reply } = require('fc-toolkit').initReveiver(
false, // if disable oss, defaults to false
'aws' // set 'aws' when using minio, defaults to 'oss'
ossThreshold: number // ossThreshold. 当响应超过此大小时, 使用oss. 默认2000000
)
async function handler (event, context, callback) {
try {
// `receive` 在从 OSS 收到 payload 后会自动将其删除
const body = await receive(event)
// handle the body here..
const returnValue = await doSomethingYouNeed(body)
await reply(callback)(returnValue)
} catch (e) {
callback(e)
}
}
或者也可以使用 receiveManually
来获取包含 header 在内的更多响应内容,以及手动控制 OSS 临时对象的清理:
const { receiveManually, reply } = require('fc-toolkit').initReveiver(
false,
'aws'
)
async function handler (event, context, callback) {
try {
const resp = await receiveManually(event)
const returnValue = await doSomethingYouNeed(resp.body)
await reply(callback)(returnValue)
// 手动调用清理回调
await resp.cleanup()
} catch (e) {
callback(e)
}
}
// using oss
const invoke = require('fc-toolkit').bufferSupport.initInvoker({
oss: {
...
},
fc: {
...
},
ossThreshold: number; // 当请求body大于ossThreshold时使用oss
})
const result: string | Buffer = await invoke(serviceName, functionName, body)
MIT
FAQs
fc-toolkit
The npm package fc-toolkit receives a total of 6 weekly downloads. As such, fc-toolkit popularity was classified as not popular.
We found that fc-toolkit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.