UNPKG

@sauce-api/core

Version:

Sauce API core functionality

25 lines (24 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Controller = void 0; const Responses_1 = require("./Responses"); /** * Controllers are the brain of your routes. Every route must have a controller & a controller action. This is where your controller actions live for their respective route(s). * * File Naming Convention * * By default, Sauce expects a specific naming convention for your controllers. For example, let's say you created a route and specified a controller of example for a route of GET /some-route. When that route gets hit, Sauce will look in the configured controller directory (see Sauce Config) for a controller named example.controller.<CONFIGURED EXTENSION> (based on your configured file extension, again see Sauce Config) * However you can override that naming convention by specify a specific controller with customControllerPath in your route (see Routes) */ class Controller { constructor(Sauce) { this.Sauce = Sauce; this.req = Sauce.req; this.currentRoute = Sauce.currentRoute; this.res = Sauce.res; this.next = Sauce.next; this.config = Sauce.config; this.responses = new Responses_1.Responses(this.res); } } exports.Controller = Controller;