You should check out Code on Standard Library [0], we do exactly this - turn JavaScript files into APIs via the open source FunctionScript specification [1]. We’re a Stripe-backed company and we do a lot of other stuff, too (handle auth between multiple providers... etc.), but building APIs easily is where we started.
We have a lot of new tooling coming soon, so if this is of interest to you please reach out! You can e-mail me directly: keith at (our domain).