<commit_before>import Instrumentation from '../metal/instrumentation';
import Model from '../data/model';
import Response from './response';
import * as http from 'http';
import * as createDebug from 'debug';
import {
  assign,
  capitalize,
  isArray,
  uniq,
  flatten,
  compact,
  map
} from 'lodash';
import * as assert from 'assert';
import eachPrototype from '../metal/each-prototype';
import DenaliObject from '../metal/object';
import Request from './request';
import Logger from './logger';
import Container from './container';
import Service from './service';
import Errors from './errors';
import Serializer from '../data/serializer';

const debug = createDebug('denali:action');

/**
 * An error used to break the chain of promises created by running filters. Indicates that a before
 * filter returned a value which will be rendered as the response, and that the remaining filters
 * and the responder method should not be run.
 */
class PreemptiveRender {}
PreemptiveRender.prototype = Object.create(Error.prototype);
PreemptiveRender.prototype.constructor = PreemptiveRender;

export interface ActionOptions {
  request: Request;
  response: http.ServerResponse;
  logger: Logger;
  container: Container;
}

interface Responder {
  (params: any): Response | { [key: string]: any } | void;
}

/**
 * Actions form the core of interacting with a Denali application. They are the controller layer in
 * the MVC architecture, taking in incoming requests, performing business logic, and handing off to
 * the renderer to send the response.
 *
 * When a request comes in, Denali will invoke the `respond` method (or `respondWith__` for content
 * negotiated requests) on the matching Action class. The return value (or resolved return value) of<commit_msg>refactor: use TS host object subclass support<commit_after>import Instrumentation from '../metal/instrumentation';
import Model from '../data/model';
import Response from './response';
import * as http from 'http';
import * as createDebug from 'debug';
import {
  assign,
  capitalize,
  isArray,
  uniq,
  flatten,
  compact,
  map
} from 'lodash';
import * as assert from 'assert';
import eachPrototype from '../metal/each-prototype';
import DenaliObject from '../metal/object';
import Request from './request';
import Logger from './logger';
import Container from './container';
import Service from './service';
import Errors from './errors';
import Serializer from '../data/serializer';

const debug = createDebug('denali:action');

/**
 * An error used to break the chain of promises created by running filters. Indicates that a before
 * filter returned a value which will be rendered as the response, and that the remaining filters
 * and the responder method should not be run.
 */
class PreemptiveRender extends Error {
  public response: Response;
  constructor(response: Response) {
    super();
    this.response = response;
  }
}

export interface ActionOptions {
  request: Request;
  response: http.ServerResponse;
  logger: Logger;
  container: Container;
}

interface Responder {
  (params: any): Response | { [key: string]: any } | void;
}

/**
 * Actions form the core of interacting with a Denali application. They are the controller layer in
 * the MVC architecture, taking in incoming requests, performing business logic, and handing off to
 * the renderer to send the response.
 *
 * When a request comes in, Denali will invoke the `respond` method (or `respondWith__` for content
 * negotiated requests) on the matching Action class. The return value (or resolved return value) of
{'fraction_non_alphanumeric': 0.09778649481647521, 'fraction_numerical': 0.0, 'mean_word_length': 4.384615384615385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7209709', 'n_tokens_mistral': 931, 'n_tokens_neox': 908, 'n_words': 421}