-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Astro resource #4075
Comments
I have limited experience with MPA frameworks but it would be great to get this working. Some initial ideas and thoughts:
The API makes sense to me - the only possible issue in the short term is I'm not sure if we'll be able to support passing entire resource clients (like
It's not possible to get the URL during the synthesis of the construct tree since the API resource may not be deployed yet (and the URL may be dynamically generated by a cloud provider). But, it is possible to have Wing create a Terraform (or CloudFormation) template in a way so that the URL is injected into a resource in one way or another during deployment time. In This "content" field references the property, and it's only read once the API has been deployed. This is just one way to do it, environment variables is another common solution, but I think we can also come up with more custom or granular solutions. Some way to create a custom resource might also solve this (not sure): #3270
In the normal sense, not really (right now all preflight methods have to be synchronous). It might be a good idea to create a separate issue if we want to add support for that. But it is possible to create a resource that performs an asynchronous task during deployment. For example,
I think it should be possible to lift these restrictions...
Sounds feasible. We don't have any reflection APIs in Wing yet but I know some folks have brought it up before as a potentially useful tool. |
To summarize, in an MPA framework there is a server that renders the HTML back to the user (a la old school PHP server). The difference today is that you can still code your app with your framework of choice (ie, react) as if it was a client-only app... you almost don't need to care about it being an MPA.
Yeah, inferring is out of the question here. As a workaround, we can "trigger" the permission binding as follows:
That's great. I think environment variables should be enough (and the most optimal way since it doesn't require fetching other resources). The astro server will be a cloud.Function so it can technically rely on
I think we need async in preflight initializers... It's a very common pattern that we'll encounter for so many resources we want to integrate with. I understand this needs a whole separate discussion, but I picture doing the following in the Astro initializer:
Good :) |
Just wanna sum up what I was trying to say in the meeting regarding the "SDK" - What I meant was SDK in a sense of an inflight client consumed in another context, which the following types seems to represent to me.
Isn't this just an implicit inflight SDK for resources defined in Wing to be consumed in another context - which happens to be Astro / JS in this case. However, conceptually this could be (generated) Python, Java or some other language code. So, could a similar thing be useful for a Laravel, Rails or Flask app? |
Hi, This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
Yes, if resources are able to reflect metadata from inflight APIs during preflight, it should be possible to generate source files for different languages (I believe). |
Create a Wing resource that enables working with Astro projects.
Some in-depth details:
Passing Data and Clients to the Astro environment
Currently, there's no way to pass inflight clients from Wing source code to the runtime environment in Astro. I thought this interface would be ideal to enable a good DX:
TypeScript type definitions for the Virtual Modules can be generated from Wing and consumed in the Astro project. The type definition needed for the example above would be:
Possible problems:
References:
Building one function per route or one for all
By building the Astro project with
adapterFeatures: { functionPerRoute: true }
, we can generate either one function per route, or one function for all routes. This implies that we need to build the Astro project before creating thecloud.Function
resources. It would be interesting to enable async tasks for resources, but in the meantime we can resort to use the Astro CLI withexec
orspawn
.References:
Creating Type Definitions for the Astro Virtual Modules
In Astro projects there's an
astro.config.mjs
file where you can customize the project. There you can enable integrations and adapters, which are similar to Vite plugins. I propose having a@winglang/astro-adapter
package that can be used like this:The purpose of this adapter is to:
wing it
The text was updated successfully, but these errors were encountered: