> For the complete documentation index, see [llms.txt](https://mantou.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mantou.gitbook.io/docs/guard.md).

# Guard

Api route protector

```typescript
import { guard, handler, t, type Store } from 'mantou/routes'

const auth = (roles: string[]) => guard(async () => {
  console.log('Auth guard: ', roles);
  return true // return boolean only
})
```

### Example usage

```typescript
export const post = handler(() => {
  return "Update Something";
}, {}, [
auth(["buyer"])
])
```
