https://github.com/cludden/sails-hook-nested-services
sails hook for loading services defined in subdirectories
https://github.com/cludden/sails-hook-nested-services
Last synced: 9 months ago
JSON representation
sails hook for loading services defined in subdirectories
- Host: GitHub
- URL: https://github.com/cludden/sails-hook-nested-services
- Owner: cludden
- License: mit
- Created: 2016-01-07T00:34:31.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-07T15:30:45.000Z (over 10 years ago)
- Last Synced: 2025-04-08T13:51:50.304Z (over 1 year ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# sails-hook-nested-services
a `sails.js` hook for loading services defined in subdirectories.
## Install
```javascript
npm install --save sails-hook-nested-services
```
## Purpose
By default, sails only loads top level services. This hook provides functionality for loading nested services.
```javascript
// in /api/services/path/to/service.js
module.exports = {
sayHello: function() {
sails.log.silly('Hello!');
}
};
// and then in one of your controllers
module.exports = {
action: function(req, res) {
sails.services['path/to/service'].sayHello();
res.ok();
}
}
```
## Testing
run all tests
```javascript
npm test
```
run coverage
```javascript
grunt coverage
```
## Contributing
1. [Fork it](https://github.com/cludden/sails-hook-nested-services/fork)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## License
Copyright (c) 2016 Chris Ludden.
Licensed under the [MIT license](LICENSE.md).