Skip to content

Commit

Permalink
Merge pull request #731 from vedraan/patch-1
Browse files Browse the repository at this point in the history
docs: Update use of glob patterns in docs in README.md
  • Loading branch information
jotamorais authored Aug 4, 2021
2 parents 8fae22a + 01761f7 commit f4fe9f1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,10 @@ You can load all controllers from directories, by specifying array of directorie

```typescript
import { createExpressServer } from 'routing-controllers';
import path from 'path';
createExpressServer({
controllers: [__dirname + '/controllers/*.js'],
controllers: [path.join(__dirname + '/controllers/*.js')],
}).listen(3000); // register controllers routes in our express application
```

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

```typescript
import { createExpressServer } from 'routing-controllers';
import path from 'path';
createExpressServer({
controllers: [__dirname + '/controllers/**/*.js'],
middlewares: [__dirname + '/middlewares/**/*.js'],
interceptors: [__dirname + '/interceptors/**/*.js'],
controllers: [path.join(__dirname, '/controllers/**/*.js')],
middlewares: [path.join(__dirname, '/middlewares/**/*.js')],
interceptors: [path.join(__dirname, '/interceptors/**/*.js')],
}).listen(3000);
```

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

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

// create and run server
createExpressServer({
controllers: [__dirname + '/controllers/*.js'],
middlewares: [__dirname + '/middlewares/*.js'],
interceptors: [__dirname + '/interceptors/*.js'],
controllers: [path.join(__dirname, '/controllers/*.js')],
middlewares: [path.join(__dirname, '/middlewares/*.js')],
interceptors: [path.join(__dirname, '/interceptors/*.js')],
}).listen(3000);
```

Expand Down

0 comments on commit f4fe9f1

Please sign in to comment.