Skip to content

API Applet

Michael Anderson edited this page Dec 1, 2017 · 1 revision

CoffeeCat API - Applet Class

An applet class extends the coffeecat-applet class. The coffeecat-applet class modifies the request object.

Properties

app

Type: Express.Application

Returns the express application for the container. This is used by the server to associate the application with the path.

configuration

Type: applet_configuration

Returns the configuration for this applet.

Methods

setViewEngine(engine: string): void

engine: The module name for the template engine to use.

Equivalent to this.app.set('view engine', engine); from Express

setViewPath(root: string): void

path: The path to search for templates.

Equivalent to this.app.set('views', root); from Express

setStaticContentPath(root: string, config: express.static-options): void

root: The path to search for static content config: express.static-options

Equivalent to this.app.use(express.static(root, config)); from Express

setSession(engine: string, ...args: any): void

engine: The module name for the session engine to use. args: Additional arguments to pass to the session engine.

Equivalent to this.app.use(_engine_(_args_));.

Example

this.setSession('express-session', {
    secret: '95f0d5bd-b3aa-482d-8469-b6ee04776d8a',
    resave: false,
    saveUninitialized: true,
    cookie: { 
        secure: true,
        path: this.configuration.applet.container
    }
});

Clone this wiki locally