├── .github └── workflows │ ├── eggjs-starter.yml │ ├── express-starter.yml │ ├── flask-starter.yml │ ├── fullstack.yml │ ├── koa-starter.yml │ ├── multi-scf-db-starter.yml │ ├── multi-scf-nodejs.yml │ ├── multi-scf-python.yml │ ├── multi-scf-starter.yml │ ├── nextjs-starter.yml │ ├── nuxtjs-starter.yml │ ├── react-starter.yml │ ├── restful-api.yml │ ├── scf-golang.yml │ ├── scf-nodejs.yml │ ├── scf-php.yml │ ├── scf-python.yml │ ├── scf-starter.yml │ ├── springboot-starter.yml │ ├── transcode-app.yml │ ├── vue-starter.yml │ └── website-starter.yml ├── .gitignore ├── LICENSE ├── README.md ├── README_EN.md ├── eggjs-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── .gitignore │ ├── .travis.yml │ ├── README.md │ ├── README_EN.md │ ├── app │ ├── controller │ │ ├── home.js │ │ └── user.js │ ├── public │ │ └── styles │ │ │ └── index.css │ ├── router.js │ ├── utils │ │ ├── constants.js │ │ └── index.js │ └── view │ │ └── index.html │ ├── appveyor.yml │ ├── config │ ├── config.default.js │ └── plugin.js │ ├── jsconfig.json │ ├── package.json │ └── serverless.yml ├── express-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── .gitignore │ ├── README.md │ ├── README_EN.md │ ├── app.js │ ├── index.html │ ├── package.json │ └── serverless.yml ├── flask-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── __pycache__ │ ├── typing_extensions.cpython-36.pyc │ └── zipp.cpython-36.pyc │ ├── app.py │ ├── requirements.txt │ ├── serverless.yml │ └── templates │ └── index.html ├── fullstack-mysql ├── LICENSE ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── .gitignore │ ├── README.md │ ├── api │ ├── .env.example │ ├── README.md │ ├── controller │ │ ├── db.js │ │ └── user.js │ ├── db.sql │ ├── docker-compose.yml │ ├── package.json │ ├── serverless.yml │ └── sls.js │ ├── db │ └── serverless.yml │ ├── frontend │ ├── .gitkeep │ ├── README.md │ ├── babel.config.js │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ ├── serverless.yml │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ ├── fonts │ │ │ │ ├── serverless-regular.woff │ │ │ │ └── serverless-regular.woff2 │ │ │ ├── fullstack.png │ │ │ ├── serverless-logo.png │ │ │ ├── serverless-logo.svg │ │ │ ├── tencent-cloud-hero.gif │ │ │ └── tencent-cloud-logo.png │ │ ├── components │ │ │ ├── UserForm.vue │ │ │ └── UserList.vue │ │ ├── event-bus.js │ │ ├── main.js │ │ ├── plugins │ │ │ └── element.js │ │ ├── style │ │ │ └── app.css │ │ └── theme │ │ │ ├── fonts │ │ │ ├── element-icons.ttf │ │ │ └── element-icons.woff │ │ │ └── index.css │ └── vue.config.js │ ├── package.json │ ├── scripts │ └── bootstrap.js │ ├── serverless.yml │ ├── tests │ ├── integration.test.js │ └── utils.js │ └── vpc │ └── serverless.yml ├── fullstack-sequelize ├── LICENSE ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── .gitignore │ ├── README.md │ ├── backend │ ├── .env.example │ ├── README.md │ ├── app.js │ ├── config │ │ └── db.js │ ├── controller │ │ └── user.js │ ├── database │ │ ├── db.sql │ │ └── index.js │ ├── docker-compose.yml │ ├── models │ │ └── user.js │ ├── package.json │ ├── routes │ │ └── index.js │ ├── server.js │ ├── serverless.yml │ └── sls.js │ ├── db │ └── serverless.yml │ ├── frontend │ ├── .gitkeep │ ├── README.md │ ├── babel.config.js │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ ├── serverless.yml │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ ├── fullstack.png │ │ │ ├── serverless-logo.png │ │ │ ├── serverless-logo.svg │ │ │ ├── tencent-cloud-hero.gif │ │ │ └── tencent-cloud-logo.png │ │ ├── components │ │ │ ├── UserForm.vue │ │ │ └── UserList.vue │ │ ├── event-bus.js │ │ ├── main.js │ │ ├── plugins │ │ │ └── element.js │ │ ├── style │ │ │ └── app.css │ │ └── theme │ │ │ ├── fonts │ │ │ ├── element-icons.ttf │ │ │ └── element-icons.woff │ │ │ └── index.css │ └── vue.config.js │ └── vpc │ └── serverless.yml ├── fullstack ├── LICENSE ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── .gitignore │ ├── README.md │ ├── README_EN.md │ ├── api │ ├── controller │ │ └── user.js │ ├── package.json │ ├── serverless.yml │ └── sls.js │ ├── db │ └── serverless.yml │ ├── frontend │ ├── .gitkeep │ ├── README.md │ ├── babel.config.js │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ ├── serverless.yml │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ ├── fonts │ │ │ │ ├── serverless-regular.woff │ │ │ │ └── serverless-regular.woff2 │ │ │ ├── fullstack.png │ │ │ └── tencent-cloud-hero.gif │ │ ├── components │ │ │ ├── UserForm.vue │ │ │ └── UserList.vue │ │ ├── config.js │ │ ├── main.js │ │ └── style │ │ │ └── app.css │ └── vue.config.js │ ├── package.json │ ├── scripts │ └── bootstrap.js │ ├── serverless.yml │ ├── tests │ ├── integration.test.js │ └── utils.js │ └── vpc │ └── serverless.yml ├── koa-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── app.js │ ├── index.html │ ├── package.json │ └── serverless.yml ├── laravel-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── .editorconfig │ ├── .env.example │ ├── .env.production │ ├── .gitattributes │ ├── .gitignore │ ├── .styleci.yml │ ├── README.md │ ├── README_EN.md │ ├── app │ ├── Console │ │ └── Kernel.php │ ├── Exceptions │ │ └── Handler.php │ ├── Http │ │ ├── Controllers │ │ │ └── Controller.php │ │ ├── Kernel.php │ │ └── Middleware │ │ │ ├── Authenticate.php │ │ │ ├── CheckForMaintenanceMode.php │ │ │ ├── EncryptCookies.php │ │ │ ├── RedirectIfAuthenticated.php │ │ │ ├── TrimStrings.php │ │ │ ├── TrustHosts.php │ │ │ ├── TrustProxies.php │ │ │ └── VerifyCsrfToken.php │ ├── Providers │ │ ├── AppServiceProvider.php │ │ ├── AuthServiceProvider.php │ │ ├── BroadcastServiceProvider.php │ │ ├── EventServiceProvider.php │ │ └── RouteServiceProvider.php │ └── User.php │ ├── artisan │ ├── bootstrap │ ├── app.php │ └── cache │ │ └── .gitignore │ ├── composer.json │ ├── composer.lock │ ├── config │ ├── app.php │ ├── auth.php │ ├── broadcasting.php │ ├── cache.php │ ├── cors.php │ ├── database.php │ ├── filesystems.php │ ├── hashing.php │ ├── logging.php │ ├── mail.php │ ├── queue.php │ ├── services.php │ ├── session.php │ └── view.php │ ├── database │ ├── .gitignore │ ├── factories │ │ └── UserFactory.php │ ├── migrations │ │ ├── 2014_10_12_000000_create_users_table.php │ │ └── 2019_08_19_000000_create_failed_jobs_table.php │ └── seeds │ │ └── DatabaseSeeder.php │ ├── package.json │ ├── phpunit.xml │ ├── public │ ├── .htaccess │ ├── favicon.ico │ ├── index.php │ ├── robots.txt │ └── web.config │ ├── resources │ ├── js │ │ ├── app.js │ │ └── bootstrap.js │ ├── lang │ │ └── en │ │ │ ├── auth.php │ │ │ ├── pagination.php │ │ │ ├── passwords.php │ │ │ └── validation.php │ ├── sass │ │ └── app.scss │ └── views │ │ └── welcome.blade.php │ ├── routes │ ├── api.php │ ├── channels.php │ ├── console.php │ └── web.php │ ├── server.php │ ├── serverless.yml │ ├── storage │ └── framework │ │ └── views │ │ ├── 5974a20b5097c79d9b6e2ca48080a376f85e3940.php │ │ ├── 641ce7419f4834c1fb5522e743e2c36b19fafca1.php │ │ └── e8b4bb9e9045b5e4d42d503b4ce315a579ab90fc.php │ └── webpack.mix.js ├── multi-scf-db-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── db │ └── serverless.yml │ ├── server │ ├── index.js │ ├── package.json │ └── serverless.yml │ ├── serverless.yml │ └── vpc │ └── serverless.yml ├── multi-scf-nodejs ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── index.js │ └── serverless.yml ├── multi-scf-python ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── index.py │ └── serverless.yml ├── multi-scf-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── index.js │ └── serverless.yml ├── nextjs-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── .env.example │ ├── .gitignore │ ├── README.md │ ├── README_EN.md │ ├── next.config.js │ ├── package.json │ ├── pages │ ├── _app.js │ ├── api │ │ └── hello.js │ └── index.js │ ├── public │ └── favicon.ico │ ├── serverless.yml │ └── styles │ ├── global.css │ └── index.module.css ├── nuxtjs-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── .editorconfig │ ├── .env.example │ ├── .gitignore │ ├── README.md │ ├── README_EN.md │ ├── assets │ └── README.md │ ├── components │ ├── Logo.vue │ └── README.md │ ├── layouts │ ├── README.md │ └── default.vue │ ├── middleware │ └── README.md │ ├── nuxt.config.js │ ├── package.json │ ├── pages │ ├── README.md │ └── index.vue │ ├── plugins │ └── README.md │ ├── serverless.yml │ ├── static │ ├── README.md │ └── favicon.ico │ └── store │ └── README.md ├── package.json ├── react-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── .gitignore │ ├── App.js │ ├── README.md │ ├── README_EN.md │ ├── app.css │ ├── fonts │ ├── serverless-regular.woff │ └── serverless-regular.woff2 │ ├── images │ ├── favicon.ico │ └── hero.png │ ├── index.html │ ├── index.js │ ├── package.json │ └── serverless.yml ├── restful-api ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── index.py │ └── serverless.yml ├── scf-golang ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── main │ └── serverless.yaml ├── scf-nodejs ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── index.js │ └── serverless.yml ├── scf-php ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── index.php │ ├── serverless.yml │ └── template.yaml ├── scf-python ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── index.py │ └── serverless.yml ├── scf-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── index.js │ └── serverless.yml ├── scripts ├── generateREADMEs.js └── publishAllTemplates.js ├── springboot-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── .gitignore │ ├── pom.xml │ ├── serverless.yml │ └── src │ └── main │ ├── java │ └── example │ │ ├── DemoApplication.java │ │ ├── MyHandler.java │ │ └── controller │ │ ├── HelloController.java │ │ └── MyController.java │ └── resources │ ├── application.properties │ ├── static │ ├── bg.png │ └── test.txt │ └── templates │ └── index.html ├── transcode-app ├── .gitignore ├── README.md ├── serverless.template.yml └── src │ ├── .env │ ├── log │ └── serverless.yml │ ├── serverless.yml │ └── transcode │ ├── serverless.yml │ └── src │ ├── ffmpeg │ └── index.py ├── vue-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src │ ├── README.md │ ├── README_EN.md │ ├── babel.config.js │ ├── package.json │ ├── public │ ├── favicon.ico │ └── index.html │ ├── serverless.yml │ ├── src │ ├── App.vue │ ├── assets │ │ └── logo.png │ ├── components │ │ └── HelloWorld.vue │ └── main.js │ └── tests │ ├── integration.test.js │ └── utils.js └── website-starter ├── README.md ├── README_EN.md ├── serverless.template.yml └── src ├── README.md ├── README_EN.md ├── serverless.yml └── src └── index.html /.github/workflows/eggjs-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test eggjs-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'eggjs-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd eggjs-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init eggjs-starter --name test-eggjs-starter 33 | -------------------------------------------------------------------------------- /.github/workflows/express-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test express-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'express-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd express-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init express-starter --name test-express-starter 33 | -------------------------------------------------------------------------------- /.github/workflows/flask-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test flask-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'flask-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd flask-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init flask-starter --name test-flask-starter 33 | -------------------------------------------------------------------------------- /.github/workflows/fullstack.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test fullstack 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'fullstack/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd fullstack 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init fullstack --name test-fullstack 33 | -------------------------------------------------------------------------------- /.github/workflows/koa-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test koa-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'koa-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd koa-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init koa-starter --name test-koa-starter 33 | -------------------------------------------------------------------------------- /.github/workflows/multi-scf-db-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test multi-scf-db-starter 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | paths: ['multi-scf-db-starter/**'] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: cd multi-scf-db-starter && sls publish 27 | - name: Test template 28 | run: | 29 | sls init multi-scf-db-starter --name test-multi-scf-db-starter 30 | -------------------------------------------------------------------------------- /.github/workflows/multi-scf-nodejs.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test multi-scf-nodejs 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'multi-scf-nodejs/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd multi-scf-nodejs 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init multi-scf-nodejs --name test-multi-scf-nodejs 33 | -------------------------------------------------------------------------------- /.github/workflows/multi-scf-python.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test multi-scf-python 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | paths: ['multi-scf-python/**'] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd multi-scf-python 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init multi-scf-python --name test-multi-scf-python 33 | -------------------------------------------------------------------------------- /.github/workflows/multi-scf-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test multi-scf-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'multi-scf-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd multi-scf-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init multi-scf-starter --name test-multi-scf-starter 33 | -------------------------------------------------------------------------------- /.github/workflows/nextjs-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test nextjs-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'nextjs-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd nextjs-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init nextjs-starter --name test-nextjs-starter 33 | -------------------------------------------------------------------------------- /.github/workflows/nuxtjs-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test nuxtjs-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'nuxtjs-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd nuxtjs-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init nuxtjs-starter --name test-nuxtjs-starter 33 | -------------------------------------------------------------------------------- /.github/workflows/react-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test react-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'react-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd react-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init react-starter --name test-react-starter 33 | -------------------------------------------------------------------------------- /.github/workflows/restful-api.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test restful-api 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'restful-api/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd restful-api 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init restful-api --name test-restful-api 33 | -------------------------------------------------------------------------------- /.github/workflows/scf-golang.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test scf-golang 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'scf-golang/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd scf-golang 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init scf-golang --name test-scf-golang 33 | -------------------------------------------------------------------------------- /.github/workflows/scf-nodejs.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test scf-nodejs 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'scf-nodejs/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd scf-nodejs 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init scf-nodejs --name test-scf-nodejs 33 | cd test-scf-nodejs 34 | sls deploy 35 | -------------------------------------------------------------------------------- /.github/workflows/scf-php.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test scf-php 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'scf-php/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd scf-php 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init scf-php --name test-scf-php 33 | -------------------------------------------------------------------------------- /.github/workflows/scf-python.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test scf-python 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'scf-python/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd scf-python 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init scf-python --name test-scf-python 33 | -------------------------------------------------------------------------------- /.github/workflows/scf-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test scf-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'scf-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd scf-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init scf-starter --name test-scf-starter 33 | -------------------------------------------------------------------------------- /.github/workflows/springboot-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test springboot-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'springboot-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd springboot-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init springboot-starter --name test-springboot-starter 33 | 34 | -------------------------------------------------------------------------------- /.github/workflows/transcode-app.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test transcode-app 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'transcode-app/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd transcode-app 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | -------------------------------------------------------------------------------- /.github/workflows/vue-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test vue-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'vue-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd vue-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init vue-starter --name test-vue-starter 33 | -------------------------------------------------------------------------------- /.github/workflows/website-starter.yml: -------------------------------------------------------------------------------- 1 | name: Publish and test website-starter 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: [ 'website-starter/**' ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publishAndTest: 13 | runs-on: ubuntu-latest 14 | env: 15 | TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} 16 | TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} 17 | SERVERLESS_PLATFORM_VENDOR: tencent 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v1 21 | with: 22 | node-version: '14.x' 23 | - name: Install serverless cli 24 | run: sudo npm i serverless -g 25 | - name: Publish template 26 | run: | 27 | cd website-starter 28 | SERVERLESS_PLATFORM_STAGE=dev sls publish 29 | sls publish 30 | - name: Test template 31 | run: | 32 | sls init website-starter --name test-website-starter 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.sublime-project 3 | *.sublime-workspace 4 | *.log 5 | .serverless 6 | v8-compile-cache-* 7 | jest/* 8 | coverage 9 | node_modules 10 | .vscode/ 11 | .eslintcache 12 | dist 13 | .idea 14 | build/ 15 | .env 16 | .cache* 17 | env.js 18 | tmp 19 | package-lock.json 20 | yarn.lock 21 | test 22 | .npmrc 23 | .next 24 | .nuxt -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Serverless Components 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /eggjs-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: eggjs-starter 2 | displayName: Egg.js 项目模版 3 | author: Tencent Cloud, Inc. 4 | org: Tencent Cloud, Inc. 5 | description: Deploy an egg.js app via SCF and Apigateway 6 | description-i18n: 7 | zh-cn: 快速部署一个Egg.js 基础应用 8 | type: template 9 | keywords: tencent, Egg, nodejs 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/eggjs-starter 11 | readme: https://github.com/serverless-components/tencent-examples/blob/master/eggjs-starter/README.md 12 | license: MIT 13 | src: 14 | src: ./src 15 | exclude: 16 | - '**/node_modules' 17 | -------------------------------------------------------------------------------- /eggjs-starter/src/.gitignore: -------------------------------------------------------------------------------- 1 | logs/ 2 | npm-debug.log 3 | yarn-error.log 4 | node_modules/ 5 | package-lock.json 6 | yarn.lock 7 | coverage/ 8 | .idea/ 9 | run/ 10 | .DS_Store 11 | *.sw* 12 | *.un~ 13 | typings/ 14 | .nyc_output/ 15 | -------------------------------------------------------------------------------- /eggjs-starter/src/.travis.yml: -------------------------------------------------------------------------------- 1 | 2 | language: node_js 3 | node_js: 4 | - '10' 5 | before_install: 6 | - npm i npminstall -g 7 | install: 8 | - npminstall 9 | script: 10 | - npm run ci 11 | after_script: 12 | - npminstall codecov && codecov 13 | -------------------------------------------------------------------------------- /eggjs-starter/src/app/controller/home.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Controller = require('egg').Controller 4 | 5 | class HomeController extends Controller { 6 | async index() { 7 | const { ctx } = this 8 | 9 | ctx.set('content-type', 'text/html') 10 | await ctx.render('index.html', { 11 | msg: 'hi, egg' 12 | }) 13 | } 14 | 15 | async event() { 16 | const { ctx } = this 17 | ctx.body = { 18 | req: ctx.req.__SLS_EVENT__, 19 | request: ctx.request.__SLS_EVENT__ 20 | } 21 | } 22 | 23 | async getConfig() { 24 | const { ctx } = this 25 | ctx.body = this.config 26 | } 27 | } 28 | 29 | module.exports = HomeController 30 | -------------------------------------------------------------------------------- /eggjs-starter/src/app/controller/user.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { Controller } = require('egg') 4 | const { sleep } = require('../utils/index') 5 | 6 | class UserController extends Controller { 7 | async list() { 8 | const { ctx } = this 9 | await sleep(Math.random()) 10 | ctx.body = [ 11 | { 12 | id: 1, 13 | name: 'yugasun', 14 | email: 'yuga_sun@163.com' 15 | } 16 | ] 17 | } 18 | } 19 | 20 | module.exports = UserController 21 | -------------------------------------------------------------------------------- /eggjs-starter/src/app/router.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /** 4 | * @param {Egg.Application} app - egg application 5 | */ 6 | module.exports = (app) => { 7 | const { 8 | router, 9 | controller, 10 | config: { apiPrefix } 11 | } = app 12 | router.get('/', controller.home.index) 13 | router.get('/event', controller.home.event) 14 | 15 | router.get('/user', controller.user.list) 16 | } 17 | -------------------------------------------------------------------------------- /eggjs-starter/src/app/utils/constants.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | ONE_SECOND: 1000 5 | } 6 | -------------------------------------------------------------------------------- /eggjs-starter/src/app/utils/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { ONE_SECOND } = require('./constants') 4 | 5 | async function sleep(seconds) { 6 | setTimeout(() => { 7 | Promise.resolve(true) 8 | }, seconds * ONE_SECOND) 9 | } 10 | 11 | module.exports = { 12 | sleep 13 | } 14 | -------------------------------------------------------------------------------- /eggjs-starter/src/app/view/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Serverless - Egg.js 9 | 16 | 17 | 18 |

