Compute service JS | add my code to existing code

Hi,
I would like to add my JS code to an existing code in Compute Service JS.
my code is an index.js file that fetch the request, takes some metadata about the request and the response, and returns the response back.
can I do it?
if yes, what is the better way to do it? add my code to npm and just import the package?

Thanks.

Hi tchelet

Thanks for reaching out!

If you already have a compute service setup, then I think the simplest thing to do would be to follow the standard JavaScript practices for application structure (e.g. put your code into a separate .js file that can be imported using import).

NOTE: I’m not a JavaScript developer so unfortunately I can’t comment on the exact process for structuring a JavaScript application.

I don’t think you’d need to package your code up into a separate NPM package unless you are hoping other users of the Fastly platform would install and use the package.