Replies: 1 comment
-
Cool idea. Is this an adapter, or is it merely an approach for building one? I could see a pretty generic rest "adapter" implementation like: const restAdapter = (methods = []) =>
(url, secret) =>
methods.reduce((acc, method) => ({
...acc,
[method]: async (...args) => {
const res = await fetch(url, {
headers: {
Authorization: `Bearer ${secret}`
},
body: JSON.stringify({
method,
payload: args
})
})
return res.json()
}
}))
// then use
const adapter = restAdapter(
['createDatabase', 'removeDatabase', 'createDocument', '...']
)('https://my.rest.service', Deno.env.get('REST_ADAPTER_SECRET')) Alternatively, we could have docs for how to do build this sort of thing. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This proposal is for a rest adapter for hyper, a kind of proxy adapter, the adapter would pass through to a REST integration, allowing for adapters to built using other technologies than Deno. For example, we could support a p2p database
hyperbee
which is tightly coupled to NodeJS, we could support hyperbee by creating anhyper-adapter-rest
adapter that basically, takes the port methods and implements them withfetch
rest calls. This will give us the ability to implement any service interface in any technology.Pros
Cons
Beta Was this translation helpful? Give feedback.
All reactions