Replies: 13 comments
-
I assume that all actions are nodejs based... so why using the Request/Response from Fetch API and not based NodeJS's ClientRequest/Response and/or using express like handlers? eg: async function handleDefault(req, res) {
// access environment (aka action params)
req.local.env.get(....);
res.status(501).send('not implmented yet');
}
export function(app) {
app.use(handleDefault);
} this would also allow to add different routes, for the more complex actions, eg: async function handleHealthCheck(req, res) {
...
}
export function(app) {
app.get('/_status_check/healthcheck.json', handleHealthCheck)
app.use(handleDefault);
} |
Beta Was this translation helpful? Give feedback.
-
using a if the API should be based on http request processing, I would not use fetch semantics, since they are built for clients. |
Beta Was this translation helpful? Give feedback.
-
I'm assuming JS, but not node so that we keep the door open for more lightweight runtimes like deno or Cloudflare Workers. 99% of our I/O is via HTTPS, so we have little need for the full power of node. |
Beta Was this translation helpful? Give feedback.
-
I see that multi-action functions are creeping monoliths and do not want to encourage that (I'm fine with not being able to prevent them either). Furthermore I do not like that express mixes request and environment and that it uses function parameters (input) as vehicles for results (output). A clear return value seems to be much cleaner. |
Beta Was this translation helpful? Give feedback.
-
I acknowledge that, but the fetch API is well known and vendor independent, so that it is easy to pick up for developers. In fact that API is used by Cloudflare Workers and Fastly, in both cases you'd use the constructor. |
Beta Was this translation helpful? Give feedback.
-
I disagree (of course). if you're implementing an API (e.g a backend for a SPA) it's much more convenient to have all code in 1 action that to have 100 actions loosely kept together by an API controller and a lot of release engineering glue.
maybe, but that's a necessity for the direct binding to the server request/response. which might indeed be a bit weird for the serverless usecase.
but most of the developers are used to express which also has a wide adoption base, examples and documentation. It just doesn't feel right to use client side API.
ok. one side note: using the express API, there already are implementations for:
|
Beta Was this translation helpful? Give feedback.
-
but I think I agree with your proposal. using the Fetch API is standard and more modern :-) what about creating a poc for one of your actions, eg git-resolve-ref (since you already started)? another interresting question is how to be agostic about the service catalog. e.g content-proxy invokes word2md, which might (or not?) be invoked in the same environment. So something like a |
Beta Was this translation helpful? Give feedback.
-
+1 for Fetch-like Request/Response objects. It can't be 100% compliant with the Fetch Spec though. The Fetch Spec was written for the browser use-case and includes many features/restrictions targeted at the browser (CORS etc) which don't make sense in the server-side use-case. It should be a pragmatic adaption of the spec, similar to node-fetch, helix-fetch et al. |
Beta Was this translation helpful? Give feedback.
-
BTW: Fastly's |
Beta Was this translation helpful? Give feedback.
-
AS does not have |
Beta Was this translation helpful? Give feedback.
-
I suggest to create a library that:
|
Beta Was this translation helpful? Give feedback.
-
now here: https://github.com/adobe/helix-deploy |
Beta Was this translation helpful? Give feedback.
-
Overview
If we wanted to deploy our serverless functions to more than one runtime environment, what would a good API look like?
I've been looking at APIs for
Details
Design Notes
fetch
APIfetch
APIasync
: better than Lambda's callbacksreturn
: better than a callback onrequest
,context
or setting a property oncontext
export
: always use the default exportcontext
: read-only container for:Proposed Actions
Beta Was this translation helpful? Give feedback.
All reactions