Open jyecusch opened 2 years ago
One thing that needs to be considered here is securing the default API.
This is currently defined upon API creation, as it needs to be defined at the top level of the API.
Currently we do:
import { api, jwt } from "@nitric/sdk";
const publicApi = api('public', {
securityDefinitions: {
'user': jwt({
issuer: "example...",
audiences: [],
})
}
});
We would need a way to define this for the default api as well.
something like
import { api } from "@nitric/sdk";
api.withSecurity(...)
Also need to somehow invalidate the
make
cache or force a re-application or delay creation of the API resource.
Feature Request
Suggestion
Many applications only include a single API gateway, particularly when developers are learning the framework. To make this use case easier let's expose a 'default' API to reduce the need to create one in every app.
Functions would change from this:
To this:
Then, creating additional APIs could be performed by calling the api object (same as today):
Alternatively, if that's confusing or not possible we could add a
new
method, e.g.:Value
Should be less confusing for developers new to the framework and requires less code for the majority of projects that will only have a single API.