# EffectFactory

{% hint style="warning" %}
**Deprecation warning**

With an introduction of Marble.js 3.0, old `EffectFactory` HTTP route builder is deprecated. Please use[`r.pipe`](https://marblejs.gitbook.io/docs/v3/other/api-reference/core/r.pipe) builder instead.
{% endhint %}

## **Importing**

```typescript
import { EffectFactory } from '@marblejs/core';
```

## **`matchPath`**

`EffectFactory` namespace function. Matches request path for connected *Effect*.

### **Type declaration**

```typescript
matchPath :: string -> matchType
```

### **Parameters**

| *parameter* | definition |
| ----------- | ---------- |
| *path*      | `string`   |

### Returns

EffectFactory `matchType` function

## **`matchType`**

`EffectFactory` namespace function. Matches HTTP method type for connected *Effect*.

### **Type declaration**

```typescript
matchType :: HttpMethod -> use
```

### **Parameters**

| *parameter* | definition                                                                                                          |
| ----------- | ------------------------------------------------------------------------------------------------------------------- |
| *type*      | `HttpMethod = 'POST \| 'PUT' \| 'PATCH' \| 'GET' \| 'HEAD' \| 'DELETE' \| 'CONNECT' \| 'OPTIONS' \| 'TRACE' \| '*'` |

### Returns

EffectFactory *`use`* function

## **`use`**

`EffectFactory` namespace function. Connects *Effect* with path and HTTP method type.

### **Type declaration**

```typescript
use :: HttpEffect -> RouteEffect
```

### **Parameters**

| *parameter* | definition            |
| ----------- | --------------------- |
| *effect*    | `HttpEffect` function |

### Returns

Factorized `RouteEffect` object.

## Example

{% tabs %}
{% tab title="root.effect.ts" %}

```typescript
import { EffectFactory } from '@marblejs/core';
import { mapTo } from 'rxjs/operators';

export const root$ = EffectFactory
  .matchPath('/')
  .matchType('GET')
  .use(req$ => req$.pipe(
    mapTo({ body: `Hello, world! 👻` })
  ));
```

{% endtab %}
{% endtabs %}
