Open RaphaelManke opened 1 year ago
I think we will need a solution for this and for the cloud.Website
resource - cc @tsuf239
brainstorming some ideas...
WING_API_PORT
? To avoid confusion we would need to throw if the app has more than one cloud.Api
. Also this solution would not play well with the Wing consolewing.yml
that has a section for simulator options. It would be nice if we can avoid configuration files...bring cloud;
bring sim;
let api = new cloud.Api();
(<sim.Api>api).set_port(3000); // casting mechanism -- will fail if you compile to `tf-aws`
I would add an idea like
http://localhost:<staticPort>/<apiIdentifier>
This allows a port be defined by the user e.g. if a default port is not suitable and also support multiple APIs in an wing app.
The apiIdentifier could be something like the node hash.
This is a duplicate with #2227 -- I am not sure a static port is necessarily the correct way to address this use case.
This is a duplicate with #2227 -- I am not sure a static port is necessarily the correct way to address this use case.
@eladb I'm not sure that #2227 is really covering this. I think exposing a service to the public internet is quite a different use-case from wanting to have a locally available, static port - even if not necessarily technically, certainly from an organizational policy point of view e.g.: I might have another application I develop running locally (no matter if frontend or backend), where all I want is a known address to a Wing API. In particular in enterprise contexts, I could see this become a dealbreaker if the only option was exposing this via something like ngrok.
I agree I think some more discussion is needed, also this issue does not only pertain to webhooks (webhooks just happen to be one use case). Reopening
We need one for the website as well :) my initial thought was to just let the user decide, inside the Api/website constructor made sense for me back then, but I do like @Chriscbr's in-code suggestion, (which we can even change a bit to avoid the user comment and uncomment the line of code to make the file compiles to both sim and aws)
let api = new cloud.Api();
if (utils.target == TARGETS.SIM ) {
api.setPort(3000);
}
Duplicates #2227
Oops, missed some important comments on this issue... Reopening - we'll discuss it on a next team time
We've made two changes that should help here:
cloud.Api
on the simulator are now reused (https://github.com/winglang/wing/pull/5736)Let us know if these improvements solve your use case(s). I'll downgrade this issue to P2 for now - but if there are use cases or situations that aren't addressed by these changes, I think it could still be feasible to support static ports via an optional custom platform parameter: https://www.winglang.io/docs/concepts/platforms#defining-custom-platform-parameters
Hi,
This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!
Feature Spec
I would like to have a static port when the cloud.Api resource is started in simulator.
Use Cases
This helps in cases where I develop against the api e.g. with a Frontend or want to make api calls with an external api client like insomnia oder postman. On top of that it enables the use of http reverse proxy like ngrok.
I discovered this lack of capability while developing a slack bot. To test it I used ngrok to forward the slack commands to the local machine.
Implementation Notes
No response
Component
SDK, Wing Console
Community Notes