+
+
1
+
介绍
+
这是一个 Nest
应用示例,可以通过 Serverless Devs
工具将项目一键部署到云开发环境
+
+
+
+
3
+
快速部署一个 Nest 应用
+
+
+
步骤一. 准备工作
+
具体步骤请参照 Serverless Cli 安装
+
步骤二. 初始化应用示例
+
s init start-nest
+
步骤三. 一键部署
+
进入到项目目录,在命令行执行
+
s deploy
+
帮助文档
+
+
+
+
+
4
+
Github
+
您对此应用有任何问题或者建议,欢迎给我们 提issue
+
+
+
+
+`;
+ }
+}
diff --git a/web-framework/nodejs/custom-runtime/nest/src/code/src/main.ts b/web-framework/nodejs/custom-runtime/nest/src/code/src/main.ts
new file mode 100644
index 000000000..13cad38cf
--- /dev/null
+++ b/web-framework/nodejs/custom-runtime/nest/src/code/src/main.ts
@@ -0,0 +1,8 @@
+import { NestFactory } from '@nestjs/core';
+import { AppModule } from './app.module';
+
+async function bootstrap() {
+ const app = await NestFactory.create(AppModule);
+ await app.listen(3000);
+}
+bootstrap();
diff --git a/web-framework/nodejs/custom-runtime/nest/src/code/test/app.e2e-spec.ts b/web-framework/nodejs/custom-runtime/nest/src/code/test/app.e2e-spec.ts
new file mode 100644
index 000000000..50cda6233
--- /dev/null
+++ b/web-framework/nodejs/custom-runtime/nest/src/code/test/app.e2e-spec.ts
@@ -0,0 +1,24 @@
+import { Test, TestingModule } from '@nestjs/testing';
+import { INestApplication } from '@nestjs/common';
+import * as request from 'supertest';
+import { AppModule } from './../src/app.module';
+
+describe('AppController (e2e)', () => {
+ let app: INestApplication;
+
+ beforeEach(async () => {
+ const moduleFixture: TestingModule = await Test.createTestingModule({
+ imports: [AppModule],
+ }).compile();
+
+ app = moduleFixture.createNestApplication();
+ await app.init();
+ });
+
+ it('/ (GET)', () => {
+ return request(app.getHttpServer())
+ .get('/')
+ .expect(200)
+ .expect('Hello World!');
+ });
+});
diff --git a/web-framework/nodejs/custom-runtime/nest/src/code/test/jest-e2e.json b/web-framework/nodejs/custom-runtime/nest/src/code/test/jest-e2e.json
new file mode 100644
index 000000000..e9d912f3e
--- /dev/null
+++ b/web-framework/nodejs/custom-runtime/nest/src/code/test/jest-e2e.json
@@ -0,0 +1,9 @@
+{
+ "moduleFileExtensions": ["js", "json", "ts"],
+ "rootDir": ".",
+ "testEnvironment": "node",
+ "testRegex": ".e2e-spec.ts$",
+ "transform": {
+ "^.+\\.(t|j)s$": "ts-jest"
+ }
+}
diff --git a/web-framework/nodejs/custom-runtime/nest/src/code/tsconfig.build.json b/web-framework/nodejs/custom-runtime/nest/src/code/tsconfig.build.json
new file mode 100644
index 000000000..64f86c6bd
--- /dev/null
+++ b/web-framework/nodejs/custom-runtime/nest/src/code/tsconfig.build.json
@@ -0,0 +1,4 @@
+{
+ "extends": "./tsconfig.json",
+ "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
+}
diff --git a/web-framework/nodejs/custom-runtime/nest/src/code/tsconfig.json b/web-framework/nodejs/custom-runtime/nest/src/code/tsconfig.json
new file mode 100644
index 000000000..adb614cab
--- /dev/null
+++ b/web-framework/nodejs/custom-runtime/nest/src/code/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "declaration": true,
+ "removeComments": true,
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "allowSyntheticDefaultImports": true,
+ "target": "es2017",
+ "sourceMap": true,
+ "outDir": "./dist",
+ "baseUrl": "./",
+ "incremental": true,
+ "skipLibCheck": true,
+ "strictNullChecks": false,
+ "noImplicitAny": false,
+ "strictBindCallApply": false,
+ "forceConsistentCasingInFileNames": false,
+ "noFallthroughCasesInSwitch": false
+ }
+}
diff --git a/web-framework/nodejs/custom-runtime/nest/src/readme.md b/web-framework/nodejs/custom-runtime/nest/src/readme.md
new file mode 100644
index 000000000..5a9e68bd2
--- /dev/null
+++ b/web-framework/nodejs/custom-runtime/nest/src/readme.md
@@ -0,0 +1,82 @@
+# nest-app 帮助文档
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Nest (NestJS) 是一个用于构建高效、可扩展的 Node.js 服务器端应用程序的开发框架。
+
+
+
+
+
+## 前期准备
+使用该项目,推荐您拥有以下的产品权限 / 策略:
+
+| 服务/业务 | 函数计算 |
+| --- | --- |
+| 权限/策略 | AliyunFCFullAccess |
+
+
+
+
+
+# 代码 & 预览
+
+- [ :smiley_cat: 源代码](https://github.com/devsapp/start-web-framework/blob/master/web-framework/nodejs/nodejs-runtime/nest)
+
+
+
+
+
+## 部署 & 体验
+
+
+
+- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=nest-app) ,
+[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=nest-app) 该应用。
+
+
+
+- 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署:
+ - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://www.serverless-devs.com/fc/config) ;
+ - 初始化项目:`s init nest-app -d nest-app`
+ - 进入项目,并进行项目部署:`cd nest-app && s deploy -y`
+
+
+
+
+
+# 应用详情
+
+
+本应用仅作为学习和参考使用,您可以基于本项目进行二次开发和完善,实现自己的业务逻辑
+
+
+
+
+
+
+## 开发者社区
+
+您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:
+
+
+
+| | | |
+|--- | --- | --- |
+|
微信公众号:`serverless` | 微信小助手:`xiaojiangwh` | 钉钉交流群:`33947367` |
+
+
+
+
\ No newline at end of file
diff --git a/web-framework/nodejs/custom-runtime/nest/src/s.yaml b/web-framework/nodejs/custom-runtime/nest/src/s.yaml
new file mode 100644
index 000000000..9aae36e4f
--- /dev/null
+++ b/web-framework/nodejs/custom-runtime/nest/src/s.yaml
@@ -0,0 +1,85 @@
+# ------------------------------------
+# If you need English case, you can refer to [s_en.yaml] file
+# ------------------------------------
+# 欢迎您使用阿里云函数计算 FC 组件进行项目开发
+# 组件仓库地址:https://github.com/devsapp/fc
+# 组件帮助文档:https://www.serverless-devs.com/fc/readme
+# Yaml参考文档:https://www.serverless-devs.com/fc/yaml/readme
+# 关于:
+# - Serverless Devs和FC组件的关系、如何声明/部署多个函数、超过50M的代码包如何部署
+# - 关于.fcignore使用方法、工具中.s目录是做什么、函数进行build操作之后如何处理build的产物
+# 等问题,可以参考文档:https://www.serverless-devs.com/fc/tips
+# 关于如何做CICD等问题,可以参考:https://www.serverless-devs.com/serverless-devs/cicd
+# 关于如何进行环境划分等问题,可以参考:https://www.serverless-devs.com/serverless-devs/extend
+# 更多函数计算案例,可参考:https://github.com/devsapp/awesome/
+# 有问题快来钉钉群问一下吧:33947367
+# ------------------------------------
+edition: 1.0.0
+name: web-framework-app
+# access 是当前应用所需要的密钥信息配置:
+# 密钥配置可以参考:https://www.serverless-devs.com/serverless-devs/command/config
+# 密钥使用顺序可以参考:https://www.serverless-devs.com/serverless-devs/tool#密钥使用顺序与规范
+access: "{{ access }}"
+
+vars: # 全局变量
+ region: "{{ region }}"
+ service:
+ name: "{{ serviceName }}"
+ description: 'Serverless Devs Web Framework Service'
+
+services:
+ framework: # 业务名称/模块名称
+ # 如果只想针对 framework 下面的业务进行相关操作,可以在命令行中加上 framework,例如:
+ # 只对framework进行构建:s framework build
+ # 如果不带有 framework ,而是直接执行 s build,工具则会对当前Yaml下,所有和 framework 平级的业务模块(如有其他平级的模块,例如下面注释的next-function),按照一定顺序进行 build 操作
+ component: fc # 组件名称,Serverless Devs 工具本身类似于一种游戏机,不具备具体的业务能力,组件类似于游戏卡,用户通过向游戏机中插入不同的游戏卡实现不同的功能,即通过使用不同的组件实现不同的具体业务能力
+ actions: # 自定义执行逻辑,关于actions 的使用,可以参考:https://www.serverless-devs.com/serverless-devs/yaml#行为描述
+ pre-deploy: # 在deploy之前运行
+ - run: npm install --production # 要执行的系统命令,类似于一种钩子的形式
+ path: ./code # 执行系统命令/钩子的路径
+ - run: npm run build
+ path: ./code
+ # - component: fc build --use-docker # 要运行的组件,格式为【component: 组件名 命令 参数】(可以通过s cli registry search --type Component 获取组件列表)
+# - plugin: myplugin # 与运行的插件 (可以通过s cli registry search --type Plugin 获取组件列表)
+# args: # 插件的参数信息
+# testKey: testValue
+# post-deploy: # 在deploy之后运行
+# - component: fc versions publish # 要运行的命令行
+ props: # 组件的属性值
+ region: ${vars.region} # 关于变量的使用方法,可以参考:https://www.serverless-devs.com/serverless-devs/yaml#变量赋值
+ service: ${vars.service}
+ function:
+ name: "{{ functionName }}"
+ description: 'Serverless Devs Web Framework Function'
+ codeUri: ./code
+ runtime: custom
+ memorySize: 512
+ timeout: 6
+ caPort: 3000
+ triggers:
+ - name: http-trigger
+ type: http
+ config:
+ authType: anonymous
+ methods:
+ - GET
+ - POST
+ customDomains:
+ - domainName: auto
+ protocol: HTTP
+ routeConfigs:
+ - path: /*
+# next-function: # 第二个函数的案例,仅供参考
+# # 如果在当前项目下执行 s deploy,会同时部署模块:
+# # helloworld:服务hello-world-service,函数cpp-event-function
+# # next-function:服务hello-world-service,函数next-function-example
+# # 如果想单独部署当前服务与函数,可以执行 s + 模块名/业务名 + deploy,例如:s next-function deploy
+# # 如果想单独部署当前函数,可以执行 s + 模块名/业务名 + deploy function,例如:s next-function deploy function
+# # 更多命令可参考:https://www.serverless-devs.com/fc/readme#文档相关
+# component: fc
+# props:
+# region: ${vars.region}
+# service: ${vars.service} # 应用整体的服务配置
+# function: # 定义一个新的函数
+# name: next-function-example
+# description: 'hello world by serverless devs'
\ No newline at end of file
diff --git a/web-framework/nodejs/custom-runtime/nest/src/s_en.yaml b/web-framework/nodejs/custom-runtime/nest/src/s_en.yaml
new file mode 100644
index 000000000..fa3bf7f18
--- /dev/null
+++ b/web-framework/nodejs/custom-runtime/nest/src/s_en.yaml
@@ -0,0 +1,87 @@
+# ------------------------------------
+# If you want to use this file directly, please add [-t/--template] parameter, for example [s deploy -t s_en.yaml]
+# ------------------------------------
+# Welcome to use Alibaba Cloud Function Compute FC components for project development
+# Component warehouse address: https://github.com/devsapp/fc
+# Component help documentation: https://www.serverless-devs.com/fc/readme
+# Yaml reference documentation: https://www.serverless-devs.com/fc/yaml/readme
+# About:
+# - The relationship between Serverless Devs and FC components, how to declare/deploy multiple functions, how to deploy code packages over 50M
+# - About the usage of .fcignore, what the .s directory in the tool does, and how to process the build product after the function performs the build operation
+# and other issues, you can refer to the documentation: https://www.serverless-devs.com/fc/tips
+# For questions about how to do CICD, please refer to: https://www.serverless-devs.com/serverless-devs/cicd
+# For issues such as how to divide the environment, please refer to: https://www.serverless-devs.com/serverless-devs/extend
+# For more function calculation cases, please refer to: https://github.com/devsapp/awesome/blob/main/README_en.md
+# If you have any questions, please come to the DingTalk group and ask: 33947367
+# ------------------------------------
+edition: 1.0.0
+name: web-framework-app
+# access is the key information configuration required by the current application:
+# Key configuration can refer to: https://www.serverless-devs.com/serverless-devs/command/config
+# For the order of key usage, please refer to: https://www.serverless-devs.com/serverless-devs/tool#Key usage order and specification
+# access: default
+
+vars: # global variables
+ region: cn-hangzhou
+ service:
+ name: hello-world-service
+ description: 'Serverless Devs Web Framework Service'
+
+services:
+ framework: # business name/module name
+ # If you only want to perform related operations on the business below framework, you can add framework to the command line, for example:
+ # Build only framework: s framework build
+ # If s build is directly executed without framework, the tool will perform the same operation on all business modules at the same level as framework under the current Yaml (if there are other level modules, such as the next-function commented below), according to certain Sequential build operations
+ component: fc # The name of the component. The Serverless Devs tool itself is similar to a game console and does not have specific business capabilities. The component is similar to a game card. Users can achieve different functions by inserting different game cards into the game console, that is, by using Different components implement different specific business capabilities
+ actions: # Customize execution logic. For the use of actions, please refer to: https://www.serverless-devs.com/serverless-devs/yaml#Behavior description
+ pre-deploy: # run before deploy
+ - run: npm install --production
+ path: ./code
+ - run: npm run build
+ path: ./code
+# - component: fc build --use-docker # The component to run, the format is [component: component name command parameter] (you can get the component list through s cli registry search --type Component)
+# - run: docker build xxx # System command to execute, similar to a hook
+# path: ./src # The path to execute system commands/hooks
+# - plugin: myplugin # and running plugins (you can get a list of components via s cli registry search --type Plugin)
+# args: # parameter information of the plugin
+# testKey: testValue
+# post-deploy: # run after deploy
+# - component: fc versions publish # command line to run
+ props:
+ region: ${vars.region} # For the usage of variables, please refer to: https://www.serverless-devs.com/serverless-devs/yaml#Variable assignment
+ service: ${vars.service}
+ function:
+ name: nest
+ description: 'Serverless Devs Web Framework Function'
+ codeUri: ./code
+ runtime: custom
+ memorySize: 512
+ timeout: 6
+ caPort: 3000
+ triggers:
+ - name: http-trigger
+ type: http
+ config:
+ authType: anonymous
+ methods:
+ - GET
+ - POST
+ customDomains:
+ - domainName: auto
+ protocol: HTTP
+ routeConfigs:
+ - path: /*
+# next-function: # The case of the second function, just for reference
+# # If you execute s deploy under the current project, the modules will be deployed at the same time:
+# # helloworld: service hello-world-service, function cpp-event-function
+# # next-function: service hello-world-service, function next-function-example
+# # If you want to deploy the current service and function separately, you can execute s + module name/business name + deploy, for example: s next-function deploy
+# # If you want to deploy the current function separately, you can execute s + module name/business name + deploy function, for example: s next-function deploy function
+# # For more commands, please refer to: https://www.serverless-devs.com/fc/readme#Document related
+# component: fc
+# props:
+# region: ${vars.region}
+# service: ${vars.service} # The overall service configuration of the application
+# function: # define a new function
+# name: next-function-example
+# description: 'hello world by serverless devs'
\ No newline at end of file
diff --git a/web-framework/nodejs/custom-runtime/nest/version.md b/web-framework/nodejs/custom-runtime/nest/version.md
new file mode 100644
index 000000000..b51e0aaac
--- /dev/null
+++ b/web-framework/nodejs/custom-runtime/nest/version.md
@@ -0,0 +1 @@
+- 新版本支持
\ No newline at end of file