From c99b32cd89f4ba1165b5cc12e0a5f789411626f3 Mon Sep 17 00:00:00 2001 From: Alen Joseph Date: Thu, 18 Jul 2019 12:40:10 +0530 Subject: [PATCH 1/4] added params --- template/node10-express/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/template/node10-express/index.js b/template/node10-express/index.js index 8c85f48..670ee83 100644 --- a/template/node10-express/index.js +++ b/template/node10-express/index.js @@ -21,6 +21,7 @@ class FunctionEvent { this.method = req.method; this.query = req.query; this.path = req.path; + this.params=req.params } } From eed605c91fe313dbdc9f0ab9b13dc8fe60f5b2c5 Mon Sep 17 00:00:00 2001 From: Alen Joseph Date: Thu, 18 Jul 2019 12:40:34 +0530 Subject: [PATCH 2/4] Update index.js --- template/node10-express/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/node10-express/index.js b/template/node10-express/index.js index 670ee83..9a8fcb3 100644 --- a/template/node10-express/index.js +++ b/template/node10-express/index.js @@ -21,7 +21,7 @@ class FunctionEvent { this.method = req.method; this.query = req.query; this.path = req.path; - this.params=req.params + this.params=req.params; } } From 5d99816db7ab4a1ad5bf354734485d8e51731097 Mon Sep 17 00:00:00 2001 From: Alen Joseph Date: Thu, 18 Jul 2019 12:49:41 +0530 Subject: [PATCH 3/4] Update index.js --- template/node10-express/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/node10-express/index.js b/template/node10-express/index.js index 9a8fcb3..a80aea0 100644 --- a/template/node10-express/index.js +++ b/template/node10-express/index.js @@ -21,7 +21,7 @@ class FunctionEvent { this.method = req.method; this.query = req.query; this.path = req.path; - this.params=req.params; + } } From 9be2dbf79c26ddcec36da85a60619881bda6ed86 Mon Sep 17 00:00:00 2001 From: Alen Joseph Date: Sat, 27 Jul 2019 18:11:31 +0530 Subject: [PATCH 4/4] enabled cors --- template/node10-express-arm64/index.js | 7 ++++++- template/node10-express-arm64/package.json | 1 + template/node10-express-armhf/index.js | 7 ++++++- template/node10-express-armhf/package.json | 1 + template/node10-express/index.js | 8 ++++++-- template/node10-express/package.json | 1 + 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/template/node10-express-arm64/index.js b/template/node10-express-arm64/index.js index 8c85f48..240cc50 100644 --- a/template/node10-express-arm64/index.js +++ b/template/node10-express-arm64/index.js @@ -7,7 +7,7 @@ const express = require('express') const app = express() const handler = require('./function/handler'); const bodyParser = require('body-parser') - +const cors = require("cors");// imported cors package // app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); app.use(bodyParser.raw()); @@ -80,10 +80,15 @@ var middleware = (req, res) => { handler(fnEvent, fnContext, cb); }; +app.use(cors());// enabled cors app.post('/*', middleware); +app.use(cors());// enabled cors app.get('/*', middleware); +app.use(cors());// enabled cors app.patch('/*', middleware); +app.use(cors());// enabled cors app.put('/*', middleware); +app.use(cors());// enabled cors app.delete('/*', middleware); const port = process.env.http_port || 3000; diff --git a/template/node10-express-arm64/package.json b/template/node10-express-arm64/package.json index 51b667c..522fff1 100644 --- a/template/node10-express-arm64/package.json +++ b/template/node10-express-arm64/package.json @@ -11,6 +11,7 @@ "license": "ISC", "dependencies": { "body-parser": "^1.18.2", + "cors": "^2.8.5", "express": "^4.16.2" } } diff --git a/template/node10-express-armhf/index.js b/template/node10-express-armhf/index.js index 8c85f48..240cc50 100644 --- a/template/node10-express-armhf/index.js +++ b/template/node10-express-armhf/index.js @@ -7,7 +7,7 @@ const express = require('express') const app = express() const handler = require('./function/handler'); const bodyParser = require('body-parser') - +const cors = require("cors");// imported cors package // app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); app.use(bodyParser.raw()); @@ -80,10 +80,15 @@ var middleware = (req, res) => { handler(fnEvent, fnContext, cb); }; +app.use(cors());// enabled cors app.post('/*', middleware); +app.use(cors());// enabled cors app.get('/*', middleware); +app.use(cors());// enabled cors app.patch('/*', middleware); +app.use(cors());// enabled cors app.put('/*', middleware); +app.use(cors());// enabled cors app.delete('/*', middleware); const port = process.env.http_port || 3000; diff --git a/template/node10-express-armhf/package.json b/template/node10-express-armhf/package.json index 51b667c..522fff1 100644 --- a/template/node10-express-armhf/package.json +++ b/template/node10-express-armhf/package.json @@ -11,6 +11,7 @@ "license": "ISC", "dependencies": { "body-parser": "^1.18.2", + "cors": "^2.8.5", "express": "^4.16.2" } } diff --git a/template/node10-express/index.js b/template/node10-express/index.js index a80aea0..240cc50 100644 --- a/template/node10-express/index.js +++ b/template/node10-express/index.js @@ -7,7 +7,7 @@ const express = require('express') const app = express() const handler = require('./function/handler'); const bodyParser = require('body-parser') - +const cors = require("cors");// imported cors package // app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); app.use(bodyParser.raw()); @@ -21,7 +21,6 @@ class FunctionEvent { this.method = req.method; this.query = req.query; this.path = req.path; - } } @@ -81,10 +80,15 @@ var middleware = (req, res) => { handler(fnEvent, fnContext, cb); }; +app.use(cors());// enabled cors app.post('/*', middleware); +app.use(cors());// enabled cors app.get('/*', middleware); +app.use(cors());// enabled cors app.patch('/*', middleware); +app.use(cors());// enabled cors app.put('/*', middleware); +app.use(cors());// enabled cors app.delete('/*', middleware); const port = process.env.http_port || 3000; diff --git a/template/node10-express/package.json b/template/node10-express/package.json index 51b667c..522fff1 100644 --- a/template/node10-express/package.json +++ b/template/node10-express/package.json @@ -11,6 +11,7 @@ "license": "ISC", "dependencies": { "body-parser": "^1.18.2", + "cors": "^2.8.5", "express": "^4.16.2" } }