diff --git a/CHANGELOG.md b/CHANGELOG.md index 25cb023..b114c3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.0.7](https://github.com/serverless-components/tencent-egg/compare/v1.0.6...v1.0.7) (2020-05-14) + + +### Bug Fixes + +* custom sls.js load logical ([b79c948](https://github.com/serverless-components/tencent-egg/commit/b79c948af5dfb70a279b53763ea3e0d7b979d1bd)) + +### [1.0.6](https://github.com/serverless-components/tencent-egg/compare/v1.0.5...v1.0.6) (2020-04-21) + + +### Features + +* make callbackWaitsForEmptyEventLoop default to false ([ed3508f](https://github.com/serverless-components/tencent-egg/commit/ed3508ff03bfe88257afb508952eb805c401ce86)) + ### [1.0.5](https://github.com/serverless-components/tencent-egg/compare/v1.0.4...v1.0.5) (2020-04-03) diff --git a/docs/configure.md b/docs/configure.md index 5960cf3..be03532 100644 --- a/docs/configure.md +++ b/docs/configure.md @@ -77,8 +77,8 @@ Main param description | Param | Required | Default | Description | | ---------------------------------------- | :------: | :-------------: | :------------------------------------------------------------------------------------------ | -| runtime | N | Nodejs8.9 | Function Runtime, support: Nodejs6.10, Nodejs8.9, Nodejs10.15 | -| region | N | ap-guangzhou | Deploy region | +| runtime | N | `Nodejs8.9` | Function Runtime, support: Nodejs6.10, Nodejs8.9, Nodejs10.15 | +| region | N | `ap-guangzhou` | Deploy region | | functionName | N | | Serverless Cloud Function Name | | serviceName | N | | API-Gateway service name, default to create a new serivce | | serviceId | N | | API-Gateway service id, if it has will use this APII-Gateway service | diff --git a/package.json b/package.json index f932ba0..1d4bbfe 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@serverless/tencent-egg", "description": "Tencent Cloud Egg.js Serverless Component", - "version": "1.0.5", + "version": "1.0.7", "main": "serverless.js", "publishConfig": { "access": "public" diff --git a/src/shims/handler.js b/src/shims/handler.js index b06b45c..0214979 100644 --- a/src/shims/handler.js +++ b/src/shims/handler.js @@ -1,15 +1,23 @@ const path = require('path') const fs = require('fs') const { createServer, proxy } = require('tencent-serverless-http') -let app = require('./sls') module.exports.handler = async (event, context) => { const userSls = path.join(__dirname, 'sls.js') + let app if (fs.existsSync(userSls)) { // eslint-disable-next-line console.log('Using user custom sls.js') app = require(userSls) + } else { + app = require('./sls') } - const server = createServer(app.callback(), null, app.binaryTypes || []) - return proxy(server, event, context, 'PROMISE').promise + + context.callbackWaitsForEmptyEventLoop = + app.callbackWaitsForEmptyEventLoop === true ? true : false + + if (!global.server) { + global.server = createServer(app.callback(), null, app.binaryTypes || []) + } + return proxy(global.server, event, context, 'PROMISE').promise }