Forum Academy Marketplace Showcase Pricing Features

Migrate script to Google Code Functions

Hello, anyone here with nodejs skills who can help me migrate the following script from @Kfawcett from to Google Clode Functions?

@param context {WebtaskContext}
This task routes a request between two different URLs. If the request has a query parameter then it goes to endPoint1, else it goes to endPoint2
var express = require(‘express’);
var Webtask = require(‘webtask-tools’);
var bodyParser = require(‘body-parser’);
var proxy = require(‘express-http-proxy’);
var app = express();

app.use("/", proxy(‘’, {
proxyReqPathResolver: function (req) {
var parts = req.url.split(’?’);
console.log("parts " + parts);
var queryString = parts[1];
var updatedPath = parts[0].replace(’/’, ‘/version-test/api/1.1/wf/’);
var endPoint1 = ‘/msgraphvalidation?’;
var endPoint2 = ‘/msgraphsubscription’;
return updatedPath + (queryString ? endPoint1 + queryString : endPoint2);

module.exports = Webtask.fromExpress(app);