solidjs / solid-start

SolidStart, the Solid app framework
https://start.solidjs.com
MIT License
5.19k stars 375 forks source link

feat: config export within api route #700

Closed OrJDev closed 10 months ago

OrJDev commented 1 year ago

Enhancement

Allow config export within api route, this is similar to NextJS v13 config exports.

Why

Assuming you have a solid-start app that includes api routes that cannot run in edge environment, and one single api route that can and should be running on vercel edge, how would you do that?

Currently when using the vercel adapter you have to say wether you do or don't want to use the vercel edge:

adapter: vercel({ edge: boolean });

How does it look like

In NextJS you can export a config object that mentions the runtime environment (edge, etc) - this should be exported from a single api route (api/test.ts for instance)

export const config = {
 runtime: "edge"
}

Using the above code will make this api route run in edge environment, by default it should target to non edge environments (meaning that it will be treated as serverless function if the config is not mentioned)

nksaraf commented 1 year ago

This would have to be more thought out because we probably want on way of doing route level config (for pages, and API routes).

It needs to be able to do a few things:

  1. Be Statically analyzable: If it needs to control how compilation/transpilation happens, then it needs to statically analyzable
  2. Tree shakeable: So that we can compile it out without including the component or data code. Should ideally be a tiny static config
  3. Typesafe: We should somehow be able to make it typesafe
arbassett commented 1 year ago

Something to note for config... this is very adapter specific as the concept of edge doesn't exist for node. its not the best example as most others do but their could be config for region names

ryansolid commented 10 months ago

In setting up for SolidStarts next Beta Phase built on Nitro and Vinxi we are closing all PRs/Issues that will not be merged due to the system changing. If you feel your issue was closed by mistake. Feel free to re-open it after updating/testing against 0.4.x release. Thank you for your patience.

See https://github.com/solidjs/solid-start/pull/1139 for more details.