---
lang: en
title: 'API docs: rest.createroutesforcontroller'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/rest
permalink: /doc/en/lb4/apidocs.rest.createroutesforcontroller.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/rest](./rest.md) &gt; [createRoutesForController](./rest.createroutesforcontroller.md)

## createRoutesForController() function

Create routes for a controller with the given spec

**Signature:**

```typescript
export declare function createRoutesForController<T extends object>(spec: ControllerSpec, controllerCtor: ControllerClass<T>, controllerFactory?: ControllerFactory<T>): ControllerRoute<T>[];
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

spec


</td><td>

[ControllerSpec](./openapi-v3.controllerspec.md)


</td><td>

Controller spec


</td></tr>
<tr><td>

controllerCtor


</td><td>

[ControllerClass](./rest.controllerclass.md)<!-- -->&lt;T&gt;


</td><td>

Controller class


</td></tr>
<tr><td>

controllerFactory


</td><td>

[ControllerFactory](./rest.controllerfactory.md)<!-- -->&lt;T&gt;


</td><td>

_(Optional)_ Controller factory


</td></tr>
</tbody></table>
**Returns:**

[ControllerRoute](./rest.controllerroute.md)<!-- -->&lt;T&gt;\[\]


