# Agent v2 - How to override the default routes?

**URL:** <https://community.forestadmin.com/t/agent-v2-how-to-override-the-default-routes/4777>\
**Category:** Help me!\
**Created:** [June 8, 2022, 2:35pm UTC](https://community.forestadmin.com/t/agent-v2-how-to-override-the-default-routes/4777 "2022-06-08T14:35:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Martin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/justin_martin/32/1028_2.png) [@Justin\_Martin](https://community.forestadmin.com/u/Justin_Martin)\
**Post date:** [June 8, 2022, 2:35pm UTC](https://community.forestadmin.com/t/agent-v2-how-to-override-the-default-routes/4777/1 "2022-06-08T14:35:10Z")

</div>

Hello,

I’m trying to know if it’s possible to override the default route, as exemple update of a collection.

agent-version: node-v2 =\> [Forest Admin - [Beta] Developer guide (agents v2)](https://docs.forestadmin.com/beta-developer-guide-agents-v2/)

---

<div class="post-metadata">

**Author:** ![anon39940173](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@anon39940173](https://community.forestadmin.com/u/anon39940173)\
**Post date:** [June 8, 2022, 3:11pm UTC](https://community.forestadmin.com/t/agent-v2-how-to-override-the-default-routes/4777/2 "2022-06-08T15:11:18Z")

</div>

The new NodeJS implementation won’t support route overrides.

There are many reasons for that, the main one being that letting customers interact with low-level requests caused changes on our end to break customer code more often than we would like.

Instead multiple features are planned to fill the same need.

We’re working hard to release and document them as fast as possible, now that the new agent is publicly announced and a Beta is available.

### [not released] Hooks

```javascript
collection.addHook('List', (context, flow) => {
  return flow.continue()
});

```

Hooks is the lowest level feature that the new agents will have.  
They allow to change behaviors in a controlled way.

### [undocumented] Write overrides

```javascript
collection.replaceWrite('aFieldName', value => {
  return { aFieldName: btoa(value) };
})

```

Write overrides allow to override the action that is performed when a given field is modified.

### [not released] Validators

```javascript
collection.addFieldValidation('aFieldName', 'GreaterThan', 4)

```

```javascript
collection.addRelationValidation('someRelation', async (context) => {
  return {
    field: 'author:country:name',
    operator: 'Equal',
    value: 'France'
  }
});

```

This feature allows to add validation both in the frontend and agent for a list of preset conditions on specific fields.

---

<div class="post-metadata">

**Author:** ![Justin\_Martin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/justin_martin/32/1028_2.png) [@Justin\_Martin](https://community.forestadmin.com/u/Justin_Martin)\
**Post date:** [June 8, 2022, 3:29pm UTC](https://community.forestadmin.com/t/agent-v2-how-to-override-the-default-routes/4777/3 "2022-06-08T15:29:07Z")

</div>

so with you’re exemple we going to have something like :

```javascript
collection.addHook('Update', (context, flow) => {
  return flow.continue()
});

```

Is the field validation is are already check or only if the field changed ?

---

<div class="post-metadata">

**Author:** ![anon39940173](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@anon39940173](https://community.forestadmin.com/u/anon39940173)\
**Post date:** [June 8, 2022, 3:50pm UTC](https://community.forestadmin.com/t/agent-v2-how-to-override-the-default-routes/4777/4 "2022-06-08T15:50:23Z")

</div>

It is difficult to reply to that last question: hooks are being designed/developed as we speak, so I can’t know for sure.

What I can tell is that

- Once they are released they will be documented
- Methods will be available to raise validation and permission errors from them before any action is performed on the backends which are plugged into the agent
