Skip to content

Commit a79e027

Browse files
Lucas Mendes LoureiroLucasMendesl
authored andcommitted
fix: problem when controller file is empty
1 parent 3039b83 commit a79e027

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ Before putting the application to run, it is necessary to re-bind the controller
102102

103103
```js
104104

105-
const express = require('express')
106-
const cors = require('cors')
107-
const useControllers = require('express-decorator-router/register')
105+
const express = require('express')
106+
const cors = require('cors')
107+
const { useControllers } = require('express-decorator-router')
108108

109109
const app = express()
110110
const router = express.Router()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": false,
33
"name": "express-decorator-router",
4-
"version": "0.1.0",
4+
"version": "0.1.1",
55
"description": "use decorators in a simple way without transpiling javascript code",
66
"main": "src/index.js",
77
"scripts": {

src/register.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const isPromise = obj => !!obj && (isObject(obj) || isFunction(obj)) && isFuncti
1818
* @returns This method returns a configured router object
1919
* @example
2020
*
21-
* const express = require('express')
22-
* const cors = require('cors')
23-
* const useControllers = require('express-decorator-router/register')
21+
* const express = require('express')
22+
* const cors = require('cors')
23+
* const { useControllers } = require('express-decorator-router')
2424
*
2525
* const app = express()
2626
* const router = express.Router()
@@ -59,7 +59,8 @@ module.exports = function useControllers (configuration = {}) {
5959
? new ApplicationController()
6060
: ApplicationController
6161

62-
return instance.$routes.reduce((server, {
62+
const routes = instance.$routes || []
63+
return routes.reduce((server, {
6364
httpMethod,
6465
endpointFn,
6566
actionPath,

0 commit comments

Comments
 (0)