Skip to content

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 GET

Behaviors

  • 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-method option is not specified, it defaults to Get, if it is a Get it is a Query, otherwise it is a Command.
    • When GraphQL: Interprets the method name as Query or Mutation. Depending on which it resolves to the subfolder Query or Mutation, 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 the method option is not specified, it defaults to Query.
  • SingleLayer: Creates a single comprehensive endpoint file in the Endpoints/path folder containing request, response, configuration, and logic all in one file.

  • Microservices: You’d ideally do each microservice as if it were a SingleLayer project

`