Simple conditional redirects based on query string values

Hi! I’m new to the workers scripts and learning to transfer some of our use cases to the cloud. In NGINX, we have a link redirector that redirects based on the query string, i.e:

For example, if this link will receive:
redirect it to:
redirect it to:

else return a 404

We have this system set up in NGINX with regex matching on the values of the url parameter. I’m wondering how to implement this using a worker script as this should lower the latency. A simple script would be appreciated. Thanks for any nudge on the right direction!