Skip to content

Commit f4fe9f1

Browse files
authored
Merge pull request #731 from vedraan/patch-1
docs: Update use of glob patterns in docs in README.md
2 parents 8fae22a + 01761f7 commit f4fe9f1

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

README.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,10 @@ You can load all controllers from directories, by specifying array of directorie
318318

319319
```typescript
320320
import { createExpressServer } from 'routing-controllers';
321+
import path from 'path';
321322

322323
createExpressServer({
323-
controllers: [__dirname + '/controllers/*.js'],
324+
controllers: [path.join(__dirname + '/controllers/*.js')],
324325
}).listen(3000); // register controllers routes in our express application
325326
```
326327

@@ -1113,10 +1114,12 @@ Also you can load middlewares from directories. Also you can use glob patterns:
11131114

11141115
```typescript
11151116
import { createExpressServer } from 'routing-controllers';
1117+
import path from 'path';
1118+
11161119
createExpressServer({
1117-
controllers: [__dirname + '/controllers/**/*.js'],
1118-
middlewares: [__dirname + '/middlewares/**/*.js'],
1119-
interceptors: [__dirname + '/interceptors/**/*.js'],
1120+
controllers: [path.join(__dirname, '/controllers/**/*.js')],
1121+
middlewares: [path.join(__dirname, '/middlewares/**/*.js')],
1122+
interceptors: [path.join(__dirname, '/interceptors/**/*.js')],
11201123
}).listen(3000);
11211124
```
11221125

@@ -1409,16 +1412,17 @@ Here is example how to integrate routing-controllers with [typedi](https://githu
14091412
```typescript
14101413
import { createExpressServer, useContainer } from 'routing-controllers';
14111414
import { Container } from 'typedi';
1415+
import path from 'path';
14121416

14131417
// its important to set container before any operation you do with routing-controllers,
14141418
// including importing controllers
14151419
useContainer(Container);
14161420

14171421
// create and run server
14181422
createExpressServer({
1419-
controllers: [__dirname + '/controllers/*.js'],
1420-
middlewares: [__dirname + '/middlewares/*.js'],
1421-
interceptors: [__dirname + '/interceptors/*.js'],
1423+
controllers: [path.join(__dirname, '/controllers/*.js')],
1424+
middlewares: [path.join(__dirname, '/middlewares/*.js')],
1425+
interceptors: [path.join(__dirname, '/interceptors/*.js')],
14221426
}).listen(3000);
14231427
```
14241428

0 commit comments

Comments
 (0)