From d9946926fa31b995b231d952190f7731936382d9 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 21 Jun 2018 08:29:35 +0200 Subject: [PATCH] prototype Zoho proxy --- package.json | 4 +++- webtask-zoho.js | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 webtask-zoho.js diff --git a/package.json b/package.json index 09a4075..04f03da 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,13 @@ "version": "0.1.0", "private": true, "scripts": { - "start": "wt serve webtask-medium.js", + "start": "wt serve webtask-zoho.js", "test": "eslint ./{src,public}/**/*.js" }, "dependencies": { + "cors": "^2.8.4", "express": "^4.16.3", + "http-proxy-middleware": "^0.18.0", "request": "^2.85.0", "webtask-tools": "^3.2.0" }, diff --git a/webtask-zoho.js b/webtask-zoho.js new file mode 100644 index 0000000..da45568 --- /dev/null +++ b/webtask-zoho.js @@ -0,0 +1,21 @@ +const express = require('express') +const Webtask = require('webtask-tools') +const cors = require('cors') +const proxy = require('http-proxy-middleware') + +const server = express() + +const config = { + target: 'https://www.zohoapis.com/crm/v2/', + changeOrigin: true, + headers: { + Authorization: 'Zoho-oauthtoken hello' + } +} + +server.use(cors()) +server.use('*', proxy(config)) + +server.listen(4430) + +module.exports = Webtask.fromExpress(server)