diff --git a/src/main/java/com/hithomelabs/CFTunnels/Entity/Mapping.java b/src/main/java/com/hithomelabs/CFTunnels/Entity/Mapping.java index 113f740..e89f674 100644 --- a/src/main/java/com/hithomelabs/CFTunnels/Entity/Mapping.java +++ b/src/main/java/com/hithomelabs/CFTunnels/Entity/Mapping.java @@ -6,9 +6,29 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; - import java.util.UUID; +/** + * JPA Entity representing an ingress mapping configuration for a Cloudflare Tunnel. + * + *
A mapping defines how incoming traffic should be routed through the tunnel + * to your internal services. It specifies the protocol, port, and subdomain + * where the service will be accessible.
+ * + *Database Table: {@code mappings}
+ * + *Example Usage:
+ *
+ * Mapping mapping = new Mapping();
+ * mapping.setPort(8080);
+ * mapping.setProtocol(Protocol.HTTP);
+ * mapping.setSubdomain("api");
+ *
+ *
+ * @see Tunnel
+ * @see Protocol
+ * @see Request
+ */
@Entity
@Getter
@Setter
@@ -17,22 +37,50 @@ import java.util.UUID;
@Table(name = "mappings")
public class Mapping {
+ /**
+ * Unique identifier for this mapping (auto-generated UUID).
+ */
@Id
@GeneratedValue
@Column(columnDefinition = "uuid", nullable = false, unique = true)
private UUID id;
+ /**
+ * Port number where the internal service is running.
+ *
+ * Example: 8080 for a Spring Boot application's default port.
+ */ @Column(nullable = false) private int port; + /** + * Protocol used for the connection. + * + *Supported values: HTTP, HTTPS, TCP, SSH
+ * @see Protocol + */ @Enumerated(EnumType.STRING) @Column(length = 10, nullable = false) private Protocol protocol; + /** + * Subdomain prefix for accessing this service. + * + *Example: "api" would make the service available at + * {@code api.yourdomain.com}
+ */ @Column(length = 50, nullable = false) private String subdomain; + /** + * The tunnel this mapping is associated with. + * + *Each mapping belongs to exactly one tunnel. + * This is a lazy-loaded relationship to optimize performance.
+ * + * @see Tunnel + */ @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "tunnel_id", nullable = false) private Tunnel tunnel; -} +} \ No newline at end of file