Skip to content

Commit 01761f7

Browse files
committed
docs: update use of glob patterns in docs
1 parent af0cdf8 commit 01761f7

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

@@ -1086,10 +1087,12 @@ Also you can load middlewares from directories. Also you can use glob patterns:
10861087

10871088
```typescript
10881089
import { createExpressServer } from 'routing-controllers';
1090+
import path from 'path';
1091+
10891092
createExpressServer({
1090-
controllers: [__dirname + '/controllers/**/*.js'],
1091-
middlewares: [__dirname + '/middlewares/**/*.js'],
1092-
interceptors: [__dirname + '/interceptors/**/*.js'],
1093+
controllers: [path.join(__dirname, '/controllers/**/*.js')],
1094+
middlewares: [path.join(__dirname, '/middlewares/**/*.js')],
1095+
interceptors: [path.join(__dirname, '/interceptors/**/*.js')],
10931096
}).listen(3000);
10941097
```
10951098

@@ -1382,16 +1385,17 @@ Here is example how to integrate routing-controllers with [typedi](https://githu
13821385
```typescript
13831386
import { createExpressServer, useContainer } from 'routing-controllers';
13841387
import { Container } from 'typedi';
1388+
import path from 'path';
13851389

13861390
// its important to set container before any operation you do with routing-controllers,
13871391
// including importing controllers
13881392
useContainer(Container);
13891393

13901394
// create and run server
13911395
createExpressServer({
1392-
controllers: [__dirname + '/controllers/*.js'],
1393-
middlewares: [__dirname + '/middlewares/*.js'],
1394-
interceptors: [__dirname + '/interceptors/*.js'],
1396+
controllers: [path.join(__dirname, '/controllers/*.js')],
1397+
middlewares: [path.join(__dirname, '/middlewares/*.js')],
1398+
interceptors: [path.join(__dirname, '/interceptors/*.js')],
13951399
}).listen(3000);
13961400
```
13971401

0 commit comments

Comments
 (0)