Express JS alternatives in Forge

Hi,

I am new to development on Jira Cloud and have a requirement where I need to intercept the coming request and modify the response being sent using the Forge App. For this, I thought of using Express JS as a middleware. Turns out that during deployment, it keeps giving this error “process.cwd is not a function.” (Attached the snapshot for reference.

I tried installing process module and updating the webpack version but it didn’t work.

  1. Is it because of the sandboxed runtime environment of Forge?
  2. Can someone please suggest the alternative for using Express JS?

Thanks in advance.
Apoorva


Not all of the build-in Nodejs modules are available in Forge, a sandboxed environment. You can read more about it here.
If you need to do something which is not possible in Forge, you may delegate this to another application. For example, you can use AWS Lambda and invoke it to process your request and get the result back to the Forge application. Doing this takes away some of the security guarantees of the Forge environment, and you should try not to do it unless you really need it.

2 Likes

It is probably best to use a different mental model when trying to understand forge. It is not a typical “Serverless” or FaaS platform.

Although forge runs on AWS and uses familiar terminology like “handler”, there is little similarity between the sandboxed environment of forge and AWS lambda. You should not approach writing forge functions as if you’re writing AWS lambda functions.

Even though @denizoguz is right, and you can invoke an http call to an AWS lambda function from within a forge function handler, i would not recommend doing so if the sole purpose is to cling on to a familiar mental model for writing serverless functions.

I would say that it is best to spend time learning the intricacies of the forge platform, preferably without the burden of previously learned patterns, and create native forge applications.

1 Like