19 | 欢迎访问 Egg.js 应用 20 |
21 |
22 | 23 | 腾讯云 Serverless 24 | 25 | 为您提供服务 26 |

27 | 28 | 29 | -------------------------------------------------------------------------------- /eggjs-starter/src/appveyor.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | matrix: 3 | - nodejs_version: '10' 4 | 5 | install: 6 | - ps: Install-Product node $env:nodejs_version 7 | - npm i npminstall && node_modules\.bin\npminstall 8 | 9 | test_script: 10 | - node --version 11 | - npm --version 12 | - npm run test 13 | 14 | build: off 15 | -------------------------------------------------------------------------------- /eggjs-starter/src/config/config.default.js: -------------------------------------------------------------------------------- 1 | /* eslint valid-jsdoc: "off" */ 2 | 3 | 'use strict' 4 | 5 | /** 6 | * @param {Egg.EggAppInfo} appInfo app info 7 | */ 8 | module.exports = (appInfo) => { 9 | /** 10 | * built-in config 11 | * @type {Egg.EggAppConfig} 12 | **/ 13 | const config = {} 14 | 15 | // use for cookie sign key, should change to your own and keep security 16 | config.keys = appInfo.name + '_1576384476895_3620' 17 | 18 | // add your middleware config here 19 | config.middleware = [] 20 | 21 | // add your user config here 22 | const userConfig = { 23 | view: { 24 | mapping: { 25 | '.html': 'nunjucks' 26 | } 27 | } 28 | } 29 | 30 | return { 31 | ...config, 32 | ...userConfig 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /eggjs-starter/src/config/plugin.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /** @type Egg.EggPlugin */ 4 | module.exports = { 5 | // had enabled by egg 6 | static: { 7 | enable: true 8 | }, 9 | nunjucks: { 10 | enable: true, 11 | package: 'egg-view-nunjucks' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /eggjs-starter/src/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["**/*"] 3 | } 4 | -------------------------------------------------------------------------------- /eggjs-starter/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "private": true, 6 | "egg": { 7 | "declarations": true 8 | }, 9 | "dependencies": { 10 | "egg": "^2.15.1", 11 | "egg-scripts": "^2.11.0", 12 | "egg-view-nunjucks": "^2.3.0" 13 | }, 14 | "devDependencies": { 15 | "autod": "^3.0.1", 16 | "autod-egg": "^1.1.0", 17 | "egg-bin": "^4.11.0", 18 | "egg-ci": "^1.11.0", 19 | "egg-mock": "^3.21.0", 20 | "eslint": "^5.13.0", 21 | "eslint-config-egg": "^7.1.0" 22 | }, 23 | "engines": { 24 | "node": ">=10.0.0" 25 | }, 26 | "scripts": { 27 | "start": "egg-scripts start --title=egg-server --port=9000", 28 | "stop": "egg-scripts stop --title=egg-server-test", 29 | "dev": "egg-bin dev", 30 | "debug": "egg-bin debug", 31 | "test": "npm run lint -- --fix && npm run test-local", 32 | "test-local": "egg-bin test", 33 | "cov": "egg-bin cov", 34 | "lint": "eslint .", 35 | "ci": "npm run lint && npm run cov", 36 | "autod": "autod" 37 | }, 38 | "ci": { 39 | "version": "10" 40 | }, 41 | "repository": { 42 | "type": "git", 43 | "url": "" 44 | }, 45 | "author": "", 46 | "license": "MIT" 47 | } 48 | -------------------------------------------------------------------------------- /eggjs-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: http 2 | name: eggDemo 3 | 4 | inputs: 5 | src: 6 | src: ./ 7 | exclude: 8 | - .env 9 | faas: 10 | runtime: Nodejs12.16 11 | framework: egg 12 | name: ${name} 13 | apigw: 14 | protocols: 15 | - http 16 | - https 17 | -------------------------------------------------------------------------------- /express-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: express-starter 2 | displayName: Express.js 项目模版 3 | author: Tencent Cloud, Inc. 4 | org: Tencent Cloud, Inc. 5 | description: Deploy an Express.js app via SCF and Apigateway 6 | description-i18n: 7 | zh-cn: 快速部署一个 Express.js 基础应用 8 | type: template 9 | keywords: tencent, Expressjs, nodejs, SCF, APIGateway 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/express-starter 11 | readme: https://github.com/serverless-components/tencent-examples/tree/master/express-starter/README.md 12 | license: MIT 13 | src: 14 | src: ./src 15 | exclude: 16 | - '**/node_modules' 17 | 18 | -------------------------------------------------------------------------------- /express-starter/src/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /express-starter/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Serverless - Express.js 9 | 16 | 17 | 18 |

19 | 欢迎访问 Express.js 应用 20 |
21 | 22 | 腾讯云 Serverless 23 | 24 | 为您提供服务 25 |

26 | 27 | 28 | -------------------------------------------------------------------------------- /express-starter/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "express-demo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "sls.js", 6 | "scripts": { 7 | "dev": "NODE_ENV=development node app.js" 8 | }, 9 | "author": "yugasun", 10 | "license": "MIT", 11 | "dependencies": { 12 | "express": "^4.17.1", 13 | "multer": "^1.4.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /express-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: http 2 | name: expressDemo 3 | 4 | inputs: 5 | src: 6 | src: ./ 7 | exclude: 8 | - .env 9 | faas: 10 | runtime: Nodejs12.16 11 | framework: express 12 | name: ${name} 13 | apigw: 14 | protocols: 15 | - http 16 | - https 17 | -------------------------------------------------------------------------------- /flask-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: flask-starter 2 | displayName: Flask 项目模版 3 | author: Tencent Cloud, Inc. 4 | org: Tencent Cloud, Inc. 5 | description: Deploy an Flask app via SCF and Apigateway 6 | description-i18n: 7 | zh-cn: 快速部署一个 Flask 基础应用 8 | type: template 9 | keywords: tencent, Flask, python, SCF, APIGateway 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/flask-starter 11 | readme: https://github.com/serverless-components/tencent-examples/blob/master/flask-starter/README.md 12 | license: MIT 13 | src: 14 | src: ./src 15 | exclude: 16 | 17 | -------------------------------------------------------------------------------- /flask-starter/src/__pycache__/typing_extensions.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/flask-starter/src/__pycache__/typing_extensions.cpython-36.pyc -------------------------------------------------------------------------------- /flask-starter/src/__pycache__/zipp.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/flask-starter/src/__pycache__/zipp.cpython-36.pyc -------------------------------------------------------------------------------- /flask-starter/src/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, jsonify, render_template 2 | app = Flask(__name__) 3 | 4 | 5 | @app.route("/") 6 | def index(): 7 | return render_template('index.html') 8 | 9 | 10 | @app.route("/users") 11 | def users(): 12 | users = [{'name': 'test1'}, {'name': 'test2'}] 13 | return jsonify(data=users) 14 | 15 | 16 | @app.route("/users/") 17 | def user(id): 18 | return jsonify(data={'name': 'test1'}) 19 | 20 | # HTTP 直通函数由于是基于 docker 镜像运行,所以必须监听地址为 0.0.0.0,并且端口为 9000 21 | app.run(host = '0.0.0.0', port = 9000) 22 | -------------------------------------------------------------------------------- /flask-starter/src/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==1.0.2 2 | # TODO: 由于云函数运行环境 Python3.6 版本太低,werkzeug 只能使用低版本 3 | werkzeug==1.0.1 4 | -------------------------------------------------------------------------------- /flask-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: http 2 | name: flaskDemo 3 | 4 | inputs: 5 | src: 6 | # TODO: 安装python项目依赖到项目当前目录 7 | hook: 'pip3 install -r requirements.txt -t ./' 8 | dist: ./ 9 | exclude: 10 | - .env 11 | - 'requirements/**' 12 | - '__pycache__/**' 13 | region: ap-guangzhou 14 | faas: 15 | framework: flask 16 | name: ${name} 17 | runtime: Python3.6 18 | apigw: 19 | protocols: 20 | - http 21 | - https 22 | -------------------------------------------------------------------------------- /flask-starter/src/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Serverless Flask 7 | 14 | 15 | 16 |

17 | 欢迎访问 Flask 应用 18 |
19 |
20 | 21 | 腾讯云 Serverless 22 | 23 | 为您提供服务 24 |

25 | 26 | 27 | -------------------------------------------------------------------------------- /fullstack-mysql/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Yuga Sun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /fullstack-mysql/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: fullstack-mysql 2 | author: Tencent Cloud, Inc. 3 | org: Tencent Cloud, Inc. 4 | description: Deploy a full stack application. 5 | description-i18n: 6 | zh-cn: 快速部署一个 Full Stack 应用, vuejs + express + mysql 7 | keywords: tencent, serverless, express, website, fullstack 8 | repo: https://github.com/serverless-components/tencent-examples/tree/master/fullstack-mysql 9 | readme: https://github.com/serverless-components/tencent-examples/tree/master/fullstack-mysql/README.md 10 | license: MIT 11 | src: 12 | src: ./src 13 | exclude: 14 | - .env 15 | - '.git/**' 16 | - serverless.yml 17 | - '**/node_modules' 18 | - '**/package-lock.json' 19 | -------------------------------------------------------------------------------- /fullstack-mysql/src/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.sublime-project 3 | *.sublime-workspace 4 | *.log 5 | .serverless 6 | v8-compile-cache-* 7 | jest/* 8 | coverage 9 | testProjects/*/package-lock.json 10 | testProjects/*/yarn.lock 11 | .serverlessUnzipped 12 | node_modules 13 | .vscode/ 14 | .eslintcache 15 | dist 16 | .idea 17 | build/ 18 | .env 19 | .cache* 20 | .serverless 21 | .serverless_nextjs 22 | .serverless_plugins 23 | env.js 24 | tmp 25 | package-lock.json 26 | yarn.lock 27 | test 28 | .npmrc -------------------------------------------------------------------------------- /fullstack-mysql/src/api/.env.example: -------------------------------------------------------------------------------- 1 | # mysql 配置,依赖 docker-compose.yml 中的初始化配置 2 | DB_HOST=127.0.0.1 3 | DB_PORT=3306 4 | DB_USER=root 5 | DB_PASSWORD=xxx -------------------------------------------------------------------------------- /fullstack-mysql/src/api/README.md: -------------------------------------------------------------------------------- 1 | # 后端服务 2 | 3 | 本地开发调试,数据库连接可以先通过 docker 来模拟 MySQL 服务。待业务代码开发调试成功后,再部署到云端 Serverless. 4 | 5 | ## 本地开发 6 | 7 | 安装依赖: 8 | 9 | ```bash 10 | $ npm install 11 | ``` 12 | 13 | 启动 Docker Mysql 容器: 14 | 15 | ```bash 16 | $ npm run docker:up 17 | ``` 18 | 19 | 将 `.env.example` 复制为 `.env`,并将 `DB_PASSWORD` 的值修改为 `docker-comopse.yml` 中配置的 `MYSQL_ROOT_PASSWORD` 的值。 20 | 21 | 本地启动 Express 服务: 22 | 23 | ```bash 24 | $ npm run dev 25 | ``` 26 | -------------------------------------------------------------------------------- /fullstack-mysql/src/api/db.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS fullstack; 2 | 3 | USE fullstack; 4 | 5 | CREATE TABLE IF NOT EXISTS users( 6 | id INT UNSIGNED AUTO_INCREMENT COMMENT 'primary key', 7 | name VARCHAR(30) DEFAULT NULL, 8 | email VARCHAR(50) DEFAULT NULL, 9 | site VARCHAR(50) DEFAULT NULL, 10 | PRIMARY KEY (id) 11 | )ENGINE=InnoDB DEFAULT CHARSET=utf8; -------------------------------------------------------------------------------- /fullstack-mysql/src/api/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Use root/example as user/password credentials 2 | version: '3.1' 3 | 4 | services: 5 | db: 6 | image: mysql 7 | restart: always 8 | ports: 9 | - 3306:3306 10 | environment: 11 | MYSQL_USER: root 12 | MYSQL_ROOT_PASSWORD: root 13 | 14 | adminer: 15 | image: adminer 16 | restart: always 17 | ports: 18 | - 8080:8080 -------------------------------------------------------------------------------- /fullstack-mysql/src/api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@serverless-fullstack/api", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "dev": "NODE_ENV=development node sls.js", 6 | "docker:up": "docker-compose up -d" 7 | }, 8 | "dependencies": { 9 | "cors": "^2.8.5", 10 | "dotenv": "^8.2.0", 11 | "express": "^4.17.1", 12 | "mysql2": "^2.2.5" 13 | }, 14 | "license": "MIT" 15 | } 16 | -------------------------------------------------------------------------------- /fullstack-mysql/src/api/serverless.yml: -------------------------------------------------------------------------------- 1 | app: fullstack-mysql-app 2 | 3 | component: express 4 | name: fullstack-api 5 | 6 | inputs: 7 | src: 8 | src: ./ 9 | exclude: 10 | - .env 11 | functionName: ${name} 12 | region: ${env:REGION} 13 | runtime: Nodejs12.16 14 | functionConf: 15 | timeout: 30 16 | vpcConfig: 17 | vpcId: ${output:${stage}:${app}:fullstack-vpc.vpcId} 18 | subnetId: ${output:${stage}:${app}:fullstack-vpc.subnetId} 19 | environment: 20 | variables: 21 | DB_HOST: ${output:${stage}:${app}:fullstack-db.connection.ip} 22 | DB_PORT: ${output:${stage}:${app}:fullstack-db.connection.port} 23 | DB_USER: root 24 | DB_PASSWORD: ${output:${stage}:${app}:fullstack-db.adminPassword} 25 | apigatewayConf: 26 | enableCORS: true 27 | protocols: 28 | - http 29 | - https 30 | -------------------------------------------------------------------------------- /fullstack-mysql/src/db/serverless.yml: -------------------------------------------------------------------------------- 1 | app: fullstack-mysql-app 2 | 3 | component: cynosdb 4 | name: fullstack-db 5 | 6 | inputs: 7 | region: ${env:REGION} 8 | zone: ${env:ZONE} 9 | vpcConfig: 10 | vpcId: ${output:${stage}:${app}:fullstack-vpc.vpcId} 11 | subnetId: ${output:${stage}:${app}:fullstack-vpc.subnetId} 12 | enablePublicAccess: true 13 | -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-mysql/src/frontend/.gitkeep -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/README.md: -------------------------------------------------------------------------------- 1 | # frontend 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Lints and fixes files 19 | ``` 20 | npm run lint 21 | ``` 22 | 23 | ### Customize configuration 24 | See [Configuration Reference](https://cli.vuejs.org/config/). 25 | -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.19.0", 12 | "core-js": "^3.4.3", 13 | "element-ui": "^2.4.5", 14 | "vue": "^2.6.10" 15 | }, 16 | "devDependencies": { 17 | "@vue/cli-plugin-babel": "^4.1.0", 18 | "@vue/cli-plugin-eslint": "^4.1.0", 19 | "@vue/cli-service": "^4.1.0", 20 | "babel-eslint": "^10.0.3", 21 | "eslint": "^5.16.0", 22 | "eslint-plugin-vue": "^5.0.0", 23 | "vue-cli-plugin-element": "~1.0.1", 24 | "vue-template-compiler": "^2.6.10" 25 | }, 26 | "eslintConfig": { 27 | "root": true, 28 | "env": { 29 | "node": true 30 | }, 31 | "extends": [ 32 | "plugin:vue/essential", 33 | "eslint:recommended" 34 | ], 35 | "rules": { 36 | "no-console": "off" 37 | }, 38 | "parserOptions": { 39 | "parser": "babel-eslint" 40 | } 41 | }, 42 | "browserslist": [ 43 | "> 1%", 44 | "last 2 versions" 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-mysql/src/frontend/public/favicon.ico -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 基于 Serverless Framework 的秒杀H5 14 | 15 | 16 | 17 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/serverless.yml: -------------------------------------------------------------------------------- 1 | app: fullstack-mysql-app 2 | 3 | component: website 4 | name: fullstack-frontend 5 | 6 | inputs: 7 | region: ${env:REGION} 8 | bucketName: fullstack-mysql-app-frontend 9 | protocol: https 10 | src: 11 | src: ./ 12 | hook: npm run build 13 | dist: ./dist 14 | envPath: ./ 15 | index: index.html 16 | error: index.html 17 | exclude: 18 | - 'public/env.js' 19 | env: 20 | # get api url after below api service deployed. 21 | apiUrl: ${output:${stage}:${app}:fullstack-api.apigw.url} 22 | -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/assets/fonts/serverless-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-mysql/src/frontend/src/assets/fonts/serverless-regular.woff -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/assets/fonts/serverless-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-mysql/src/frontend/src/assets/fonts/serverless-regular.woff2 -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/assets/fullstack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-mysql/src/frontend/src/assets/fullstack.png -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/assets/serverless-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-mysql/src/frontend/src/assets/serverless-logo.png -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/assets/tencent-cloud-hero.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-mysql/src/frontend/src/assets/tencent-cloud-hero.gif -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/assets/tencent-cloud-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-mysql/src/frontend/src/assets/tencent-cloud-logo.png -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/event-bus.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | 3 | const EventBus = new Vue(); 4 | 5 | export default EventBus; 6 | -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './App.vue'; 3 | import EventBus from './event-bus'; 4 | 5 | // import 'env'; 6 | import './style/app.css'; 7 | 8 | import './plugins/element.js'; 9 | 10 | Vue.config.productionTip = false; 11 | 12 | Vue.prototype.$EventBus = EventBus; 13 | 14 | new Vue({ 15 | render: (h) => h(App), 16 | }).$mount('#app'); 17 | -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/plugins/element.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Element from 'element-ui'; 3 | import '../theme/index.css'; 4 | 5 | Vue.use(Element); 6 | -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/theme/fonts/element-icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-mysql/src/frontend/src/theme/fonts/element-icons.ttf -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/src/theme/fonts/element-icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-mysql/src/frontend/src/theme/fonts/element-icons.woff -------------------------------------------------------------------------------- /fullstack-mysql/src/frontend/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | configureWebpack: { 3 | resolve: { 4 | alias: { 5 | ENV: require('path').resolve(__dirname, 'env.js'), 6 | }, 7 | }, 8 | externals: { 9 | env: 'env' 10 | }, 11 | plugins: [], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /fullstack-mysql/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tencent-fullstack", 3 | "version": "1.1.0", 4 | "description": "Fullstack with serverless db", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jest ./tests/integration.test.js --testEnvironment node", 8 | "bootstrap": "node scripts/bootstrap.js", 9 | "deploy": "sls deploy --all", 10 | "remove": "sls remove --all", 11 | "info": "npm run info:vpc && npm run info:db && npm run info:api && npm run info:frontend", 12 | "info:vpc": "sls info --target=./vpc", 13 | "info:db": "sls info --target=./db", 14 | "info:api": "sls info --target=./api", 15 | "info:frontend": "sls info --target=./frontend" 16 | }, 17 | "keywords": [ 18 | "fullstack", 19 | "serverless", 20 | "serverless-db" 21 | ], 22 | "author": "yugasun", 23 | "license": "MIT", 24 | "devDependencies": { 25 | "@serverless/platform-client-china": "^1.0.32", 26 | "dotenv": "^8.2.0", 27 | "jest": "^26.3.0", 28 | "js-yaml": "^3.14.0" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /fullstack-mysql/src/scripts/bootstrap.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const path = require('path') 4 | const util = require('util') 5 | const exec = util.promisify(require('child_process').exec) 6 | 7 | const rootDir = path.join(__dirname, '..') 8 | const apiDir = path.join(rootDir, 'api') 9 | const frontendDir = path.join(rootDir, 'frontend') 10 | 11 | async function installDependencies(dir) { 12 | await exec('npm install', { 13 | cwd: dir 14 | }) 15 | } 16 | 17 | /* eslint-disable no-console*/ 18 | async function bootstrap() { 19 | console.log('Start install dependencies...\n') 20 | console.log('Start install api dependencies...\n') 21 | await installDependencies(apiDir) 22 | console.log('Api dependencies installed success.') 23 | console.log('Start install frontend dependencies...\n') 24 | await installDependencies(frontendDir) 25 | console.log('Frontend dependencies installed success.') 26 | console.log('All dependencies installed.') 27 | } 28 | 29 | bootstrap() 30 | 31 | process.on('unhandledRejection', (e) => { 32 | throw e 33 | }) 34 | -------------------------------------------------------------------------------- /fullstack-mysql/src/serverless.yml: -------------------------------------------------------------------------------- 1 | app: fullstack-mysql-app -------------------------------------------------------------------------------- /fullstack-mysql/src/vpc/serverless.yml: -------------------------------------------------------------------------------- 1 | app: fullstack-mysql-app 2 | 3 | component: vpc 4 | name: fullstack-vpc 5 | 6 | 7 | inputs: 8 | region: ${env:REGION} 9 | zone: ${env:ZONE} 10 | vpcName: serverless 11 | subnetName: serverless 12 | -------------------------------------------------------------------------------- /fullstack-sequelize/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Yuga Sun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /fullstack-sequelize/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: fullstack-sequelize 2 | author: Tencent Cloud, Inc. 3 | org: Tencent Cloud, Inc. 4 | description: Deploy a full stack application. 5 | description-i18n: 6 | zh-cn: 快速部署一个 Full Stack 应用, vuejs + express + mysql 7 | keywords: tencent, serverless, express, website, fullstack 8 | repo: https://github.com/serverless-components/tencent-examples/tree/master/fullstack-sequelize 9 | readme: https://github.com/serverless-components/tencent-examples/tree/master/fullstack-sequelize/README.md 10 | license: MIT 11 | src: 12 | src: ./src 13 | exclude: 14 | - .env 15 | - '.git/**' 16 | - serverless.yml 17 | - '**/node_modules' 18 | - '**/package-lock.json' 19 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.sublime-project 3 | *.sublime-workspace 4 | *.log 5 | .serverless 6 | v8-compile-cache-* 7 | jest/* 8 | coverage 9 | testProjects/*/package-lock.json 10 | testProjects/*/yarn.lock 11 | .serverlessUnzipped 12 | node_modules 13 | .vscode/ 14 | .eslintcache 15 | dist 16 | .idea 17 | build/ 18 | .env 19 | .cache* 20 | .serverless 21 | .serverless_nextjs 22 | .serverless_plugins 23 | env.js 24 | tmp 25 | package-lock.json 26 | yarn.lock 27 | test 28 | .npmrc -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/.env.example: -------------------------------------------------------------------------------- 1 | # mysql 配置,依赖 docker-compose.yml 中的初始化配置 2 | DB_HOST=127.0.0.1 3 | DB_PORT=3306 4 | DB_USER=root 5 | DB_PASSWORD=root 6 | DB_NAME=fullstack -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/README.md: -------------------------------------------------------------------------------- 1 | # 后端服务 2 | 3 | 本地开发调试,数据库连接可以先通过 docker 来模拟 MySQL 服务。待业务代码开发调试成功后,再部署到云端 Serverless. 4 | 5 | ## 本地开发 6 | 7 | 安装依赖: 8 | 9 | ```bash 10 | $ npm install 11 | ``` 12 | 13 | 启动 Docker Mysql 容器: 14 | 15 | ```bash 16 | $ npm run docker:up 17 | ``` 18 | 19 | 将 `.env.example` 复制为 `.env`,并将 `DB_PASSWORD` 的值修改为 `docker-comopse.yml` 中配置的 `MYSQL_ROOT_PASSWORD` 的值。 20 | 21 | 本地启动 Express 服务: 22 | 23 | ```bash 24 | $ npm run dev 25 | ``` 26 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/app.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const cors = require('cors'); 3 | const routes = require('./routes'); 4 | 5 | const app = express(); 6 | 7 | app.set('port', process.env.PORT || 3000); 8 | app.use(express.json()); 9 | app.use(express.urlencoded({ extended: true })); 10 | app.use(cors()); 11 | 12 | routes(app); 13 | 14 | module.exports = { app }; 15 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/config/db.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | host: process.env.DB_HOST, 3 | port: +process.env.DB_PORT, 4 | username: process.env.DB_USER, 5 | password: process.env.DB_PASSWORD, 6 | database: process.env.DB_NAME, 7 | }; 8 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/controller/user.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const { User } = require('../models/user'); 4 | 5 | function ApiError(code, msg) { 6 | const e = new Error(msg); 7 | e.code = code; 8 | return e; 9 | } 10 | 11 | module.exports = { 12 | async getUserList() { 13 | const res = await User.findAll({}); 14 | return res; 15 | }, 16 | async createUser(user) { 17 | const { name } = user; 18 | const existUser = await this.getUserByName(name); 19 | if (existUser) { 20 | throw new ApiError(1000, `Name ${name} exist.`); 21 | } 22 | const res = await User.create(user); 23 | return res; 24 | }, 25 | 26 | async getUserByName(name) { 27 | try { 28 | const res = await User.findOne({ where: { name } }); 29 | if (res) { 30 | return res; 31 | } 32 | return false; 33 | } catch (e) { 34 | throw new ApiError(1001, e); 35 | } 36 | }, 37 | 38 | async deleteUserByName(name) { 39 | const res = await User.destroy({ where: { name } }); 40 | return res; 41 | }, 42 | 43 | async deleteUserId(id) { 44 | const res = await User.destroy({ where: { id } }); 45 | return res; 46 | }, 47 | }; 48 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/database/db.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS fullstack; 2 | 3 | USE fullstack; 4 | 5 | CREATE TABLE IF NOT EXISTS users( 6 | id INT UNSIGNED AUTO_INCREMENT COMMENT 'primary key', 7 | name VARCHAR(30) DEFAULT NULL, 8 | email VARCHAR(50) DEFAULT NULL, 9 | site VARCHAR(50) DEFAULT NULL, 10 | PRIMARY KEY (id) 11 | )ENGINE=InnoDB DEFAULT CHARSET=utf8; -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Use root/example as user/password credentials 2 | version: '3.1' 3 | 4 | services: 5 | db: 6 | image: mysql 7 | restart: always 8 | ports: 9 | - 3306:3306 10 | environment: 11 | MYSQL_USER: root 12 | MYSQL_ROOT_PASSWORD: root 13 | 14 | adminer: 15 | image: adminer 16 | restart: always 17 | ports: 18 | - 8080:8080 -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/models/user.js: -------------------------------------------------------------------------------- 1 | const { DataTypes } = require('sequelize'); 2 | const Model = require('sequelize/lib/model'); 3 | 4 | class User extends Model {} 5 | 6 | const initUser = (sequelize) => { 7 | User.init( 8 | { 9 | name: { 10 | type: DataTypes.STRING, 11 | allowNull: false, 12 | }, 13 | email: { 14 | type: DataTypes.STRING, 15 | allowNull: false, 16 | }, 17 | site: { 18 | type: DataTypes.STRING, 19 | allowNull: true, 20 | }, 21 | }, 22 | { 23 | sequelize, 24 | moduleName: 'users', 25 | }, 26 | ); 27 | }; 28 | 29 | module.exports = { 30 | User, 31 | initUser, 32 | }; 33 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@serverless-fullstack/api", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "dev": "NODE_ENV=development node server.js", 6 | "docker:up": "docker-compose up -d" 7 | }, 8 | "dependencies": { 9 | "cors": "^2.8.5", 10 | "dotenv": "^8.2.0", 11 | "express": "^4.17.1", 12 | "mysql2": "^2.2.5", 13 | "sequelize": "^6.3.5" 14 | }, 15 | "license": "MIT" 16 | } 17 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/server.js: -------------------------------------------------------------------------------- 1 | const dotenv = require('dotenv'); 2 | const path = require('path'); 3 | dotenv.config({ path: path.join(__dirname, '.env') }); 4 | 5 | const { app } = require('./app'); 6 | const { initDatabase } = require('./database'); 7 | 8 | /** 9 | * Start Express server. 10 | */ 11 | async function initServer() { 12 | await initDatabase(); 13 | 14 | const server = app.listen(app.get('port'), () => { 15 | console.log( 16 | ' App is running at http://localhost:%d in %s mode', 17 | app.get('port'), 18 | app.get('env'), 19 | ); 20 | console.log(' Press CTRL-C to stop\n'); 21 | }); 22 | 23 | return server; 24 | } 25 | 26 | initServer(); 27 | 28 | process.on('unhandledRejection', (e) => { 29 | throw e; 30 | }); 31 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/serverless.yml: -------------------------------------------------------------------------------- 1 | app: fullstack-sequelize-app 2 | 3 | component: express 4 | name: fullstack-api 5 | 6 | inputs: 7 | src: 8 | src: ./ 9 | exclude: 10 | - .env 11 | functionName: ${name} 12 | region: ${env:REGION} 13 | runtime: Nodejs12.16 14 | functionConf: 15 | timeout: 30 16 | vpcConfig: 17 | vpcId: ${output:${stage}:${app}:fullstack-vpc.vpcId} 18 | subnetId: ${output:${stage}:${app}:fullstack-vpc.subnetId} 19 | environment: 20 | variables: 21 | DB_HOST: ${output:${stage}:${app}:fullstack-db.connection.ip} 22 | DB_PORT: ${output:${stage}:${app}:fullstack-db.connection.port} 23 | DB_USER: root 24 | DB_NAME: fullstack 25 | DB_PASSWORD: ${output:${stage}:${app}:fullstack-db.adminPassword} 26 | apigatewayConf: 27 | enableCORS: true 28 | protocols: 29 | - http 30 | - https 31 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/backend/sls.js: -------------------------------------------------------------------------------- 1 | const { app } = require('./app'); 2 | const { initDatabase } = require('./database'); 3 | 4 | app.slsInitialize = async () => { 5 | try { 6 | await initDatabase(); 7 | } catch (e) { 8 | console.log(`[DB Error]: ${e}`); 9 | } 10 | }; 11 | 12 | app.binaryTypes = ['*/*']; 13 | 14 | module.exports = app; 15 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/db/serverless.yml: -------------------------------------------------------------------------------- 1 | app: fullstack-sequelize-app 2 | 3 | component: cynosdb 4 | name: fullstack-db 5 | 6 | inputs: 7 | region: ${env:REGION} 8 | zone: ${env:ZONE} 9 | vpcConfig: 10 | vpcId: ${output:${stage}:${app}:fullstack-vpc.vpcId} 11 | subnetId: ${output:${stage}:${app}:fullstack-vpc.subnetId} 12 | enablePublicAccess: true 13 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-sequelize/src/frontend/.gitkeep -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/README.md: -------------------------------------------------------------------------------- 1 | # frontend 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Lints and fixes files 19 | ``` 20 | npm run lint 21 | ``` 22 | 23 | ### Customize configuration 24 | See [Configuration Reference](https://cli.vuejs.org/config/). 25 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.19.0", 12 | "core-js": "^3.4.3", 13 | "element-ui": "^2.4.5", 14 | "vue": "^2.6.10" 15 | }, 16 | "devDependencies": { 17 | "@vue/cli-plugin-babel": "^4.1.0", 18 | "@vue/cli-plugin-eslint": "^4.1.0", 19 | "@vue/cli-service": "^4.1.0", 20 | "babel-eslint": "^10.0.3", 21 | "eslint": "^5.16.0", 22 | "eslint-plugin-vue": "^5.0.0", 23 | "vue-cli-plugin-element": "~1.0.1", 24 | "vue-template-compiler": "^2.6.10" 25 | }, 26 | "eslintConfig": { 27 | "root": true, 28 | "env": { 29 | "node": true 30 | }, 31 | "extends": [ 32 | "plugin:vue/essential", 33 | "eslint:recommended" 34 | ], 35 | "rules": { 36 | "no-console": "off" 37 | }, 38 | "parserOptions": { 39 | "parser": "babel-eslint" 40 | } 41 | }, 42 | "browserslist": [ 43 | "> 1%", 44 | "last 2 versions" 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-sequelize/src/frontend/public/favicon.ico -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 基于 Serverless Framework 的秒杀H5 14 | 15 | 16 | 17 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/serverless.yml: -------------------------------------------------------------------------------- 1 | app: fullstack-sequelize-app 2 | 3 | component: website 4 | name: fullstack-frontend 5 | 6 | inputs: 7 | region: ${env:REGION} 8 | bucketName: fullstack-mysql-app-frontend 9 | protocol: https 10 | src: 11 | src: ./ 12 | hook: npm run build 13 | dist: ./dist 14 | envPath: ./ 15 | index: index.html 16 | error: index.html 17 | exclude: 18 | - 'public/env.js' 19 | env: 20 | # get api url after below api service deployed. 21 | apiUrl: ${output:${stage}:${app}:fullstack-api.apigw.url} 22 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/src/assets/fullstack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-sequelize/src/frontend/src/assets/fullstack.png -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/src/assets/serverless-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-sequelize/src/frontend/src/assets/serverless-logo.png -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/src/assets/tencent-cloud-hero.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-sequelize/src/frontend/src/assets/tencent-cloud-hero.gif -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/src/assets/tencent-cloud-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-sequelize/src/frontend/src/assets/tencent-cloud-logo.png -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/src/event-bus.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | 3 | const EventBus = new Vue(); 4 | 5 | export default EventBus; 6 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './App.vue'; 3 | import EventBus from './event-bus'; 4 | 5 | // import 'env'; 6 | import './style/app.css'; 7 | 8 | import './plugins/element.js'; 9 | 10 | Vue.config.productionTip = false; 11 | 12 | Vue.prototype.$EventBus = EventBus; 13 | 14 | new Vue({ 15 | render: (h) => h(App), 16 | }).$mount('#app'); 17 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/src/plugins/element.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Element from 'element-ui'; 3 | import '../theme/index.css'; 4 | 5 | Vue.use(Element); 6 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/src/theme/fonts/element-icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-sequelize/src/frontend/src/theme/fonts/element-icons.ttf -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/src/theme/fonts/element-icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack-sequelize/src/frontend/src/theme/fonts/element-icons.woff -------------------------------------------------------------------------------- /fullstack-sequelize/src/frontend/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | configureWebpack: { 3 | resolve: { 4 | alias: { 5 | ENV: require('path').resolve(__dirname, 'env.js'), 6 | }, 7 | }, 8 | externals: { 9 | env: 'env' 10 | }, 11 | plugins: [], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /fullstack-sequelize/src/vpc/serverless.yml: -------------------------------------------------------------------------------- 1 | app: fullstack-sequelize-app 2 | 3 | component: vpc 4 | name: fullstack-vpc 5 | 6 | 7 | inputs: 8 | region: ${env:REGION} 9 | zone: ${env:ZONE} 10 | vpcName: serverless 11 | subnetName: serverless 12 | -------------------------------------------------------------------------------- /fullstack/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Yuga Sun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /fullstack/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 fullstack 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | fullstack 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 fullstack 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init fullstack --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 fullstack 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /fullstack/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: fullstack 2 | author: Tencent Cloud, Inc. 3 | org: Tencent Cloud, Inc. 4 | description: Deploy a full stack application. 5 | description-i18n: 6 | zh-cn: 快速部署一个 Full Stack 应用, vuejs + express + postgres 7 | keywords: tencent, serverless, express, website, fullstack 8 | repo: https://github.com/serverless-components/tencent-examples/tree/master/fullstack 9 | readme: https://github.com/serverless-components/tencent-examples/tree/master/fullstack/README.md 10 | license: MIT 11 | src: 12 | src: ./src 13 | exclude: 14 | - .env 15 | - '.git/**' 16 | - '**/node_modules' 17 | - '**/package-lock.json' 18 | -------------------------------------------------------------------------------- /fullstack/src/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.sublime-project 3 | *.sublime-workspace 4 | *.log 5 | .serverless 6 | v8-compile-cache-* 7 | jest/* 8 | coverage 9 | testProjects/*/package-lock.json 10 | testProjects/*/yarn.lock 11 | .serverlessUnzipped 12 | node_modules 13 | .vscode/ 14 | .eslintcache 15 | dist 16 | .idea 17 | build/ 18 | .env 19 | .cache* 20 | .serverless 21 | .serverless_nextjs 22 | .serverless_plugins 23 | env.js 24 | tmp 25 | package-lock.json 26 | yarn.lock 27 | test 28 | .npmrc -------------------------------------------------------------------------------- /fullstack/src/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 fullstack 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | fullstack 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 fullstack 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init fullstack --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 fullstack 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /fullstack/src/api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@serverless-fullstack/api", 3 | "version": "0.0.0", 4 | "dependencies": { 5 | "body-parser": "^1.19.0", 6 | "cors": "^2.8.5", 7 | "dotenv": "^8.2.0", 8 | "express": "^4.17.1", 9 | "pg": "^7.14.0" 10 | }, 11 | "license": "MIT" 12 | } 13 | -------------------------------------------------------------------------------- /fullstack/src/db/serverless.yml: -------------------------------------------------------------------------------- 1 | # 欢迎使用 ⚡️serverless⚡️ 组件 2 | # 3 | # serverless组件是基于具体使用场景(Express, 静态网站等)提供的定制云资源编排和组织的解决方案。 4 | # 这是serverless的主要配置文件,包含了一些使用示例以及注释说明。 5 | # 您只需几行配置描述,即可进行云函数、API 网关、COS、DB 等 6 | # Serverless 资源进行快速创建、部署和修改。 7 | # 8 | # 有关完整的配置选项,请检查文档: 9 | # https://cloud.tencent.com/document/product/1154/51080 10 | # 11 | # 👩‍💻 Happy Coding 👨‍💻 12 | 13 | # ##应用信息## 14 | # app,stage 会被根目录配置文件覆写 15 | app: fullstack-serverless-db # app名称(app唯一识别标识)。同账号下需唯一 16 | component: postgresql # [必选]要使用组件,更多组件请查看 https://github.com/serverless-components 17 | name: fullstack-db # [必选]组件实例名称 18 | # stage: dev # app环境名称,默认为dev 19 | 20 | # ##postgresql 组件配置## 21 | # 更多内容请查看: https://github.com/serverless-components/tencent-postgresql/blob/master/docs/configure.md 22 | inputs: 23 | region: ${env:REGION} # 部署目标地区。 更多参考 https://cloud.tencent.com/document/api/583/17238#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 24 | zone: ${env:ZONE} # 数据库所在地区的区域, 由环境变量配置。[ap-guangzhou-2,ap-shanghai-2,...] 25 | dBInstanceName: ${name} # 数据库实例名称。同账号下需唯一,使用此配置文件中的name(组件实例名称) 26 | vpcConfig: # 私有网络配置 27 | vpcId: ${output:${stage}:${app}:fullstack-vpc.vpcId} # 私有网络Id 28 | subnetId: ${output:${stage}:${app}:fullstack-vpc.subnetId} # 子网Id 29 | extranetAccess: false # 是否开启外网访问 30 | -------------------------------------------------------------------------------- /fullstack/src/frontend/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack/src/frontend/.gitkeep -------------------------------------------------------------------------------- /fullstack/src/frontend/README.md: -------------------------------------------------------------------------------- 1 | # frontend 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Lints and fixes files 19 | ``` 20 | npm run lint 21 | ``` 22 | 23 | ### Customize configuration 24 | See [Configuration Reference](https://cli.vuejs.org/config/). 25 | -------------------------------------------------------------------------------- /fullstack/src/frontend/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /fullstack/src/frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.19.0", 12 | "core-js": "^3.4.3", 13 | "vue": "^2.6.10" 14 | }, 15 | "devDependencies": { 16 | "@vue/cli-plugin-babel": "^4.1.0", 17 | "@vue/cli-plugin-eslint": "^4.1.0", 18 | "@vue/cli-service": "^4.1.0", 19 | "babel-eslint": "^10.0.3", 20 | "eslint": "^5.16.0", 21 | "eslint-plugin-vue": "^5.0.0", 22 | "vue-template-compiler": "^2.6.10" 23 | }, 24 | "eslintConfig": { 25 | "root": true, 26 | "env": { 27 | "node": true 28 | }, 29 | "extends": [ 30 | "plugin:vue/essential", 31 | "eslint:recommended" 32 | ], 33 | "rules": {}, 34 | "parserOptions": { 35 | "parser": "babel-eslint" 36 | } 37 | }, 38 | "browserslist": [ 39 | "> 1%", 40 | "last 2 versions" 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /fullstack/src/frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack/src/frontend/public/favicon.ico -------------------------------------------------------------------------------- /fullstack/src/frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 基于 Serverless Framework 的秒杀H5 14 | 15 | 16 | 17 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /fullstack/src/frontend/src/assets/fonts/serverless-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack/src/frontend/src/assets/fonts/serverless-regular.woff -------------------------------------------------------------------------------- /fullstack/src/frontend/src/assets/fonts/serverless-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack/src/frontend/src/assets/fonts/serverless-regular.woff2 -------------------------------------------------------------------------------- /fullstack/src/frontend/src/assets/fullstack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack/src/frontend/src/assets/fullstack.png -------------------------------------------------------------------------------- /fullstack/src/frontend/src/assets/tencent-cloud-hero.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/fullstack/src/frontend/src/assets/tencent-cloud-hero.gif -------------------------------------------------------------------------------- /fullstack/src/frontend/src/components/UserList.vue: -------------------------------------------------------------------------------- 1 | 23 | 45 | 54 | -------------------------------------------------------------------------------- /fullstack/src/frontend/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './App.vue'; 3 | // import 'env'; 4 | import './style/app.css'; 5 | 6 | Vue.config.productionTip = false; 7 | 8 | new Vue({ 9 | render: (h) => h(App), 10 | }).$mount('#app'); 11 | -------------------------------------------------------------------------------- /fullstack/src/frontend/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | configureWebpack: { 3 | resolve: { 4 | alias: { 5 | ENV: require('path').resolve(__dirname, 'env.js'), 6 | }, 7 | }, 8 | externals: { 9 | env: 'env' 10 | }, 11 | plugins: [], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /fullstack/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tencent-fullstack", 3 | "version": "1.1.0", 4 | "description": "Fullstack with serverless db", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jest ./tests/integration.test.js --testEnvironment node", 8 | "bootstrap": "node scripts/bootstrap.js", 9 | "deploy": "sls deploy --all", 10 | "remove": "sls remove --all", 11 | "info": "npm run info:vpc && npm run info:db && npm run info:api && npm run info:frontend", 12 | "info:vpc": "sls info --target=./vpc", 13 | "info:db": "sls info --target=./db", 14 | "info:api": "sls info --target=./api", 15 | "info:frontend": "sls info --target=./frontend" 16 | }, 17 | "keywords": [ 18 | "fullstack", 19 | "serverless", 20 | "serverless-db" 21 | ], 22 | "author": "yugasun", 23 | "license": "MIT", 24 | "devDependencies": { 25 | "@serverless/platform-client-china": "^1.0.32", 26 | "dotenv": "^8.2.0", 27 | "jest": "^26.3.0", 28 | "js-yaml": "^3.14.0" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /fullstack/src/scripts/bootstrap.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const path = require('path') 4 | const util = require('util') 5 | const exec = util.promisify(require('child_process').exec) 6 | 7 | const rootDir = path.join(__dirname, '..') 8 | const apiDir = path.join(rootDir, 'api') 9 | const frontendDir = path.join(rootDir, 'frontend') 10 | 11 | async function installDependencies(dir) { 12 | await exec('npm install', { 13 | cwd: dir 14 | }) 15 | } 16 | 17 | /* eslint-disable no-console*/ 18 | async function bootstrap() { 19 | console.log('Start install dependencies...\n') 20 | console.log('Start install api dependencies...\n') 21 | await installDependencies(apiDir) 22 | console.log('Api dependencies installed success.') 23 | console.log('Start install frontend dependencies...\n') 24 | await installDependencies(frontendDir) 25 | console.log('Frontend dependencies installed success.') 26 | console.log('All dependencies installed.') 27 | } 28 | 29 | bootstrap() 30 | 31 | process.on('unhandledRejection', (e) => { 32 | throw e 33 | }) 34 | -------------------------------------------------------------------------------- /fullstack/src/serverless.yml: -------------------------------------------------------------------------------- 1 | # 欢迎使用 ⚡️serverless⚡️ 组件 2 | # 3 | # serverless组件是基于具体使用场景(Express, 静态网站等)提供的定制云资源编排和组织的解决方案。 4 | # 这是serverless的主要配置文件,包含了一些使用示例以及注释说明。 5 | # 您只需几行配置描述,即可进行云函数、API 网关、COS、DB 等 6 | # Serverless 资源进行快速创建、部署和修改。 7 | # 8 | # 有关完整的配置选项,请检查文档: 9 | # https://cloud.tencent.com/document/product/1154/51080 10 | # 11 | # 👩‍💻 Happy Coding 👨‍💻 12 | 13 | # ##应用信息## 14 | # app(应用名称)和stage(环境版本)信息,会覆写子目录配置 15 | app: fullstack-serverless # app名称(app唯一识别标识)。同账号下需唯一 16 | # stage: dev # app环境名称,默认为dev 17 | -------------------------------------------------------------------------------- /fullstack/src/vpc/serverless.yml: -------------------------------------------------------------------------------- 1 | # 欢迎使用 ⚡️serverless⚡️ 组件 2 | # 3 | # serverless组件是基于具体使用场景(Express, 静态网站等)提供的定制云资源编排和组织的解决方案。 4 | # 这是serverless的主要配置文件,包含了一些使用示例以及注释说明。 5 | # 您只需几行配置描述,即可进行云函数、API 网关、COS、DB 等 6 | # Serverless 资源进行快速创建、部署和修改。 7 | # 8 | # 有关完整的配置选项,请检查文档: 9 | # https://cloud.tencent.com/document/product/1154/51080 10 | # 11 | # 👩‍💻 Happy Coding 👨‍💻 12 | 13 | # ##应用信息## 14 | # app,stage 会被根目录配置文件覆写 15 | app: fullstack-serverless-vpc # app名称(app唯一识别标识)。同账号下需唯一 16 | component: vpc # [必选]要使用组件,更多组件请查看 https://github.com/serverless-components 17 | name: fullstack-vpc # [必选]组件实例名称 18 | # stage: dev # app环境名称,默认为dev 19 | 20 | # ##Vpc 组件配置## 21 | # 更多内容请查看:https://github.com/serverless-components/tencent-vpc/blob/master/docs/configure.md 22 | inputs: 23 | region: ${env:REGION} # 部署目标地区。 更多参考 https://cloud.tencent.com/document/api/583/17238#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 24 | zone: ${env:ZONE} # 所在地区的区域 25 | vpcName: serverless # 实例名称 26 | subnetName: serverless # 子网的名称 27 | -------------------------------------------------------------------------------- /koa-starter/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 koa-starter 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | koa-starter 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 koa-starter 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init koa-starter --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 koa-starter 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /koa-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: koa-starter 2 | displayName: Koa.js 项目模版 3 | author: Tencent Cloud, Inc. 4 | org: Tencent Cloud, Inc. 5 | description: Deploy an Koa.js app via SCF and Apigateway 6 | description-i18n: 7 | zh-cn: 快速部署一个 Koa.js 基础应用 8 | type: template 9 | keywords: tencent, Koa, nodejs, SCF, APIGateway 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/koa-starter 11 | readme: https://github.com/serverless-components/tencent-examples/blob/master/koa-starter/README.md 12 | license: MIT 13 | src: 14 | src: ./src 15 | exclude: 16 | - '**/node_modules' 17 | -------------------------------------------------------------------------------- /koa-starter/src/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 koa-starter 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | koa-starter 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 koa-starter 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init koa-starter --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 koa-starter 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /koa-starter/src/app.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa') 2 | const KoaRouter = require('koa-router') 3 | const sendFile = require('koa-sendfile') 4 | const path = require('path') 5 | const multer = require('@koa/multer'); 6 | 7 | const app = new Koa() 8 | const router = new KoaRouter() 9 | 10 | // Serverless 场景只能读写 /tmp 目录,所以这里需要指定上传文件的目录为 /tmp/upload 11 | const upload = multer({ dest: '/tmp/upload' }); 12 | 13 | // Routes 14 | router.get(`/`, async (ctx) => { 15 | await sendFile(ctx, path.join(__dirname, 'index.html')) 16 | }) 17 | 18 | router.post('/upload', upload.single('file'), (ctx) => { 19 | ctx.body = { 20 | success: true, 21 | data: ctx.file, 22 | }; 23 | }); 24 | 25 | app.use(router.allowedMethods()).use(router.routes()) 26 | 27 | app.listen(9000, () => { 28 | console.log(`Server start on http://localhost:9000`); 29 | }) 30 | 31 | -------------------------------------------------------------------------------- /koa-starter/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Serverless - Koa.js 9 | 16 | 17 | 18 |

19 | 欢迎访问 Koa.js 应用 20 |
21 | 22 | 腾讯云 Serverless 23 | 24 | 为您提供服务 25 |

26 | 27 | 28 | -------------------------------------------------------------------------------- /koa-starter/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "koa-demo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "sls.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "yugasun", 10 | "license": "MIT", 11 | "dependencies": { 12 | "@koa/multer": "^3.0.0", 13 | "koa": "^2.11.0", 14 | "koa-router": "^8.0.8", 15 | "koa-sendfile": "^2.0.1", 16 | "multer": "^1.4.2" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /koa-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: http 2 | name: koaDemo 3 | 4 | inputs: 5 | src: 6 | src: ./ 7 | exclude: 8 | - .env 9 | faas: 10 | runtime: Nodejs12.16 11 | framework: koa 12 | name: ${name} 13 | apigw: 14 | ignoreUpdate: true 15 | protocols: 16 | - http 17 | - https 18 | -------------------------------------------------------------------------------- /laravel-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: laravel-starter 2 | displayName: Laravel 项目模版 3 | author: Tencent Cloud, Inc. 4 | org: Tencent Cloud, Inc. 5 | description: Deploy an Laravel app via SCF and Apigateway 6 | description-i18n: 7 | zh-cn: 快速部署一个 Laravel 基础应用 8 | type: template 9 | keywords: tencent, Laravel, php, SCF, APIGateway 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/laravel-starter 11 | readme: https://github.com/serverless-components/tencent-examples/blob/master/laravel-starter/README.md 12 | license: MIT 13 | src: 14 | src: ./src 15 | include: 16 | - .env 17 | - .env.example 18 | -------------------------------------------------------------------------------- /laravel-starter/src/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /laravel-starter/src/.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=laravel 13 | DB_USERNAME=root 14 | DB_PASSWORD= 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=file 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_MAILER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | MAIL_FROM_ADDRESS=null 33 | MAIL_FROM_NAME="${APP_NAME}" 34 | 35 | AWS_ACCESS_KEY_ID= 36 | AWS_SECRET_ACCESS_KEY= 37 | AWS_DEFAULT_REGION=us-east-1 38 | AWS_BUCKET= 39 | 40 | PUSHER_APP_ID= 41 | PUSHER_APP_KEY= 42 | PUSHER_APP_SECRET= 43 | PUSHER_APP_CLUSTER=mt1 44 | 45 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 46 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 47 | 48 | # tencent crendential 49 | TENCENT_SECRET_ID=xxx 50 | TENCENT_SECRET_KEY=xxx 51 | -------------------------------------------------------------------------------- /laravel-starter/src/.env.production: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY=base64:GF7ltREmZbBOpMFO/Xa0SP+x18EkRlPwBCb8ORejhPQ= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=laravel 13 | DB_USERNAME=root 14 | DB_PASSWORD= 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=cookie 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_DRIVER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | 33 | AWS_ACCESS_KEY_ID= 34 | AWS_SECRET_ACCESS_KEY= 35 | AWS_DEFAULT_REGION=us-east-1 36 | AWS_BUCKET= 37 | 38 | PUSHER_APP_ID= 39 | PUSHER_APP_KEY= 40 | PUSHER_APP_SECRET= 41 | PUSHER_APP_CLUSTER=mt1 42 | 43 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 44 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 45 | -------------------------------------------------------------------------------- /laravel-starter/src/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /laravel-starter/src/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | !.env.local 8 | !.env.production 9 | .env.backup 10 | .phpunit.result.cache 11 | Homestead.json 12 | Homestead.yaml 13 | npm-debug.log 14 | yarn-error.log 15 | -------------------------------------------------------------------------------- /laravel-starter/src/.styleci.yml: -------------------------------------------------------------------------------- 1 | php: 2 | preset: laravel 3 | disabled: 4 | - unused_use 5 | finder: 6 | not-name: 7 | - index.php 8 | - server.php 9 | js: 10 | finder: 11 | not-name: 12 | - webpack.mix.js 13 | css: true 14 | -------------------------------------------------------------------------------- /laravel-starter/src/app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 28 | } 29 | 30 | /** 31 | * Register the commands for the application. 32 | * 33 | * @return void 34 | */ 35 | protected function commands() 36 | { 37 | $this->load(__DIR__.'/Commands'); 38 | 39 | require base_path('routes/console.php'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /laravel-starter/src/app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /laravel-starter/src/app/Http/Middleware/CheckForMaintenanceMode.php: -------------------------------------------------------------------------------- 1 | check()) { 22 | return redirect(RouteServiceProvider::HOME); 23 | } 24 | 25 | return $next($request); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /laravel-starter/src/app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /laravel-starter/src/app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /laravel-starter/src/app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | parent::boot(); 31 | 32 | // 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /laravel-starter/src/app/User.php: -------------------------------------------------------------------------------- 1 | 'datetime', 38 | ]; 39 | } 40 | -------------------------------------------------------------------------------- /laravel-starter/src/bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /laravel-starter/src/config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /laravel-starter/src/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /laravel-starter/src/config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /laravel-starter/src/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | *.sqlite-journal 3 | -------------------------------------------------------------------------------- /laravel-starter/src/database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(User::class, function (Faker $faker) { 21 | return [ 22 | 'name' => $faker->name, 23 | 'email' => $faker->unique()->safeEmail, 24 | 'email_verified_at' => now(), 25 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 26 | 'remember_token' => Str::random(10), 27 | ]; 28 | }); 29 | -------------------------------------------------------------------------------- /laravel-starter/src/database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /laravel-starter/src/database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->text('connection'); 19 | $table->text('queue'); 20 | $table->longText('payload'); 21 | $table->longText('exception'); 22 | $table->timestamp('failed_at')->useCurrent(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('failed_jobs'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /laravel-starter/src/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UserSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /laravel-starter/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "npm run development -- --watch", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.19", 14 | "cross-env": "^7.0", 15 | "laravel-mix": "^5.0.1", 16 | "lodash": "^4.17.13", 17 | "resolve-url-loader": "^3.1.0", 18 | "sass": "^1.15.2", 19 | "sass-loader": "^8.0.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /laravel-starter/src/public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /laravel-starter/src/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/laravel-starter/src/public/favicon.ico -------------------------------------------------------------------------------- /laravel-starter/src/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /laravel-starter/src/public/web.config: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /laravel-starter/src/resources/js/app.js: -------------------------------------------------------------------------------- 1 | require('./bootstrap'); 2 | -------------------------------------------------------------------------------- /laravel-starter/src/resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | window._ = require('lodash'); 2 | 3 | /** 4 | * We'll load the axios HTTP library which allows us to easily issue requests 5 | * to our Laravel back-end. This library automatically handles sending the 6 | * CSRF token as a header based on the value of the "XSRF" token cookie. 7 | */ 8 | 9 | window.axios = require('axios'); 10 | 11 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 12 | 13 | /** 14 | * Echo exposes an expressive API for subscribing to channels and listening 15 | * for events that are broadcast by Laravel. Echo and event broadcasting 16 | * allows your team to easily build robust real-time web applications. 17 | */ 18 | 19 | // import Echo from 'laravel-echo'; 20 | 21 | // window.Pusher = require('pusher-js'); 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: process.env.MIX_PUSHER_APP_KEY, 26 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 27 | // forceTLS: true 28 | // }); 29 | -------------------------------------------------------------------------------- /laravel-starter/src/resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /laravel-starter/src/resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /laravel-starter/src/resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have emailed your password reset link!', 18 | 'throttled' => 'Please wait before retrying.', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that email address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /laravel-starter/src/resources/sass/app.scss: -------------------------------------------------------------------------------- 1 | // 2 | -------------------------------------------------------------------------------- /laravel-starter/src/resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Serverless - Laravel 9 | 16 | 17 | 18 |

19 | 欢迎访问 Laravel 应用 20 |
21 | 22 | 腾讯云 Serverless 23 | 24 | 为您提供服务 25 |

26 | 27 | 28 | -------------------------------------------------------------------------------- /laravel-starter/src/routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 18 | return $request->user(); 19 | }); 20 | -------------------------------------------------------------------------------- /laravel-starter/src/routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /laravel-starter/src/routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->describe('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /laravel-starter/src/routes/web.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /laravel-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: http 2 | name: laravelDemo 3 | 4 | inputs: 5 | src: 6 | src: ./ 7 | exclude: 8 | - .env 9 | region: ap-guangzhou 10 | faas: 11 | name: ${name} 12 | framework: laravel 13 | runtime: Php7 14 | environments: 15 | - key: APP_ENV 16 | value: production 17 | apigw: 18 | protocols: 19 | - http 20 | - https 21 | -------------------------------------------------------------------------------- /laravel-starter/src/storage/framework/views/e8b4bb9e9045b5e4d42d503b4ce315a579ab90fc.php: -------------------------------------------------------------------------------- 1 | startSection('title', __('Server Error')); ?> 2 | startSection('code', '500'); ?> 3 | startSection('message', __('Server Error')); ?> 4 | 5 | make('errors::minimal', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?> -------------------------------------------------------------------------------- /laravel-starter/src/webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js') 15 | .sass('resources/sass/app.scss', 'public/css'); 16 | -------------------------------------------------------------------------------- /multi-scf-db-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: multi-scf-db-starter # 项目模板的名字 2 | displayName: 多事件函数&数据库 # 项目模板展示在控制台的名称(中文) 3 | author: Tencent Cloud, Inc. # 作者的名字 4 | org: Tencent Cloud, Inc. # 组织名称,可选 5 | description: Deploy multiple event function with serverless database # 英文描述 6 | description-i18n: 7 | zh-cn: 快速部署多个事件类型的 nodejs 云函数 # 中文描述述 8 | type: template #类型:模版 9 | keywords: tencent, scf, Nodejs12.16, event, multiple, database # 关键字 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/multi-scf-with-db # 源代码 11 | readme: https://github.com/serverless-components/tencent-examples/tree/master/multi-scf-with-db/README.md # 详细的说明文件 12 | license: MIT # 版权声明 13 | src: # 描述项目中的哪些文件需要作为模板发布 14 | src: ./src # 指定具体的相对目录,此目录下的文件将作为模板发布 15 | #描述在指定的目录内哪些文件应该被排除 16 | # exclude: 17 | # 通常你希望排除 18 | # 1. 包含secrets的文件 19 | # 2. .git git源代码管理的相关文件 20 | # 3. node_modules等第三方依赖文件 21 | -------------------------------------------------------------------------------- /multi-scf-db-starter/src/db/serverless.yml: -------------------------------------------------------------------------------- 1 | component: postgresql 2 | name: sls-db 3 | 4 | inputs: 5 | region: ap-guangzhou 6 | zone: ap-guangzhou-2 7 | dBInstanceName: ${name}-${stage} 8 | extranetAccess: true 9 | vpcConfig: 10 | vpcId: ${output:${stage}:${app}:sls-vpc.vpcId} 11 | subnetId: ${output:${stage}:${app}:sls-vpc.subnetId} 12 | -------------------------------------------------------------------------------- /multi-scf-db-starter/src/server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "multi-scf-db-starter", 3 | "version": "1.0.0", 4 | "description": "Multiple SCF with Serverless DB", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/serverless-components/tencent-examples.git" 12 | }, 13 | "author": "", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/serverless-components/tencent-examples/issues" 17 | }, 18 | "homepage": "https://github.com/serverless-components/tencent-examples/tree/master/multi-scf-db-starter", 19 | "dependencies": { 20 | "pg": "^8.6.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /multi-scf-db-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | app: multi-scf-db-starter -------------------------------------------------------------------------------- /multi-scf-db-starter/src/vpc/serverless.yml: -------------------------------------------------------------------------------- 1 | component: vpc 2 | name: sls-vpc 3 | 4 | inputs: 5 | region: ap-guangzhou 6 | zone: ap-guangzhou-2 7 | vpcName: ${name} # 实例名称 8 | subnetName: ${name}-subnet # 子网的名称 9 | -------------------------------------------------------------------------------- /multi-scf-nodejs/serverless.template.yml: -------------------------------------------------------------------------------- 1 | 2 | name: multi-scf-nodejs # 项目模板的名字 3 | displayName: 多事件函数 # 项目模板展示在控制台的名称(中文) 4 | author: Tencent Cloud, Inc. # 作者的名字 5 | org: Tencent Cloud, Inc. # 组织名称,可选 6 | description: Deploy multiple event function # 英文描述 7 | description-i18n: 8 | zh-cn: 快速部署多个事件类型的 nodejs 云函数 # 中文描述述 9 | type: template #类型:模版 10 | keywords: tencent, scf, Nodejs12.16, event, multiple # 关键字 11 | repo: https://github.com/serverless-components/tencent-examples/tree/master/multi-scf-nodejs # 源代码 12 | readme: https://github.com/serverless-components/tencent-examples/tree/master/multi-scf-nodejs/README.md # 详细的说明文件 13 | license: MIT # 版权声明 14 | src: # 描述项目中的哪些文件需要作为模板发布 15 | src: ./src # 指定具体的相对目录,此目录下的文件将作为模板发布 16 | exclude: #描述在指定的目录内哪些文件应该被排除 17 | # 通常你希望排除 18 | # 1. 包含secrets的文件 19 | # 2. .git git源代码管理的相关文件 20 | # 3. node_modules等第三方依赖文件 -------------------------------------------------------------------------------- /multi-scf-nodejs/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | exports.index = async (event, context) => { 3 | return { 4 | message: 'Tencent SCF execute successful!', 5 | input: event, 6 | }; 7 | }; 8 | 9 | exports.hello = async (event, context) => { 10 | const name = event.pathParameters.name 11 | return { 12 | message: `Hello from ${name || 'Anonymous'}`, 13 | body: event.body || null, 14 | queries: event.queryString || null, 15 | }; 16 | }; -------------------------------------------------------------------------------- /multi-scf-python/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: multi-scf-python # 项目模板的名字 2 | displayName: 多事件函数 # 项目模板展示在控制台的名称(中文) 3 | author: Tencent Cloud, Inc. # 作者的名字 4 | org: Tencent Cloud, Inc. # 组织名称,可选 5 | description: Deploy multiple event function # 英文描述 6 | description-i18n: 7 | zh-cn: 快速部署多个事件类型的 Python 云函数 # 中文描述述 8 | type: template #类型:模版 9 | keywords: tencent, scf, python3.6, event, multiple # 关键字 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/multi-scf-python # 源代码 11 | readme: https://github.com/serverless-components/tencent-examples/tree/master/multi-scf-python/README.md # 详细的说明文件 12 | license: MIT # 版权声明 13 | src: # 描述项目中的哪些文件需要作为模板发布 14 | src: ./src # 指定具体的相对目录,此目录下的文件将作为模板发布 15 | exclude: # 描述在指定的目录内哪些文件应该被排除 16 | # 通常你希望排除 17 | # 1. 包含secrets的文件 18 | # 2. .git git源代码管理的相关文件 19 | # 3. node_modules等第三方依赖文件 20 | -------------------------------------------------------------------------------- /multi-scf-python/src/index.py: -------------------------------------------------------------------------------- 1 | 2 | def index(event, context): 3 | return { 4 | "message": 'Tencent SCF execute successful!', 5 | "input": event, 6 | } 7 | 8 | def hello(event, context): 9 | name = event.get('pathParameters').get('name') 10 | body = event.get('body') 11 | queryString = event.get('queryString') 12 | 13 | return { 14 | "message": "Hello from " + name or 'Anonymous', 15 | "body": body or {}, 16 | "queries": queryString or {}, 17 | } -------------------------------------------------------------------------------- /multi-scf-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | 2 | name: multi-scf-starter # 项目模板的名字 3 | displayName: 多事件函数 # 项目模板展示在控制台的名称(中文) 4 | author: Tencent Cloud, Inc. # 作者的名字 5 | org: Tencent Cloud, Inc. # 组织名称,可选 6 | description: Deploy multiple event function # 英文描述 7 | description-i18n: 8 | zh-cn: 快速部署多个云函数 # 中文描述述 9 | type: template #类型:模版 10 | keywords: tencent, scf, Nodejs12.16, event, multiple # 关键字 11 | repo: https://github.com/serverless-components/tencent-examples/tree/master/multi-scf-starter # 源代码 12 | readme: https://github.com/serverless-components/tencent-examples/tree/master/multi-scf-starter/README.md # 详细的说明文件 13 | license: MIT # 版权声明 14 | src: # 描述项目中的哪些文件需要作为模板发布 15 | src: ./src # 指定具体的相对目录,此目录下的文件将作为模板发布 16 | exclude: #描述在指定的目录内哪些文件应该被排除 17 | # 通常你希望排除 18 | # 1. 包含secrets的文件 19 | # 2. .git git源代码管理的相关文件 20 | # 3. node_modules等第三方依赖文件 -------------------------------------------------------------------------------- /multi-scf-starter/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | exports.index = async (event, context) => { 3 | return { 4 | message: 'Tencent SCF execute successful!', 5 | input: event, 6 | }; 7 | }; 8 | 9 | exports.hello = async (event, context) => { 10 | const name = event.pathParameters.name 11 | return { 12 | message: `Hello from ${name || 'Anonymous'}`, 13 | body: event.body || null, 14 | queries: event.queryString || null, 15 | }; 16 | }; -------------------------------------------------------------------------------- /nextjs-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: nextjs-starter 2 | displayName: nextjs 函数项目模版 3 | author: Tencent Cloud, Inc. 4 | org: Tencent Cloud, Inc. 5 | description: Deploy an nextjs app. 6 | description-i18n: 7 | zh-cn: 快速部署一个 nextjs 应用 8 | type: template 9 | keywords: tencent, nextjs, nodejs 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/nextjs-starter 11 | readme: https://github.com/serverless-components/tencent-examples/blob/master/nextjs-starter/README.md 12 | license: MIT 13 | src: 14 | src: ./src 15 | exclude: 16 | - '**/node_modules' 17 | - '**/package-lock.json' 18 | - '**/.next' -------------------------------------------------------------------------------- /nextjs-starter/src/.env.example: -------------------------------------------------------------------------------- 1 | TENCENT_SECRET_ID=123 2 | TENCENT_SECRET_KEY=123 3 | 4 | STATIC_URL=https://nextjs-demo-123456789.cos.ap-guangzhou.myqcloud.com 5 | -------------------------------------------------------------------------------- /nextjs-starter/src/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | .env 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | .serverless 28 | .next 29 | -------------------------------------------------------------------------------- /nextjs-starter/src/next.config.js: -------------------------------------------------------------------------------- 1 | const isProd = process.env.NODE_ENV === 'production' 2 | 3 | module.exports = { 4 | env: { 5 | STATIC_URL: isProd ? process.env.STATIC_URL : '' 6 | }, 7 | assetPrefix: isProd ? process.env.STATIC_URL : '', 8 | reactStrictMode: true, 9 | eslint: { 10 | ignoreDuringBuilds: true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /nextjs-starter/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start" 9 | }, 10 | "dependencies": { 11 | "next": "11.0.1", 12 | "react": "17.0.2", 13 | "react-dom": "17.0.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /nextjs-starter/src/pages/_app.js: -------------------------------------------------------------------------------- 1 | import '../styles/global.css' 2 | 3 | function MyApp({ Component, pageProps }) { 4 | return 5 | } 6 | 7 | export default MyApp 8 | -------------------------------------------------------------------------------- /nextjs-starter/src/pages/api/hello.js: -------------------------------------------------------------------------------- 1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction 2 | 3 | export default function handler(req, res) { 4 | res.status(200).json({ name: 'John Doe' }) 5 | } 6 | -------------------------------------------------------------------------------- /nextjs-starter/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import Head from 'next/head' 2 | import styles from '../styles/index.module.css' 3 | 4 | export default function Index() { 5 | return ( 6 |
7 | 8 | Serverless - Next.js 9 | 10 | 11 | 12 | 13 | 14 |
15 |

