Quick Example
This page will guide you through a quick example of a Mandarine-powered application
Step I: Installing Deno
Shell (Mac, Linux):
curl -fsSL https://deno.land/x/install/install.sh | shPowerShell (Windows):
iwr https://deno.land/x/install/install.ps1 -useb | iexStep II: Example file
import { Controller, Service, GET, Session, MandarineCore } from "https://deno.land/x/mandarinets/mod.ts";
@Service()
export class MyService {
public sayARandomName(): string {
let names: Array<string> = ["Andres", "Maureen", "Elsa"];
return names[Math.floor(Math.random() * names.length)];
}
}
@Controller()
export class MyController {
constructor(private readonly myService: MyService){}
@GET('/hello-world')
public helloWorld(@Session() session: any) {
if(session.times == undefined) session.times = 0;
session.times++;
return `Hello World number #${session.times} (Yes, there are multiple universes)`;
}
@GET('/say-hi')
public sayHi() {
return `Hello <b>${this.myService.sayARandomName()}</b> from a randomly method.`;
}
}
new MandarineCore().MVC().run();Step III: Running your file
tsconfig.json
Note
Last updated