Skip to content

Commit

Permalink
fix: stress that endpoint methods should be public
Browse files Browse the repository at this point in the history
This is based on direct user feedback. Ppl do not immediately realise that non-public endpoint methods are not exposed to TypeScript.

Related: https://github.com/vaadin/flow/issues/7681
  • Loading branch information
Viktor Lukashov committed Feb 11, 2021
1 parent 375a85d commit 31b574d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ layout: page
= Accessing Java Backend

A server-side Java endpoint is a back-end method that is exposed for calling from client-side TypeScript code.
An endpoint in Vaadin is a class that defines one or more API methods.
An endpoint in Vaadin is a class that defines one or more public methods.

Vaadin bridges Java backend endpoints and a TypeScript frontend. It generates
TypeScript clients to call the Java backend in a type-checkable way.
Expand Down
3 changes: 2 additions & 1 deletion articles/fusion/quick-start-tutorial.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ image::images/quickstart-running-1.png[Running project]
== Create a Typed Server Endpoint

One of the key features of Vaadin Fusion is type-safe server access through _endpoints_.
When you define an `@Endpoint`, Vaadin creates the needed REST-like endpoints, secures them, and generates TypeScript interfaces for all the used data types and methods.
When you define an `@Endpoint`, Vaadin creates the needed REST-like endpoints, secures them, and generates TypeScript interfaces for all the used data types and public methods.
Having full-stack type safety helps you stay productive through autocomplete and helps guard against accidental UI breakage when the data model changes on the server.

Create a new `TodoEndpoint.java` file in `src/main/java/com/example/application/data/endpoint`:
Expand Down Expand Up @@ -221,6 +221,7 @@ public class TodoEndpoint {
}
----
<1> Annotating a class with `@Endpoint` exposes it as a service for client-side views.
All *public* methods of an endpoint are callable from TypeScript.
<2> By default, endpoint access requires an authenticated user. `@AnonymousAllowed` enables access for anyone. See <<configuring-security,Configuring Security>> for more information on endpoint security.
<3> Use Spring to autowire the `TodoRepository` for database access.

Expand Down

0 comments on commit 31b574d

Please sign in to comment.