# EffectFactory

## **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

{% code title="root.effect.ts" %}

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

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

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://marblejs.gitbook.io/docs/v2/api-reference/core/core-effectfactory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
