@ResponseView() or @Render() is a decorator that can be used on a controller method (endpoint). This decorator will use the response return by the method and will use the view to create the output.



This example use EJS as engine rendering. To use other engine, see the documentation of the concerned project.

import Path = require("path");
const rootDir = Path.resolve(__dirname);

   mount: {
      '/rest': `${rootDir}/controllers/**/**.js`
   componentsScan: [
class Server extends ServerLoader {

    async $onMountingMiddlewares()  {

        const cookieParser = require('cookie-parser'),
            bodyParser = require('body-parser'),
            compress = require('compression'),
            methodOverride = require('method-override'),
            session = require('express-session');

                extended: true

        // EJS Engine Setting
        this.engine('.html', require('ejs').__express)
            .set('views', './views')
            .set('view engine', 'html');

The configuration engine is exactly the same as Express configuration engine.

Use decorator

export class EventCtrl {

    public get(request: Express.Request, response: Express.Response): any {
        return {startDate: new Date(), name: "MyEvent"};

@Render() is an alias of @ResponseView().

Create your template


<h1><%- name %></h1>
    Start: <%- startDate %>