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

<b>Signature:</b>

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

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  spec | [ControllerSpec](./openapi-v3.controllerspec.md) | Controller spec |
|  controllerCtor | [ControllerClass](./rest.controllerclass.md)<!-- -->&lt;T&gt; | Controller class |
|  controllerFactory | [ControllerFactory](./rest.controllerfactory.md)<!-- -->&lt;T&gt; | <i>(Optional)</i> Controller factory |

<b>Returns:</b>

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


