You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
import{api}from"@nitric/sdk";consthelloApi=api('main');helloApi.get("/hello/:name",async(ctx)=>{const{ name }=ctx.req.params;ctx.res.body=`Hello ${name}`;});
To this:
import{api}from"@nitric/sdk";api.get("/hello/:name",async(ctx)=>{const{ name }=ctx.req.params;ctx.res.body=`Hello ${name}`;});
Then, creating additional APIs could be performed by calling the api object (same as today):
constmain=api('main');
Alternatively, if that's confusing or not possible we could add a new method, e.g.:
constmain=api.new('main');
Note: this would be a breaking change.
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: