diff --git a/API.md b/API.md index 42fe04f..4e44500 100644 --- a/API.md +++ b/API.md @@ -193,6 +193,20 @@ Here's the complete rundown of how files and directories are mapped to API calls - **`cookies/index.js`** - export an array of objects. - **`cookies/cookie-name.js`** - export an object. The `name` will be assigned `'cookie-name'` from the filename if it isn't already specified. +#### Events +> [`server.event(events)`](https://github.com/hapijs/hapi/blob/master/API.md#servereventevents) + + - **`event/definitions.js`** - export an array of objects `{ name, options }`. + - **`event/definitions/index.js`** - export an array of objects. + - **`event/definitions/event-name.js`** - export `event` object. + +#### Event Listeners +> [`server.on(criteria, listener)`](https://github.com/hapijs/hapi/blob/master/API.md#serveroncriteria-listener) + + - **`event/listeners.js`** - export an array of objects `{ name, options }`. + - **`event/listeners/index.js`** - export an array of objects. + - **`event/listeners/listener-name.js`** - export `listener` object. + #### Model definitions (for [schwifty](https://github.com/BigRoomStudios/schwifty)) > [`server.schwifty(config)`](https://github.com/BigRoomStudios/schwifty/blob/master/API.md#serverschwiftyconfig) diff --git a/lib/manifest.js b/lib/manifest.js index 033a1c7..53fc6fe 100644 --- a/lib/manifest.js +++ b/lib/manifest.js @@ -290,6 +290,20 @@ internals.manifest = [ list: true, useFilename: internals.passthruOn('name') }, + { + place: 'event/definitions', + method: 'event', + list: true, + useFilename: internals.passthruOn('name') + }, + { + place: 'event/listeners', + method: 'on', + signature: ['criteria', 'listener'], + list: true, + useFilename: internals.passthruOn('name'), + after: ['event/definitions'] + }, { // Schwifty models place: 'models', method: 'schwifty', diff --git a/test/closet/event/definitions/test-definition.js b/test/closet/event/definitions/test-definition.js new file mode 100644 index 0000000..e57578c --- /dev/null +++ b/test/closet/event/definitions/test-definition.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + name: 'test-event' +} diff --git a/test/index.js b/test/index.js index 3294c49..c9fe201 100644 --- a/test/index.js +++ b/test/index.js @@ -455,6 +455,16 @@ describe('HauteCouture', () => { done(); }); + it('defines event definitions in event/definitions/.', (done) => { + + done(); + }); + + it('defines event listeners in event/listeners/.', (done) => { + + done(); + }); + it('defines schwifty models in models/.', (done) => { const models = bigServer.models(true);