欢迎访问 Next.js 应用

16 | 17 |

18 | 19 | 腾讯云 Serverless 20 | 21 | 为您提供服务 22 |

23 |
24 |
25 | ) 26 | } 27 | -------------------------------------------------------------------------------- /nextjs-starter/src/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/nextjs-starter/src/public/favicon.ico -------------------------------------------------------------------------------- /nextjs-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: http 2 | name: nextDemo 3 | 4 | inputs: 5 | src: 6 | dist: ./ 7 | hook: npm run build 8 | exclude: 9 | - .env 10 | faas: 11 | runtime: Nodejs12.16 12 | framework: nextjs 13 | name: ${name} 14 | apigw: 15 | protocols: 16 | - http 17 | - https 18 | -------------------------------------------------------------------------------- /nextjs-starter/src/styles/global.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | padding: 0; 4 | margin: 0; 5 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 6 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 7 | } 8 | 9 | a { 10 | color: inherit; 11 | text-decoration: none; 12 | } 13 | 14 | * { 15 | box-sizing: border-box; 16 | } 17 | -------------------------------------------------------------------------------- /nuxtjs-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: nuxtjs-starter 2 | displayName: Nuxt.js 项目模版 3 | author: Tencent Cloud, Inc. 4 | org: Tencent Cloud, Inc. 5 | description: Deploy an Nuxt.js app via SCF and Apigateway 6 | description-i18n: 7 | zh-cn: 快速部署一个 Nuxt.js 基础应用 8 | type: template 9 | keywords: tencent, Nuxtjs, nodejs, SCF, APIGateway 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/nuxtjs-starter 11 | readme: https://github.com/serverless-components/tencent-examples/blob/master/nuxtjs-starter/README.md 12 | license: MIT 13 | src: 14 | src: ./src 15 | exclude: 16 | - '**/node_modules' 17 | - '**/package-lock.json' 18 | - '**/.nuxt' -------------------------------------------------------------------------------- /nuxtjs-starter/src/.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/.env.example: -------------------------------------------------------------------------------- 1 | TENCENT_SECRET_ID=123 2 | TENCENT_SECRET_KEY=123 3 | 4 | # please change to your real appid 5 | STATIC_URL=https://nuxtjs-demo-.cos.ap-guangzhou.myqcloud.com 6 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/assets/README.md: -------------------------------------------------------------------------------- 1 | # ASSETS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your un-compiled assets such as LESS, SASS, or JavaScript. 6 | 7 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#webpacked). 8 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/components/Logo.vue: -------------------------------------------------------------------------------- 1 | 20 | 35 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/components/README.md: -------------------------------------------------------------------------------- 1 | # COMPONENTS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | The components directory contains your Vue.js Components. 6 | 7 | _Nuxt.js doesn't supercharge these components._ 8 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/layouts/README.md: -------------------------------------------------------------------------------- 1 | # LAYOUTS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your Application Layouts. 6 | 7 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/views#layouts). 8 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/middleware/README.md: -------------------------------------------------------------------------------- 1 | # MIDDLEWARE 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your application middleware. 6 | Middleware let you define custom functions that can be run before rendering either a page or a group of pages. 7 | 8 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing#middleware). 9 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/nuxt.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | env: { 3 | STATIC_URL: process.env.STATIC_URL || '' 4 | }, 5 | /* 6 | ** Build configuration 7 | */ 8 | build: { 9 | extend(config, { isDev, isClient }) { 10 | if (!isDev && process.env.STATIC_URL) { 11 | config.output.publicPath = process.env.STATIC_URL 12 | } 13 | } 14 | }, 15 | /* 16 | ** Headers of the page 17 | */ 18 | head: { 19 | title: 'Serverless Nuxt.js Application', 20 | meta: [ 21 | { charset: 'utf-8' }, 22 | { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 23 | { 24 | hid: 'description', 25 | name: 'description', 26 | content: 'Serverless Nuxt.js Application Created By Serverless Framework' 27 | } 28 | ], 29 | link: [ 30 | { rel: 'icon', type: 'image/x-icon', href: `${process.env.STATIC_URL || ''}/favicon.ico` } 31 | ] 32 | }, 33 | /* 34 | ** Customize the progress-bar color 35 | */ 36 | loading: { color: '#fff' }, 37 | /* 38 | ** Global CSS 39 | */ 40 | css: [], 41 | /* 42 | ** Plugins to load before mounting the App 43 | */ 44 | plugins: [], 45 | /* 46 | ** Nuxt.js dev-modules 47 | */ 48 | buildModules: [], 49 | /* 50 | ** Nuxt.js modules 51 | */ 52 | modules: [] 53 | } 54 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nuxt-demo", 3 | "version": "1.0.0", 4 | "description": "Serverless Nuxt.js Application Created By Serverless Framework", 5 | "author": "Tencent Cloud, Inc.", 6 | "private": true, 7 | "scripts": { 8 | "dev": "nuxt", 9 | "build": "nuxt build", 10 | "start": "nuxt start", 11 | "generate": "nuxt generate" 12 | }, 13 | "dependencies": { 14 | "nuxt": "^2.14.3" 15 | }, 16 | "devDependencies": {} 17 | } 18 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/pages/README.md: -------------------------------------------------------------------------------- 1 | # PAGES 2 | 3 | This directory contains your Application Views and Routes. 4 | The framework reads all the `*.vue` files inside this directory and creates the router of your application. 5 | 6 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing). 7 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/pages/index.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 25 | 26 | 58 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/plugins/README.md: -------------------------------------------------------------------------------- 1 | # PLUGINS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains Javascript plugins that you want to run before mounting the root Vue.js application. 6 | 7 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/plugins). 8 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: http 2 | name: nuxtDemo 3 | 4 | inputs: 5 | src: 6 | dist: ./ 7 | hook: npm run build 8 | exclude: 9 | - .env 10 | faas: 11 | runtime: Nodejs12.16 12 | framework: nuxtjs 13 | name: ${name} 14 | apigw: 15 | protocols: 16 | - http 17 | - https 18 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/static/README.md: -------------------------------------------------------------------------------- 1 | # STATIC 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your static files. 6 | Each file inside this directory is mapped to `/`. 7 | Thus you'd want to delete this README.md before deploying to production. 8 | 9 | Example: `/static/robots.txt` is mapped as `/robots.txt`. 10 | 11 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#static). 12 | -------------------------------------------------------------------------------- /nuxtjs-starter/src/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/nuxtjs-starter/src/static/favicon.ico -------------------------------------------------------------------------------- /nuxtjs-starter/src/store/README.md: -------------------------------------------------------------------------------- 1 | # STORE 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your Vuex Store files. 6 | Vuex Store option is implemented in the Nuxt.js framework. 7 | 8 | Creating a file in this directory automatically activates the option in the framework. 9 | 10 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store). 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tencent-examples", 3 | "version": "1.0.0", 4 | "description": "A collection of ready-to-deploy Serverless Framework project examples.", 5 | "main": "index.js", 6 | "scripts": { 7 | "generateREADMEs": "node scripts/generateREADMEs.js", 8 | "publishAllTemplates": "node scripts/publishAllTemplates.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/serverless-components/tencent-examples.git" 13 | }, 14 | "keywords": [], 15 | "author": "", 16 | "license": "ISC", 17 | "bugs": { 18 | "url": "https://github.com/serverless-components/tencent-examples/issues" 19 | }, 20 | "homepage": "https://github.com/serverless-components/tencent-examples#readme" 21 | } 22 | -------------------------------------------------------------------------------- /react-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: react-starter 2 | version: 0.0.4 3 | type: template 4 | org: Tencent Cloud, Inc. 5 | author: "Tencent Cloud, Inc." 6 | description: Deploys a serverless React website on Tencent Cloud 7 | description-i18n: 8 | zh-cn: 快速部署一个 React.js 应用 9 | keywords: tencent cloud, serverless, website, frontend, react 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/react-starter 11 | readme: https://github.com/serverless-components/tencent-examples/tree/master/react-starter/README.md 12 | license: MIT 13 | 14 | src: 15 | src: ./src 16 | exclude: 17 | - .env 18 | - '.git/**' 19 | - '**/node_modules' 20 | - '**/package-lock.json' 21 | - dist 22 | - .cache 23 | -------------------------------------------------------------------------------- /react-starter/src/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | -------------------------------------------------------------------------------- /react-starter/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import imageHero from './images/hero.png' 3 | 4 | export default class App extends Component { 5 | constructor(props) { 6 | super(props) 7 | } 8 | /** 9 | * Render 10 | */ 11 | 12 | render() { 13 | return ( 14 |
15 |
16 | 17 |
18 | 19 |
20 | a website built on serverless components and React via the serverless 21 | framework 22 |
23 |
24 | ) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /react-starter/src/fonts/serverless-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/react-starter/src/fonts/serverless-regular.woff -------------------------------------------------------------------------------- /react-starter/src/fonts/serverless-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/react-starter/src/fonts/serverless-regular.woff2 -------------------------------------------------------------------------------- /react-starter/src/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/react-starter/src/images/favicon.ico -------------------------------------------------------------------------------- /react-starter/src/images/hero.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/react-starter/src/images/hero.png -------------------------------------------------------------------------------- /react-starter/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Serverless Website and React 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /react-starter/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render(, document.getElementById('root')); 6 | -------------------------------------------------------------------------------- /react-starter/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-starter-website", 3 | "version": "0.0.2", 4 | "description": "", 5 | "scripts": { 6 | "start": "parcel index.html", 7 | "build": "parcel build index.html" 8 | }, 9 | "license": "MIT", 10 | "dependencies": { 11 | "react": "^16.5.2", 12 | "react-dom": "^16.5.2" 13 | }, 14 | "devDependencies": { 15 | "parcel-bundler": "1.12.3" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /react-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | # 欢迎使用 ⚡️serverless⚡️ 组件 2 | # 3 | # serverless组件是基于具体使用场景(Express, 静态网站等)提供的定制云资源编排和组织的解决方案。 4 | # 这是serverless的主要配置文件,包含了一些使用示例以及注释说明。 5 | # 您只需几行配置描述,即可进行云函数、API 网关、COS、DB 等 6 | # Serverless 资源进行快速创建、部署和修改。 7 | # 8 | # 有关完整的配置选项,请检查文档: 9 | # https://cloud.tencent.com/document/product/1154/51080 10 | # 11 | # 👩‍💻 Happy Coding 👨‍💻 12 | 13 | # ##应用信息## 14 | app: react-starter # app名称(app唯一识别标识)。同账号下需唯一,留空则继承组件实例名称 15 | component: website # [必选]要使用组件,更多组件请查看 https://github.com/serverless-components 16 | name: react-starter # [必选]组件实例名称 17 | 18 | # #website 组件配置## 19 | # 更多内容请查看:https://github.com/serverless-components/tencent-website/blob/master/docs/configure.md 20 | inputs: 21 | src: #该项目的代码信息,参数参考执行目录 22 | hook: npm run build # 构建命令。在代码上传之前执行 23 | dist: ./dist # 输出的目录。如果配置 hook,此参数必填 24 | bucketName: my-react-starter # Bucket 名称(不允许大写字母)。默认添加 AppId 作为后缀 25 | protocol: https 26 | -------------------------------------------------------------------------------- /restful-api/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 restful-api 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | restful-api 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 restful-api 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init restful-api --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 restful-api 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /restful-api/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: restful-api 2 | version: 0.0.4 3 | type: template 4 | org: Tencent Cloud, Inc. 5 | author: Tencent Cloud, Inc. 6 | description: Build a serverless REST API application with tencent serverless SCF component, support GET/PUT methods. 7 | description-i18n: 8 | zh-cn: 快速部署一个 REST API 使用 python + API gateway 9 | keywords: tencent, serverless, rest api, scf 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/restful-api 11 | readme: https://github.com/serverless-components/tencent-examples/tree/master/restful-api/README.md 12 | license: MIT 13 | 14 | src: 15 | src: ./src 16 | exclude: 17 | - .env 18 | - '.git/**' 19 | - serverless.template.yml 20 | -------------------------------------------------------------------------------- /restful-api/src/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 restful-api 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | restful-api 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 restful-api 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init restful-api --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 restful-api 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /restful-api/src/index.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | 4 | def teacher_go(): 5 | # todo: teacher_go action 6 | return { 7 | "result": "it is student_get action" 8 | } 9 | 10 | 11 | def student_go(): 12 | # todo: student_go action 13 | return { 14 | "result": "it is teacher_put action" 15 | } 16 | 17 | 18 | def student_come(): 19 | # todo: student_come action 20 | return { 21 | "result": "it is teacher_put action" 22 | } 23 | 24 | 25 | def main_handler(event, context): 26 | print(str(event)) 27 | if event["pathParameters"]["user_type"] == "teacher": 28 | if event["pathParameters"]["action"] == "go": 29 | return teacher_go() 30 | if event["pathParameters"]["user_type"] == "student": 31 | if event["pathParameters"]["action"] == "go": 32 | return student_go() 33 | if event["pathParameters"]["action"] == "come": 34 | return student_come() 35 | -------------------------------------------------------------------------------- /restful-api/src/serverless.yml: -------------------------------------------------------------------------------- 1 | app: restful-api 2 | component: scf 3 | name: restful-api 4 | 5 | inputs: 6 | name: ${name} 7 | src: ./ 8 | handler: index.main_handler 9 | runtime: Python3.6 10 | region: ap-guangzhou 11 | description: My Serverless Function 12 | memorySize: 128 13 | timeout: 20 14 | events: 15 | - apigw: 16 | name: serverless 17 | parameters: 18 | protocols: 19 | - http 20 | serviceName: serverless 21 | description: the serverless service 22 | environment: release 23 | endpoints: 24 | - path: /users/{user_type}/{action} 25 | method: GET 26 | description: Serverless REST API 27 | enableCORS: TRUE 28 | serviceTimeout: 10 29 | param: 30 | - name: user_type 31 | position: PATH 32 | required: TRUE 33 | type: string 34 | defaultValue: teacher 35 | desc: mytest 36 | - name: action 37 | position: PATH 38 | required: TRUE 39 | type: string 40 | defaultValue: go 41 | desc: mytest 42 | -------------------------------------------------------------------------------- /scf-golang/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 scf-golang 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | scf-golang 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 scf-golang 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init scf-golang --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 scf-golang 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /scf-golang/serverless.template.yml: -------------------------------------------------------------------------------- 1 | 2 | name: scf-golang # 项目模板的名字 3 | displayName: helloworld # 项目模板展示在控制台的名称(中文) 4 | author: Tencent Cloud, Inc. # 作者的名字 5 | org: Tencent Cloud, Inc. # 组织名称,可选 6 | description: This is helloworld function # 英文描述 7 | description-i18n: 8 | zh-cn: 快速部署一个 golang 云函数 # 中文描述 9 | type: template #类型:模版 10 | keywords: tencent, scf, Go1, helloworld # 关键字 11 | repo: https://github.com/serverless-components/tencent-examples/tree/master/scf-golang # 源代码 12 | readme: https://github.com/serverless-components/tencent-examples/tree/master/scf-golang/README.md # 详细的说明文件 13 | license: MIT # 版权声明 14 | src: # 描述项目中的哪些文件需要作为模板发布 15 | src: ./src # 指定具体的相对目录,此目录下的文件将作为模板发布 16 | exclude: #描述在指定的目录内哪些文件应该被排除 17 | # 通常你希望排除 18 | # 1. 包含secrets的文件 19 | # 2. .git git源代码管理的相关文件 20 | # 3. node_modules等第三方依赖文件 -------------------------------------------------------------------------------- /scf-golang/src/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 scf-golang 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | scf-golang 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 scf-golang 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init scf-golang --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 scf-golang 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /scf-golang/src/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/scf-golang/src/main -------------------------------------------------------------------------------- /scf-golang/src/serverless.yaml: -------------------------------------------------------------------------------- 1 | app: scf-golang 2 | component: scf 3 | name: scf-golang 4 | 5 | inputs: 6 | src: ./ 7 | handler: main 8 | runtime: Go1 9 | namespace: default 10 | region: ap-guangzhou 11 | memorySize: 128 12 | timeout: 3 13 | -------------------------------------------------------------------------------- /scf-nodejs/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 scf-nodejs 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | scf-nodejs 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 scf-nodejs 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init scf-nodejs --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 scf-nodejs 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /scf-nodejs/serverless.template.yml: -------------------------------------------------------------------------------- 1 | 2 | name: scf-nodejs # 项目模板的名字 3 | displayName: helloworld # 项目模板展示在控制台的名称(中文) 4 | author: Tencent Cloud, Inc. # 作者的名字 5 | org: Tencent Cloud, Inc. # 组织名称,可选 6 | description: This is helloworld function # 英文描述 7 | description-i18n: 8 | zh-cn: 快速部署一个 nodejs 云函数 # 中文描述述 9 | type: template #类型:模版 10 | keywords: tencent, scf, Nodejs10.15, helloworld # 关键字 11 | repo: https://github.com/serverless-components/tencent-examples/tree/master/scf-nodejs # 源代码 12 | readme: https://github.com/serverless-components/tencent-examples/tree/master/scf-nodejs/README.md # 详细的说明文件 13 | license: MIT # 版权声明 14 | src: # 描述项目中的哪些文件需要作为模板发布 15 | src: ./src # 指定具体的相对目录,此目录下的文件将作为模板发布 16 | exclude: #描述在指定的目录内哪些文件应该被排除 17 | # 通常你希望排除 18 | # 1. 包含secrets的文件 19 | # 2. .git git源代码管理的相关文件 20 | # 3. node_modules等第三方依赖文件 -------------------------------------------------------------------------------- /scf-nodejs/src/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 scf-nodejs 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | scf-nodejs 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 scf-nodejs 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init scf-nodejs --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 scf-nodejs 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /scf-nodejs/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | exports.main_handler = async (event, context) => { 3 | console.log("Hello World") 4 | console.log(event) 5 | console.log(event["non-exist"]) 6 | console.log(context) 7 | return event 8 | }; -------------------------------------------------------------------------------- /scf-nodejs/src/serverless.yml: -------------------------------------------------------------------------------- 1 | # 欢迎使用 ⚡️serverless⚡️ 组件 2 | # 3 | # serverless组件是基于具体使用场景(Express, 静态网站等)提供的定制云资源编排和组织的解决方案。 4 | # 这是serverless的主要配置文件,包含了一些使用示例以及注释说明。 5 | # 您只需几行配置描述,即可进行云函数、API 网关、COS、DB 等 6 | # Serverless 资源进行快速创建、部署和修改。 7 | # 8 | # 有关完整的配置选项,请检查文档: 9 | # https://cloud.tencent.com/document/product/1154/51080 10 | # 11 | # 👩‍💻 Happy Coding 👨‍💻 12 | 13 | # ##应用信息## 14 | app: helloworld # app名称(app唯一识别标识)。同账号下需唯一,留空则继承组件实例名称 15 | component: scf # [必选]要使用组件,更多组件请查看 https://github.com/serverless-components 16 | name: scf-nodejs # [必选]组件实例名称 17 | 18 | # ##scf 组件配置## 19 | # 更多内容请查看: https://github.com/serverless-components/tencent-scf/blob/master/docs/configure.md 20 | inputs: 21 | src: ./ # 执行目录 22 | handler: index.main_handler # 函数方法名称【文件名称.函数名称】。名称要求字母开始和结尾,允许使用数字、下划线(_)和连接符(-),2-60 个字符。 23 | region: ap-guangzhou # 部署目标地区。 更多参考 https://cloud.tencent.com/document/api/583/17238#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 24 | runtime: Nodejs10.15 # 运行环境。[Nodejs10.15, Nodejs12.16] 25 | memorySize: 128 # 函数运行内存,单位MB。[64, 128, ... 3072],以 128 递增 26 | timeout: 3 # 函数超时时间,单位秒,范围 1-900 27 | events: # 触发器 28 | - apigw: # api网关触发器,已有apigw服务,配置触发器 29 | parameters: 30 | endpoints: 31 | - path: / 32 | method: GET 33 | -------------------------------------------------------------------------------- /scf-php/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 scf-php 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | scf-php 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 scf-php 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init scf-php --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 scf-php 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /scf-php/serverless.template.yml: -------------------------------------------------------------------------------- 1 | 2 | name: scf-php # 项目模板的名字 3 | displayName: helloworld # 项目模板展示在控制台的名称(中文) 4 | author: Tencent Cloud, Inc. # 作者的名字 5 | org: Tencent Cloud, Inc. # 组织名称,可选 6 | description: This is helloworld function # 英文描述 7 | description-i18n: 8 | zh-cn: 快速部署一个 PHP 云函数 # 中文描述 9 | type: template #类型:模版 10 | keywords: tencent, scf, PHP7.2, helloworld # 关键字 11 | repo: https://github.com/serverless-components/tencent-examples/tree/master/scf-php # 源代码 12 | readme: https://github.com/serverless-components/tencent-examples/tree/master/scf-php/README.md # 详细的说明文件 13 | license: MIT # 版权声明 14 | src: # 描述项目中的哪些文件需要作为模板发布 15 | src: ./src # 指定具体的相对目录,此目录下的文件将作为模板发布 16 | exclude: #描述在指定的目录内哪些文件应该被排除 17 | # 通常你希望排除 18 | # 1. 包含secrets的文件 19 | # 2. .git git源代码管理的相关文件 20 | # 3. node_modules等第三方依赖文件 -------------------------------------------------------------------------------- /scf-php/src/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 scf-php 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | scf-php 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 scf-php 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init scf-php --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 scf-php 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /scf-php/src/index.php: -------------------------------------------------------------------------------- 1 | 20 | -------------------------------------------------------------------------------- /scf-php/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: scf 2 | name: scf-php 3 | app: helloworld 4 | 5 | inputs: 6 | src: ./ 7 | description: helloworld 空白模板函数 8 | handler: index.main_handler 9 | runtime: Php7 10 | namespace: default 11 | region: ap-guangzhou 12 | memorySize: 128 13 | timeout: 3 14 | -------------------------------------------------------------------------------- /scf-php/src/template.yaml: -------------------------------------------------------------------------------- 1 | Resources: 2 | default: 3 | Type: TencentCloud::Serverless::Namespace 4 | helloworld: 5 | Type: TencentCloud::Serverless::Function 6 | Properties: 7 | Description: helloworld 空白模板函数 8 | MemorySize: 128 9 | Handler: index.main_handler 10 | Timeout: 3 11 | CodeUri: ./ 12 | Runtime: Php7 13 | -------------------------------------------------------------------------------- /scf-python/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 scf-python 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | scf-python 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 scf-python 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init scf-python --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 scf-python 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /scf-python/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: scf-python # 项目模板的名字 2 | displayName: helloworld # 项目模板展示在控制台的名称(中文) 3 | author: Tencent Cloud, Inc. # 作者的名字 4 | org: Tencent Cloud, Inc. # 组织名称,可选 5 | description: This is helloworld function # 英文描述 6 | description-i18n: 7 | zh-cn: 快速部署一个 python 云函数 # 中文描述 8 | type: template #类型:模版 9 | keywords: tencent, scf, Python3.6, helloworld # 关键字 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/scf-python # 源代码 11 | readme: https://github.com/serverless-components/tencent-examples/tree/master/scf-python/README.md # 详细的说明文件 12 | license: MIT # 版权声明 13 | src: # 描述项目中的哪些文件需要作为模板发布 14 | src: ./src # 指定具体的相对目录,此目录下的文件将作为模板发布 15 | exclude: #描述在指定的目录内哪些文件应该被排除 16 | # 通常你希望排除 17 | # 1. 包含secrets的文件 18 | # 2. .git git源代码管理的相关文件 19 | # 3. node_modules等第三方依赖文件 -------------------------------------------------------------------------------- /scf-python/src/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 scf-python 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | scf-python 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 scf-python 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init scf-python --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 scf-python 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /scf-python/src/index.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | import json 3 | def main_handler(event, context): 4 | print("Received event: " + json.dumps(event, indent = 2)) 5 | print("Received context: " + str(context)) 6 | print("Hello world") 7 | return("Hello World") -------------------------------------------------------------------------------- /scf-python/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: scf 2 | name: scf-python 3 | app: helloworld 4 | 5 | inputs: 6 | src: ./ 7 | description: helloworld blank template function. Helloworld空白模板函数 8 | handler: index.main_handler 9 | runtime: Python3.6 10 | namespace: default 11 | region: ap-guangzhou 12 | memorySize: 128 13 | timeout: 3 14 | -------------------------------------------------------------------------------- /scf-starter/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 scf-starter 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | scf-starter 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 scf-starter 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init scf-starter --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 scf-starter 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /scf-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: scf-starter 2 | version: 0.0.0 3 | type: template 4 | org: "Tencent Cloud, Inc." 5 | author: "Tencent Cloud, Inc." 6 | description: Deploys a SCF on Tencent Cloud 7 | description-i18n: 8 | zh-cn: 快速部署一个云函数 # 中文描述 9 | keywords: tencent cloud, serverless, scf 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/scf-starter 11 | readme: https://github.com/serverless-components/tencent-examples/tree/master/scf-starter/README.md 12 | license: MIT 13 | 14 | src: 15 | src: ./src 16 | exclude: 17 | - .env 18 | - '.git/**' 19 | - '**/node_modules' 20 | - '**/package-lock.json' 21 | -------------------------------------------------------------------------------- /scf-starter/src/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 scf-starter 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | scf-starter 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 scf-starter 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init scf-starter --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 scf-starter 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /scf-starter/src/index.js: -------------------------------------------------------------------------------- 1 | exports.main_handler = async (event, context) => { 2 | console.log(event) 3 | return { 4 | msg: 'Hello Serverless' 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /scf-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | # 欢迎使用 ⚡️serverless⚡️ 组件 2 | # 3 | # serverless组件是基于具体使用场景(Express, 静态网站等)提供的定制云资源编排和组织的解决方案。 4 | # 这是serverless的主要配置文件,包含了一些使用示例以及注释说明。 5 | # 您只需几行配置描述,即可进行云函数、API 网关、COS、DB 等 6 | # Serverless 资源进行快速创建、部署和修改。 7 | # 8 | # 有关完整的配置选项,请检查文档: 9 | # https://cloud.tencent.com/document/product/1154/51080 10 | # 11 | # 👩‍💻 Happy Coding 👨‍💻 12 | 13 | #应用信息 14 | app: scf-starter 15 | 16 | #组件信息 17 | component: scf # (必填) 引用 component 的名称,当前用到的是 tencent-scf 组件 18 | name: scfdemo # (必填) 创建的实例名称,请修改成您的实例名称 19 | 20 | # ##scf 组件配置## 21 | # 更多内容请查看: https://github.com/serverless-components/tencent-scf/blob/master/docs/configure.md 22 | #组件参数 23 | inputs: 24 | src: ./ #代码路径 25 | handler: index.main_handler # 函数方法名称【文件名称.函数名称】。名称要求字母开始和结尾,允许使用数字、下划线(_)和连接符(-),2-60 个字符。 26 | runtime: Nodejs10.15 # 运行环境。[Nodejs10.15, Nodejs12.16] 27 | region: ap-guangzhou # 部署目标地区。 更多参考 https://cloud.tencent.com/document/api/583/17238#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 28 | events: # 触发器 29 | - apigw: # 网关触发器 30 | parameters: 31 | endpoints: 32 | - path: / 33 | method: GET 34 | -------------------------------------------------------------------------------- /scripts/publishAllTemplates.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const util = require('util'); 3 | const exec = util.promisify(require('child_process').exec); 4 | 5 | const folderNames = fs.readdirSync('./'); 6 | 7 | const run = async () => { 8 | for (const folderName of folderNames) { 9 | const isDir = fs.statSync(folderName).isDirectory(); 10 | const notTemplateFolders = ['.git', '.github', 'scripts']; 11 | 12 | // is template dir 13 | if (isDir && !notTemplateFolders.includes(folderName)) { 14 | console.log('start publishing', folderName); 15 | 16 | // To publish templates in dev env: add SERVERLESS_PLATFORM_STAGE=dev 17 | const { stdout, stderr } = await exec(`cd ${folderName} && sls publish`); 18 | if (stderr) console.error('stderr:', stderr); 19 | console.log(folderName, 'published'); 20 | } 21 | } 22 | } 23 | 24 | run(); 25 | -------------------------------------------------------------------------------- /springboot-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: springboot-starter 2 | displayName: SpringBoot 项目模版 3 | author: Tencent Cloud, Inc. 4 | org: Tencent Cloud, Inc. 5 | description: Deploy an SpringBoot app via SCF and Apigateway 6 | description-i18n: 7 | zh-cn: 快速部署一个 SpringBoot 基础应用 8 | type: template 9 | keywords: tencent, SpringBoot, java, SCF, APIGateway 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/springboot-starter 11 | readme: https://github.com/serverless-components/tencent-examples/tree/master/springboot-starter/README.md 12 | license: MIT 13 | src: 14 | src: ./src 15 | -------------------------------------------------------------------------------- /springboot-starter/src/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /springboot-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: springboot 2 | name: springbootDemo 3 | app: springbootAppDemo 4 | 5 | inputs: 6 | region: ap-guangzhou 7 | runtime: Java8 8 | src: ./ 9 | projectJarName: 'my-springboot.jar' 10 | functionConfig: 11 | handler: 'example.MyHandler::mainHandler' 12 | timeout: 30 13 | memorySize: 256 14 | apigatewayConf: 15 | protocols: 16 | - http 17 | - https 18 | environment: release 19 | -------------------------------------------------------------------------------- /springboot-starter/src/src/main/java/example/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoApplication { 8 | 9 | public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /springboot-starter/src/src/main/java/example/MyHandler.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import com.qcloud.scf.runtime.AbstractSpringHandler; 4 | import org.springframework.http.MediaType; 5 | 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | //import org.springframework.http.MediaType; 10 | //import java.util.Collections; 11 | //import java.util.List; 12 | 13 | public class MyHandler extends AbstractSpringHandler { 14 | 15 | /* 16 | 自定义需要转换成Base64的MediaType列表,默认为MediaType.ALL 17 | */ 18 | // @Override 19 | // public List getBinaryTypes() { 20 | // return Arrays.asList(MediaType.IMAGE_PNG, MediaType.IMAGE_JPEG); 21 | // } 22 | 23 | @Override 24 | public void startApp() { 25 | System.out.println("start app"); 26 | DemoApplication.main(new String[]{""}); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /springboot-starter/src/src/main/java/example/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package example.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @Controller 7 | public class HelloController { 8 | 9 | @RequestMapping("/view") 10 | public String indexView() { 11 | return "index"; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /springboot-starter/src/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #thymeleaf 2 | spring.thymeleaf.cache=false 3 | spring.thymeleaf.encoding=UTF-8 4 | spring.thymeleaf.mode=HTML5 5 | spring.thymeleaf.content-type=text/html 6 | spring.thymeleaf.prefix=classpath:/templates/ 7 | spring.thymeleaf.suffix=.html -------------------------------------------------------------------------------- /springboot-starter/src/src/main/resources/static/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/springboot-starter/src/src/main/resources/static/bg.png -------------------------------------------------------------------------------- /springboot-starter/src/src/main/resources/static/test.txt: -------------------------------------------------------------------------------- 1 | This is the test.txt content. -------------------------------------------------------------------------------- /springboot-starter/src/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Springboot Demo 6 | 7 | 8 |

