Skip to content

Commit 0ec5e77

Browse files
author
heimanba
committed
init project
0 parents  commit 0ec5e77

File tree

13 files changed

+534
-0
lines changed

13 files changed

+534
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: publish package to serverless-hub
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: '3.x'
16+
- uses: actions/setup-node@v1
17+
with:
18+
node-version: 12
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install setuptools wheel twine
23+
pip install requests
24+
- name: Publish package
25+
env:
26+
publish_token: ${{ secrets.alibaba_registry_publish_token }}
27+
run: |
28+
ls
29+
python publish.py

keep-warm-fc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.s

keep-warm-fc/hook/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
async function preInit(inputObj) {
2+
console.log(`
3+
Serverless Devs Application Case
4+
5+
Cloud services required:
6+
- FC : https://fc.console.aliyun.com/
7+
8+
Tips:
9+
- FC Component: https://www.serverless-devs.com/fc/readme`)
10+
11+
try {
12+
var process = require('child_process')
13+
const version = (await process.execSync('s -v')).toString()
14+
const versionNumber = version.match(/s: 2\.0\.(.*?),/)[1]
15+
if (Number(versionNumber) < 103) {
16+
console.log('\x1B[31m%s\x1B[0m', ' * The application requires that the version of Serverless Devs is at least 2.0.103')
17+
console.log('\x1B[31m%s\x1B[0m', ' * Plaese upgraded through [npm install -g @serverless-devs/s]\n\n')
18+
}
19+
} catch (e) {
20+
console.log(e)
21+
console.log(` - Serverless Devs Version >= v2.0.103
22+
`)
23+
}
24+
}
25+
26+
async function postInit(inputObj) {
27+
console.log(`
28+
* Before using, please check whether the actions command in Yaml file is available
29+
* Carefully reading the notes in s.yaml is helpful for the use of the tool
30+
* If need help in the use process, please apply to join the Dingtalk Group: 33947367
31+
`)
32+
}
33+
34+
module.exports = {
35+
postInit,
36+
preInit
37+
}

keep-warm-fc/publish.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Type: Application
2+
Name: start-keep-warm-fc
3+
Version: 0.0.1
4+
Provider:
5+
- 阿里云
6+
Description: 快速部署一个 keep-warm-fc 插件
7+
HomePage: https://github.com/devsapp/start-plugin
8+
Tags:
9+
- 函数计算
10+
- 你好世界
11+
- 新手入门
12+
Category: 新手入门
13+
Service:
14+
函数计算:
15+
Authorities:
16+
- AliyunFCFullAccess
17+
Runtime: Node.js14
18+
Parameters:
19+
type: object
20+
additionalProperties: false # 不允许增加其他属性
21+
required: # 必填项
22+
- region
23+
- serviceName
24+
- functionName
25+
properties:
26+
region:
27+
title: 地域
28+
type: string
29+
default: cn-hangzhou
30+
description: 创建应用所在的地区
31+
enum:
32+
- cn-beijing
33+
- cn-hangzhou
34+
- cn-shanghai
35+
- cn-qingdao
36+
- cn-zhangjiakou
37+
- cn-huhehaote
38+
- cn-shenzhen
39+
- cn-chengdu
40+
- cn-hongkong
41+
- ap-southeast-1
42+
- ap-southeast-2
43+
- ap-southeast-3
44+
- ap-southeast-5
45+
- ap-northeast-1
46+
- eu-central-1
47+
- eu-west-1
48+
- us-west-1
49+
- us-east-1
50+
- ap-south-1
51+
serviceName:
52+
title: 服务名
53+
type: string
54+
default: hello-world-service
55+
description: 服务名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间
56+
functionName:
57+
title: 函数名
58+
type: string
59+
default: start-keep-warm-fc
60+
description: 函数名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-64 之间

