{"id":27957798,"url":"https://github.com/tencentcloudbase/func-v2-template","last_synced_at":"2025-05-07T18:14:43.696Z","repository":{"id":271807518,"uuid":"909897548","full_name":"TencentCloudBase/func-v2-template","owner":"TencentCloudBase","description":"云开发-函数型云托管示例代码","archived":false,"fork":false,"pushed_at":"2025-05-06T04:13:36.000Z","size":112,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-07T18:14:38.301Z","etag":null,"topics":["cloudfunctions","cloudrunfunctions"],"latest_commit_sha":null,"homepage":"https://docs.cloudbase.net/cbrf/intro","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TencentCloudBase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-30T02:23:41.000Z","updated_at":"2025-05-06T04:13:38.000Z","dependencies_parsed_at":"2025-01-10T02:29:36.185Z","dependency_job_id":"7741ac89-73dd-4159-9365-bc919fe462a5","html_url":"https://github.com/TencentCloudBase/func-v2-template","commit_stats":null,"previous_names":["tencentcloudbase/func-v2-template"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TencentCloudBase%2Ffunc-v2-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TencentCloudBase%2Ffunc-v2-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TencentCloudBase%2Ffunc-v2-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TencentCloudBase%2Ffunc-v2-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TencentCloudBase","download_url":"https://codeload.github.com/TencentCloudBase/func-v2-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931541,"owners_count":21827112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudfunctions","cloudrunfunctions"],"created_at":"2025-05-07T18:14:42.928Z","updated_at":"2025-05-07T18:14:43.688Z","avatar_url":"https://github.com/TencentCloudBase.png","language":"JavaScript","readme":"# 函数型云托管示例代码\n\n该示例代码演示如何通过 `TypeScript` 编写 `函数型云托管示例代码` 项目代码。包括项目结构示例，以及调试。\n\n\u003e 注意：该示例项目主要展示一个完整的云函数，即，整个项目从根目录开始即为一个云函数。\n\u003e 实际项目中会包括多个云函数，以及项目中其他部分的项目代码，例如项目前端代码。\n\u003e 所以，在一个实际的项目中，该函数代码通常对应 `项目根路径/cloudrunfunctions/func-v2-template` 目录。\n\n更完整的示例项目代码可参考：[TypeScript 示例代码](https://github.com/TencentCloudBase/cloudbase-examples/tree/master/cloudrunfunctions/ts-multiple-functions)\n\n## 如何运行代码？\n\n`Git Clone` 代码到本地后，可通过 `pnpm install` 安装依赖\n\n通过如下命令允许云函数\n\n```sh\nnpx tcb-ff\n```\n\n然后通过浏览器访问 `http://localhost:3000/` 即可查看示例代码运行结果。\n\n## 如何调试代码？\n\n示例代码中已经包含了 `VSCode` 的调试配置，可在 `Run And Debug` 界面选择 `launch-tcb-ff-local` 即可允许云函数并进行断点调试。\n\n如何调试代码可参考：\u003chttps://docs.cloudbase.net/cbrf/how-to-debug-functions-code#%E8%B0%83%E8%AF%95-javascript-%E4%BB%A3%E7%A0%81\u003e\n\n## 文件说明\n\n* `cloudbase-functions.json` 多函数配置文件，描述了函数的名称、入口文件、访问路径等信息\n* `src/common` 公共模块，名称是任意的\n* `src/echo` 回显函数示例\n* `src/sse` 实现 `SSE` 的函数示例\n* `src/sse-openai` 实现 `sse+openai` 的函数示例\n* `src/ws` 实现 `WebSocket` 的函数示例\n* `package.json` node.js 项目依赖管理描述文件\n\n\u003e 注意：因为整个项目为一个函数，项目的依赖需要安装到项目根路径下，即安装到 `项目根路径/package.json` 里面，不要安装到 `src` 里面的子函数里面。\n\nQ：为什么 `src/ws` 等函数目录中存在 `package.json` 文件？\n\n主要因为需要 [`type=module|commonjs`](https://nodejs.org/api/packages.html#type) 字段以支持加载不同类型的 `node.js` 模块。\n\n## 如何部署？\n\n可在云开发平台创建云函数2.0服务后上传本示例代码包进行部署。\n\n注意：如果通过 `Github Download zip` 方式下载的代码包，因多一层目录，需要解压后重新将文件压缩到根路径后再上传，或者上传解压后的目录。\n\n压缩命令示例：\n\n```sh\nzip -x '/*.git/*' -x '.gitignore' -x '.DS_Store' -x 'node_modules/*' -r code.zip .\n```\n\n## 相关链接\n\n* [腾讯云云开发-云函数2.0](https://docs.cloudbase.net/cbrf/intro)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencentcloudbase%2Ffunc-v2-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftencentcloudbase%2Ffunc-v2-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencentcloudbase%2Ffunc-v2-template/lists"}