Hello, Springboot!

9 | 10 | 11 | -------------------------------------------------------------------------------- /transcode-app/.gitignore: -------------------------------------------------------------------------------- 1 | !.env -------------------------------------------------------------------------------- /transcode-app/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: transcode-app 2 | author: Tencent Cloud, Inc. 3 | org: Tencent Cloud, Inc. 4 | description: Deploy a transcode app 5 | description-i18n: 6 | zh-cn: 使用COS+云函数+CLS+FFmpeg,快速构建高可用、并行处理、实时日志、高度自定义视频转码服务。 7 | keywords: tencent, serverless, express, website, transcode 8 | repo: https://github.com/serverless-components/tencent-examples/tree/master/transcode-app 9 | readme: https://github.com/serverless-components/tencent-examples/tree/master/transcode-app/README.md 10 | license: MIT 11 | 12 | src: 13 | src: ./src 14 | include: 15 | - .env 16 | -------------------------------------------------------------------------------- /transcode-app/src/.env: -------------------------------------------------------------------------------- 1 | REGION=ap-shanghai 2 | -------------------------------------------------------------------------------- /transcode-app/src/log/serverless.yml: -------------------------------------------------------------------------------- 1 | #组件信息 全量配置参考https://github.com/serverless-components/tencent-cls/blob/master/docs/configure.md 2 | component: cls # 引用 component 的名称 3 | name: cls-video # 创建的实例名称,请修改成您的实例名称 4 | 5 | #组件参数 6 | inputs: 7 | name: cls-log # 您需要配置一个name,作为您的cls日志集名称 8 | topic: video-log # 您需要配置一个topic,作为您的cls日志主题名称 9 | region: ${env:REGION} # 区域,统一在环境变量中定义 10 | period: 7 # 日志保存时间,单位天 -------------------------------------------------------------------------------- /transcode-app/src/serverless.yml: -------------------------------------------------------------------------------- 1 | app: transcodeApp -------------------------------------------------------------------------------- /transcode-app/src/transcode/src/ffmpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/transcode-app/src/transcode/src/ffmpeg -------------------------------------------------------------------------------- /vue-starter/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 vue-starter 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | vue-starter 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 vue-starter 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init vue-starter --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 vue-starter 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /vue-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: vue-starter 2 | version: 0.0.0 3 | type: template 4 | org: "Tencent Cloud, Inc." 5 | author: "Tencent Cloud, Inc." 6 | description: Deploys a serverless Vue website on Tencent Cloud 7 | description-i18n: 8 | zh-cn: 快速部署一个 Vue.js 基础应用 9 | keywords: tencent cloud, serverless, website, frontend, vue 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/vue-starter 11 | readme: https://github.com/serverless-components/tencent-examples/tree/master/vue-starter/README.md 12 | license: MIT 13 | 14 | src: 15 | src: ./src 16 | exclude: 17 | - .env 18 | - '.git/**' 19 | - '**/node_modules' 20 | - '**/dist' 21 | - '**/package-lock.json' 22 | -------------------------------------------------------------------------------- /vue-starter/src/README.md: -------------------------------------------------------------------------------- 1 | # 快速构建 vue-starter 2 | 3 | **中文** | [English](./README_EN.md) 4 | 5 | ## 简介 6 | 7 | vue-starter 模板使用 Tencent SCF 组件及其触发器能力,方便的在腾讯云创建,配置和管理一个 vue-starter 应用。 8 | 9 | ## 快速开始 10 | 11 | ### 1. 安装 12 | 13 | ```bash 14 | # 安装 Serverless Framework 15 | npm install -g serverless 16 | ``` 17 | 18 | ### 2. 创建 19 | 20 | 通过如下命令直接下载该例子: 21 | 22 | ```bash 23 | serverless init vue-starter --name example 24 | cd example 25 | ``` 26 | 27 | ### 3. 部署 28 | 29 | 在 `serverless.yml` 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署: 30 | 31 | ```bash 32 | serverless deploy 33 | ``` 34 | 35 | > **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。 36 | 37 | ### 4. 查看状态 38 | 39 | 执行以下命令,查看您部署的项目信息: 40 | 41 | ```bash 42 | serverless info 43 | ``` 44 | 45 | ### 5. 移除 46 | 47 | 可以通过以下命令移除 vue-starter 应用 48 | 49 | ```bash 50 | serverless remove 51 | ``` 52 | 53 | ### 账号配置(可选) 54 | 55 | serverless 默认支持扫描二维码登录,用户扫描二维码后会自动生成一个 `.env` 文件并将密钥存入其中. 56 | 如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件, 57 | 把从[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取的 `SecretId` 和`SecretKey` 填入其中. 58 | 59 | > 如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)。 60 | 61 | ```bash 62 | # 腾讯云的配置信息 63 | touch .env 64 | ``` 65 | 66 | ``` 67 | # .env file 68 | TENCENT_SECRET_ID=123 69 | TENCENT_SECRET_KEY=123 70 | ``` 71 | -------------------------------------------------------------------------------- /vue-starter/src/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /vue-starter/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tencent-vue-starter", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint", 9 | "test": "jest ./tests/integration.test.js --testEnvironment node" 10 | }, 11 | "dependencies": { 12 | "core-js": "^3.6.5", 13 | "vue": "^2.6.11" 14 | }, 15 | "devDependencies": { 16 | "@serverless/platform-client-china": "^1.0.32", 17 | "@vue/cli-plugin-babel": "~4.4.0", 18 | "@vue/cli-plugin-eslint": "~4.4.0", 19 | "@vue/cli-service": "~4.4.0", 20 | "axios": "^0.19.2", 21 | "babel-eslint": "^10.1.0", 22 | "dotenv": "^8.2.0", 23 | "eslint": "^6.7.2", 24 | "eslint-plugin-vue": "^6.2.2", 25 | "jest": "^26.2.2", 26 | "vue-template-compiler": "^2.6.11" 27 | }, 28 | "eslintConfig": { 29 | "root": true, 30 | "env": { 31 | "node": true 32 | }, 33 | "extends": [ 34 | "plugin:vue/essential", 35 | "eslint:recommended" 36 | ], 37 | "parserOptions": { 38 | "parser": "babel-eslint" 39 | }, 40 | "rules": {} 41 | }, 42 | "browserslist": [ 43 | "> 1%", 44 | "last 2 versions", 45 | "not dead" 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /vue-starter/src/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/vue-starter/src/public/favicon.ico -------------------------------------------------------------------------------- /vue-starter/src/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /vue-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: website 2 | name: vue-starter 3 | app: vue-starter 4 | 5 | inputs: 6 | src: 7 | src: ./src 8 | hook: npm run build 9 | dist: ./dist 10 | bucketName: my-vue-starter 11 | protocol: https -------------------------------------------------------------------------------- /vue-starter/src/src/App.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 18 | 19 | 29 | -------------------------------------------------------------------------------- /vue-starter/src/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverless-components/tencent-examples/f0e3f4d0a186f00fb055ae430ddd27fb9a732f4f/vue-starter/src/src/assets/logo.png -------------------------------------------------------------------------------- /vue-starter/src/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | Vue.config.productionTip = false 5 | 6 | new Vue({ 7 | render: h => h(App), 8 | }).$mount('#app') 9 | -------------------------------------------------------------------------------- /vue-starter/src/tests/utils.js: -------------------------------------------------------------------------------- 1 | const { ServerlessSDK } = require('@serverless/platform-client-china') 2 | require('dotenv').config() 3 | 4 | /* 5 | * Generate random id 6 | */ 7 | const generateId = () => Math.random().toString(36).substring(6) 8 | 9 | /* 10 | * Initializes and returns an instance of the serverless sdk 11 | * @param ${string} orgName - the serverless org name. 12 | */ 13 | const getServerlessSdk = (orgName) => { 14 | const sdk = new ServerlessSDK({ 15 | context: { 16 | orgName, 17 | }, 18 | }) 19 | return sdk 20 | } 21 | const getCredentials = () => { 22 | const credentials = { 23 | tencent: { 24 | SecretId: process.env.TENCENT_SECRET_ID, 25 | SecretKey: process.env.TENCENT_SECRET_KEY, 26 | }, 27 | } 28 | 29 | if (!credentials.tencent.SecretId || !credentials.tencent.SecretKey) { 30 | throw new Error( 31 | 'Unable to run tests. Tencent credentials not found in the envionrment', 32 | ) 33 | } 34 | 35 | return credentials 36 | } 37 | module.exports = { generateId, getServerlessSdk, getCredentials } 38 | -------------------------------------------------------------------------------- /website-starter/serverless.template.yml: -------------------------------------------------------------------------------- 1 | name: website-starter 2 | displayName: Website 项目模版 3 | author: Tencent Cloud, Inc. 4 | org: Tencent Cloud, Inc. 5 | description: Deploy an static website app. 6 | description-i18n: 7 | zh-cn: 快速部署一个静态网站 8 | type: template 9 | keywords: tencent, Website, APIGateway 10 | repo: https://github.com/serverless-components/tencent-examples/tree/master/website-starter 11 | readme: https://github.com/serverless-components/tencent-examples/blob/master/website-starter/README.md 12 | license: MIT 13 | src: 14 | src: ./src 15 | exclude: 16 | -------------------------------------------------------------------------------- /website-starter/src/serverless.yml: -------------------------------------------------------------------------------- 1 | component: website 2 | name: websiteDemo 3 | app: websiteApp 4 | 5 | inputs: 6 | src: 7 | src: ./src 8 | index: index.html 9 | error: index.html 10 | region: ap-guangzhou 11 | bucketName: my-website-starter 12 | protocol: https 13 | -------------------------------------------------------------------------------- /website-starter/src/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Serverless Component - website 7 | 14 | 15 | 16 |

17 | Welcome to website created by 18 | Serverless Framework. 19 |

20 | 21 | 22 | --------------------------------------------------------------------------------