Skip to content

Commit

Permalink
Merge pull request #39 from michaelhue/caches-before-plugins
Browse files Browse the repository at this point in the history
Register caches before plugins
  • Loading branch information
devinivy committed Apr 16, 2018
2 parents 2a063d6 + 45f5c2a commit 7ae438b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
14 changes: 7 additions & 7 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ Here's the complete rundown of how files and directories are mapped to API calls
- **`path.js`** - export `relativeTo`.
- **`path/index.js`** - export `relativeTo`.

#### Plugin registrations
> [`await server.register(plugins, [options])`](https://github.com/hapijs/hapi/blob/master/API.md#server.register())
- **`plugins.js`** - export an array of objects `{ plugins, options }`.
- **`plugins/index.js`** - export an array of objects.
- **`plugins/plugin-name.js`** - export an object. If a plugin isn't specified in `plugins` it will be `require()`d using the filename.

#### Provisioning caches
> [`await server.cache.provision(options)`](https://github.com/hapijs/hapi/blob/master/API.md#server.cache.provision())
- **`caches.js`** - export an array of `options`.
- **`caches/index.js`** - export an array of `options`.
- **`caches/some-cache-name.js`** - export `options`. The cache's `options.name` will be assigned `'cache-name'` from the filename if a name isn't already specified.

#### Plugin registrations
> [`await server.register(plugins, [options])`](https://github.com/hapijs/hapi/blob/master/API.md#server.register())
- **`plugins.js`** - export an array of objects `{ plugins, options }`.
- **`plugins/index.js`** - export an array of objects.
- **`plugins/plugin-name.js`** - export an object. If a plugin isn't specified in `plugins` it will be `require()`d using the filename.

#### View manager (for [vision](https://github.com/hapijs/vision))
> [`server.views(options)`](https://github.com/hapijs/vision/blob/master/API.md#serverviewsoptions)
Expand Down
23 changes: 12 additions & 11 deletions lib/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ internals.manifest = [
list: false,
after: ['services']
},
{
place: 'caches',
method: 'cache.provision',
async: true,
list: true,
useFilename: internals.passthruOn('name'),
example: {
engine: null,
name: ''
}
},
{
place: 'plugins',
method: 'register',
Expand All @@ -142,6 +153,7 @@ internals.manifest = [

return value;
},
after: ['caches'],
example: {
plugins: { $value: [], $comment: 'May be an array or a single plugin' },
options: { $value: {}, $comment: 'Optional' }
Expand All @@ -159,17 +171,6 @@ internals.manifest = [
after: { $value: async (server) => {}, $comment: 'Optional' }
}
},
{
place: 'caches',
method: 'cache.provision',
async: true,
list: true,
useFilename: internals.passthruOn('name'),
example: {
engine: null,
name: ''
}
},
{
place: 'methods',
method: 'method',
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ describe('HauteCouture', () => {

expect(summary).to.equal([
'path() at path',
'register() at plugins',
'cache.provision() at caches',
'register() at plugins',
'views() at view-manager',
'decorate() at decorations',
'expose() at expose',
Expand Down Expand Up @@ -479,8 +479,8 @@ describe('HauteCouture', () => {

expect(summary).to.equal([
'path() at path',
'register() at plugins',
'cache.provision() at caches',
'register() at plugins',
'views() at view-manager',
'decorate() at decorations',
'expose() at expose',
Expand Down

0 comments on commit 7ae438b

Please sign in to comment.