generate endpoint
The generate endpoint command adds endpoint components to an existing Apiand project.
Usage
apiand generate endpoint <name> [options]Options
| Option | Alias | Description | Required | Example |
|---|---|---|---|---|
--method | -m | Method for REST (Get, Post, Put, Patch, Delete) or GraphQL (Query, Mutation) | No | --http-method Get |
Examples
Generate a endpoint with HTTP methods:
apiand generate endpoint User --http-method GETBehaviors
-
DDD:- When
FastEndpoints: Generates the fast endpoint class with the specified HTTP method in the Presentation layer, and a request and response model in the Application layer, and a request handler in the Application layer, following the CQRS pattern with MediatR. If the--http-methodoption is not specified, it defaults toGet, if it is aGetit is aQuery, otherwise it is aCommand. - When
GraphQL: Interprets the method name as Query or Mutation. Depending on which it resolves to the subfolderQueryorMutation, following the same approach as the other one. The request and response models are generated in the Application layer, and the request handler is generated in the Application layer, following the CQRS pattern with MediatR. If themethodoption is not specified, it defaults toQuery.
- When
-
SingleLayer: Creates a single comprehensive endpoint file in theEndpoints/pathfolder containing request, response, configuration, and logic all in one file. -
Microservices: You’d ideally do each microservice as if it were aSingleLayerproject
`