These page summarizes basic concepts of running a Mandarine-powered web application.
Main
A Mandarine-powered web application uses all the different core across Mandarine.TS, making your application rich in functionalities. In order to run your mandarine-powered web app, you must locate the following code at the end of your file.
new MandarineCore().MVC.run() should always be the last line of your file, as nothing after such statement will be executed. This is important to know since for things such as setting your own configuration, those statements must be above new MandarineCore().MVC().run() .
Run options
You can pass a port and hostname to the method run .
Note that both port and hostname are optional, however, if they are declared, they will override the default values or the values loaded from your properties file.
Single entry-point file
Almost all web applications will have multiple files distributed across multiple folders, although, only one file can be executed at the time. In order to unify all your components, controllers, and others, into one single file, you must have a mandarine single entry-point file, which is just a structure where your will import all your modules in order to make mandarine compile them.
Click here to see more information about single-entry point files
Files
service1.tsimport { Service } from"https://deno.land/x/mandarinets/mod.ts";@Service()exportclassMyService {publicpiValue():number {return3.14; }}
controller1.tsimport { Controller, GET } from"https://deno.land/x/mandarinets/mod.ts";import { MyService } from"./service1.ts";@Controller()exportclassMyController1 {constructor(privatereadonly service:MyService) {} @GET('/first-endpoint')publichttpHandler() {return`Hello world from MyController1. <br> The value of PI is ${this.service.piValue()}`; }}
controller2.tsimport { Controller, GET } from"https://deno.land/x/mandarinets/mod.ts";@Controller()exportclassMyController2 { @GET('/second-endpoint')publichttpHandler() {return`Hello world from MyController2`; }}
GET/first-endpointHTTP/1.1Host:127.0.0.1:8080# Hello world from MyController1. <br> The value of PI is 3.14##GET/second-endpointHTTP/1.1Host:127.0.0.1:8080# Hello world from MyController2