keep-warm-fc/readme.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# keep-warm-fc 插件案例
2+
3+
<toc>
4+
5+
<p align="center"><b> 中文 | <a href="./readme_en.md"> English </a> </b></p>
6+
7+
- [快速开始](#快速开始)
8+
- [通过应用中心部署](#通过应用中心部署)
9+
- [通过命令行工具部署](#通过命令行工具部署)
10+
- [应用详情](#应用详情)
11+
- [关于我们](#关于我们)
12+
13+
</toc>
14+
15+
# 快速开始
16+
17+
- [:octocat: 源代码](https://github.com/devsapp/start-plugin/tree/master/http-function/fc-http-node.js14/src)
18+
19+
## 通过应用中心部署
20+
21+
<appcenter>
22+
23+
您可以在阿里云 [:earth_asia: Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-keep-warm-fc) ,快速体验该应用:
24+
25+
[![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=start-keep-warm-fc)
26+
27+
</appcenter>
28+
29+
## 通过命令行工具部署
30+
31+
> 在开始之前,需要先安装 Serverless Devs 开发者工具:`npm install @serverless-devs/s -g`,更多安装方法,可以参考[Serverless Devs 安装文档](https://www.serverless-devs.com/serverless-devs/install) ,针对阿里云还需要配置密钥信息,配置密钥信息的方法可以参考[阿里云密钥配置文档](https://www.serverless-devs.com/fc/config)
32+
33+
- 初始化项目:`s init start-keep-warm-fc -d start-keep-warm-fc`
34+
> 涉及到确定密钥的选择、服务名称的确定、函数名称的确定以及容器镜像的确定
35+
- 进入项目:`cd start-keep-warm-fc`
36+
- 部署项目:`s deploy -y`
37+
- 调用函数:直接使用 POST 或者 GET 方法 curl 部署项目时候生成自定义域名
38+
39+
40+
# 应用详情
41+
42+
本应用仅作为学习和参考使用,您可以基于本项目进行二次开发和完善,实现自己的业务逻辑
43+
44+
# 关于我们
45+
46+
- Serverless Devs 工具:
47+
- 仓库:[https://www.github.com/serverless-devs/serverless-devs](https://www.github.com/serverless-devs/serverless-devs)
48+
> 欢迎帮我们增加一个 :star2:
49+
- 官网:[https://www.serverless-devs.com/](https://www.serverless-devs.com/)
50+
- 阿里云函数计算组件:
51+
- 仓库:[https://github.com/devsapp/fc](https://github.com/devsapp/fc)
52+
- 帮助文档:[https://www.serverless-devs.com/fc/readme](https://www.serverless-devs.com/fc/readme)
53+
- 钉钉交流群:33947367

keep-warm-fc/readme_en.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# keep-warm-fc Plugin case
2+
3+
<toc>
4+
5+
<p align="center"><b> <a href="./readme.md"> 中文 </a> | English </b></p>
6+
7+
- [Quick start](#Quick-start)
8+
- [Deploy via command line tool](#Deploy-via-command-line-tools)
9+
- [Application details](#Application-details)
10+
- [About Us](#About-Us)
11+
12+
</toc>
13+
14+
# Quick start
15+
16+
- [:octocat: source](https://github.com/devsapp/start-plugin/tree/master/http-function/fc-http-node.js14/src)
17+
18+
## Deploy via command line tools
19+
20+
> Before starting, you need to install the Serverless Devs developer tools: `npm install @serverless-devs/s -g`, for more installation methods, please refer to [Serverless Devs Installation Documentation](https://www.serverless-devs.com/serverless-devs/install) , you also need to configure key information for Alibaba Cloud. For the method of configuring key information, please refer to [Alibaba Cloud Key Configuration Document](https://www.serverless-devs.com/fc/config)
21+
22+
- Initialize the project: `s init start-keep-warm-fc -d start-keep-warm-fc`
23+
> It involves determining the selection of the key, the determination of the service name, the determination of the function name, and the determination of the container image
24+
- Enter the project: `cd start-keep-warm-fc`
25+
- Deploy the project: `s deploy -y`
26+
- Invoke function: Directly use POST or GET method curl to the custom domain name that is generated when deploying the project
27+
28+
# Application details
29+
30+
This application is only used for learning and reference. You can carry out secondary development and improvement based on this project to realize your own business logic.
31+
32+
# About Us
33+
34+
- Serverless Devs Tools:
35+
- Repository: [https://www.github.com/serverless-devs/serverless-devs](https://www.github.com/serverless-devs/serverless-devs)
36+
> Welcome to add a :star2:
37+
- Official website: [https://www.serverless-devs.com/](https://www.serverless-devs.com/)
38+
- Alibaba Cloud Function Compute components:
39+
- Repository: [https://github.com/devsapp/fc](https://github.com/devsapp/fc)
40+
- Help document: [https://www.serverless-devs.com/fc/readme](https://www.serverless-devs.com/fc/readme)
41+
- Dingding communication group: 33947367

keep-warm-fc/src/code/index.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var getRawBody = require('raw-body');
2+
var getFormBody = require('body/form');
3+
var body = require('body');
4+
5+
6+
/*
7+
To enable the initializer feature (https://help.aliyun.com/document_detail/156876.html)
8+
please implement the initializer function as below:
9+
exports.initializer = (context, callback) => {
10+
console.log('initializing');
11+
callback(null, '');
12+
};
13+
*/
14+
15+
exports.handler = (req, resp, context) => {
16+
console.log('hello world');
17+
18+
var params = {
19+
path: req.path,
20+
queries: req.queries,
21+
headers: req.headers,
22+
method : req.method,
23+
requestURI : req.url,
24+
clientIP : req.clientIP,
25+
}
26+
27+
getRawBody(req, function(err, body) {
28+
for (var key in req.queries) {
29+
var value = req.queries[key];
30+
resp.setHeader(key, value);
31+
}
32+
resp.setHeader('Content-Type', 'application/json');
33+
params.body = body.toString();
34+
resp.send(JSON.stringify(params, null, ' '));
35+
});
36+
37+
/*
38+
getFormBody(req, function(err, formBody) {
39+
for (var key in req.queries) {
40+
var value = req.queries[key];
41+
resp.setHeader(key, value);
42+
}
43+
params.body = formBody;
44+
console.log(formBody);
45+
resp.send(JSON.stringify(params));
46+
});
47+
*/
48+
}

keep-warm-fc/src/readme.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# keep-warm-fc 插件案例
2+
3+
<toc>
4+
5+
<p align="center"><b> 中文 | <a href="./readme_en.md"> English </a> </b></p>
6+
7+
- [快速开始](#快速开始)
8+
- [通过应用中心部署](#通过应用中心部署)
9+
- [通过命令行工具部署](#通过命令行工具部署)
10+
- [应用详情](#应用详情)
11+
- [关于我们](#关于我们)
12+
13+
</toc>
14+
15+
# 快速开始
16+
17+
- [:octocat: 源代码](https://github.com/devsapp/start-plugin/tree/master/http-function/fc-http-node.js14/src)
18+
19+
## 通过应用中心部署
20+
21+
<appcenter>
22+
23+
您可以在阿里云 [:earth_asia: Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-keep-warm-fc) ,快速体验该应用:
24+
25+
[![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=start-keep-warm-fc)
26+
27+
</appcenter>
28+
29+
## 通过命令行工具部署
30+
31+
> 在开始之前,需要先安装 Serverless Devs 开发者工具:`npm install @serverless-devs/s -g`,更多安装方法,可以参考[Serverless Devs 安装文档](https://www.serverless-devs.com/serverless-devs/install) ,针对阿里云还需要配置密钥信息,配置密钥信息的方法可以参考[阿里云密钥配置文档](https://www.serverless-devs.com/fc/config)
32+
33+
- 初始化项目:`s init start-keep-warm-fc -d start-keep-warm-fc`
34+
> 涉及到确定密钥的选择、服务名称的确定、函数名称的确定以及容器镜像的确定
35+
- 进入项目:`cd start-keep-warm-fc`
36+
- 部署项目:`s deploy -y`
37+
- 调用函数:直接使用 POST 或者 GET 方法 curl 部署项目时候生成自定义域名
38+
39+
40+
# 应用详情
41+
42+
本应用仅作为学习和参考使用,您可以基于本项目进行二次开发和完善,实现自己的业务逻辑
43+
44+
# 关于我们
45+
46+
- Serverless Devs 工具:
47+
- 仓库:[https://www.github.com/serverless-devs/serverless-devs](https://www.github.com/serverless-devs/serverless-devs)
48+
> 欢迎帮我们增加一个 :star2:
49+
- 官网:[https://www.serverless-devs.com/](https://www.serverless-devs.com/)
50+
- 阿里云函数计算组件:
51+
- 仓库:[https://github.com/devsapp/fc](https://github.com/devsapp/fc)
52+
- 帮助文档:[https://www.serverless-devs.com/fc/readme](https://www.serverless-devs.com/fc/readme)
53+
- 钉钉交流群:33947367

keep-warm-fc/src/readme_en.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# keep-warm-fc Plugin case
2+
3+
<toc>
4+
5+
<p align="center"><b> <a href="./readme.md"> 中文 </a> | English </b></p>
6+
7+
- [Quick start](#Quick-start)
8+
- [Deploy via command line tool](#Deploy-via-command-line-tools)
9+
- [Application details](#Application-details)
10+
- [About Us](#About-Us)
11+
12+
</toc>
13+
14+
# Quick start
15+
16+
- [:octocat: source](https://github.com/devsapp/start-plugin/tree/master/http-function/fc-http-node.js14/src)
17+
18+
## Deploy via command line tools
19+
20+
> Before starting, you need to install the Serverless Devs developer tools: `npm install @serverless-devs/s -g`, for more installation methods, please refer to [Serverless Devs Installation Documentation](https://www.serverless-devs.com/serverless-devs/install) , you also need to configure key information for Alibaba Cloud. For the method of configuring key information, please refer to [Alibaba Cloud Key Configuration Document](https://www.serverless-devs.com/fc/config)
21+
22+
- Initialize the project: `s init start-keep-warm-fc -d start-keep-warm-fc`
23+
> It involves determining the selection of the key, the determination of the service name, the determination of the function name, and the determination of the container image
24+
- Enter the project: `cd start-keep-warm-fc`
25+
- Deploy the project: `s deploy -y`
26+
- Invoke function: Directly use POST or GET method curl to the custom domain name that is generated when deploying the project
27+
28+
# Application details
29+
30+
This application is only used for learning and reference. You can carry out secondary development and improvement based on this project to realize your own business logic.
31+
32+
# About Us
33+
34+
- Serverless Devs Tools:
35+
- Repository: [https://www.github.com/serverless-devs/serverless-devs](https://www.github.com/serverless-devs/serverless-devs)
36+
> Welcome to add a :star2:
37+
- Official website: [https://www.serverless-devs.com/](https://www.serverless-devs.com/)
38+
- Alibaba Cloud Function Compute components:
39+
- Repository: [https://github.com/devsapp/fc](https://github.com/devsapp/fc)
40+
- Help document: [https://www.serverless-devs.com/fc/readme](https://www.serverless-devs.com/fc/readme)
41+
- Dingding communication group: 33947367

0 commit comments

Comments
 (0)