sam-goodwin / eventual

Build scalable and durable micro-services with APIs, Messaging and Workflows
https://docs.eventual.ai
MIT License
174 stars 4 forks source link

Design: Assets #336

Open thantos opened 1 year ago

thantos commented 1 year ago

Services need access to named static or dynamic data. This data may be known statically at synth time, after deployment time, or could be created once and updated later. This data may also need to be exposed as static assets to the API.

These same files should also be generated for and work for the local dev server.

Use Case:

  1. Hosted schema for openai plugings. The ai-plugin.json may have both generated and static values. The OpenAPI specification used by open AI may be generated or use the specification generated by eventual. Both of these documents need to be exposed at HTTP urls.
  2. Static HTML files for a single page application
  3. Uploading a file a static images for use in a website
const aiPluginJson = asset("aiPluginJson", { ... });

api.asset("/.well-known/ai-plugin.json", aiPluginJson);
// in service
const specification = asset.fromInfra("specification");

api.asset("spec.json", specification);

// in CDK

service.assets.specification.value = service.specification;
// in service
// path to a local folder of images
const images = asset.folder("images", "./images");

api.asset("images", images);