Share My Creation [Project Template] [Web] EndsMeet (beta)

1702901104235.png
1702901075840.png
1702901125557.png


Here is a beta version of EndsMeet, an MVC framework to develop web application in B4X using B4J IDE.
It depends on jServer and JSON libraries.
It can be easily extended with template library such as Velocity or HTMX Freemarker and database library like MiniORM and so on.
Note: This is a B4J project template. Add the attached template to B4J additional library folder and create a new project from the IDE.
 

Attachments

  • EndsMeet (0.06).b4xtemplate
    8.4 KB · Views: 65
Last edited:

aeric

Expert
Licensed User
Longtime User
A short tutorial to add a new api.

Modify to the following code.

HelloController:
Public Sub RouteApi
    Select Request.Method
        Case "GET"
            Dim RequestMap As Map = EndsMeetUtils.GetRequestElements(Request.RequestURI, Main.BaseElements)
            If RequestMap.ContainsKey("First") Then
                Dim Person As String = RequestMap.Get("First")
                GetGreet(Person)
            Else
                GetJSON
            End If
        Case Else
            Log("Unsupported method: " & Request.Method)
            EndsMeetUtils.ReturnMethodNotAllow(HRM, Response)
    End Select
End Sub

Private Sub GetGreet (Name As String)
    #region Documentation
    ' #Version = v1
    ' #Desc = Return greeting message
    #End region
    Model.ReturnGreetingApi(Name)
End Sub

HelloModel:
Public Sub ReturnGreetingApi (Person As String)
    Dim m1 As Map
    m1.Initialize
    m1.Put("greeting", $"Merry Xmas, ${Person}!"$)
    HRM.ResponseObject = m1
    EndsMeetUtils.ReturnHttpResponse(HRM, Response)
End Sub

IndexView:
Public Sub Render
    Dim strHtml As String = $"<center>
        <a href="${Main.ROOT_PATH}hello">Go to Hello page</a><br/>
        <p><a href="${Main.ROOT_PATH}api/v1/hello">Get Hello API</a></p>
        <p><a href="${Main.ROOT_PATH}api/v1/hello/B4X">Get Greeting API</a></p>
        </center>"$
    EndsMeetUtils.ReturnHtml(strHtml, Response)
End Sub

Note: This example doesn't check for api version.

1702903113058.png
 
Top