> This page is for Applications Protection.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.humansecurity.com/llms.txt.

# API

## createHumanSecurityHandler()

An out-of-the box handler with the HUMAN Enforcer returns a default Express middleware function with built-in HUMAN enforcement.

```typescript
createEnforcedRequestHandler(config: HumanSecurityConfiguration) => RequestHandler
```

* Parameters
  * config: HumanSecurityConfiguration
* Returns a default HTTP request handler function in the form of (request: [Express Request](https://expressjs.com/en/api.html#req), response: [Express Response](https://expressjs.com/en/api.html#res), next: NextFunction) => `Promise<`Response`>`

## HumanSecurityEnforcer

The entity responsible for performing HUMAN enforcement.

### constructor

Creates a new HumanSecurityEnforcer instance from a HumanSecurityConfiguration object (see the configuration section for more information).

```typescript
constructor(configuration: HumanSecurityConfiguration) => HumanSecurityEnforcer
```

* Parameters
  * config: HumanSecurityConfiguration
* Returns a new instance of the HumanSecurityEnforcer

### enforce()

Executes the enforcement functionality, returning either a response or null depending on which action should be taken.

```typescript
enforce(request: Request, response: Response) => Promise<Response | null>
```

* Parameters
  * request: [Express Request](https://expressjs.com/en/api.html#req)
  * response: [Express Response](https://expressjs.com/en/api.html#res)
* Returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) resolving to an [Express Response](https://expressjs.com/en/api.html#res) or null

### postEnforce()

Performs any post-enforcement processing actions such as sending HUMAN data to the collector.

```typescript
postEnforce(request: Request, response: Response) => Promise<void>
```

* Parameters
  * request: [Express Request](https://expressjs.com/en/api.html#req)
  * response: [Express Response](https://expressjs.com/en/api.html#res)
* Returns: void