https://github.com/makeomatic/restify-utils
Convenience methods for Restify HTTP server
https://github.com/makeomatic/restify-utils
Last synced: 7 months ago
JSON representation
Convenience methods for Restify HTTP server
- Host: GitHub
- URL: https://github.com/makeomatic/restify-utils
- Owner: makeomatic
- License: mit
- Created: 2015-11-23T12:19:27.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-04-28T20:45:19.000Z (almost 9 years ago)
- Last Synced: 2025-02-05T15:51:30.792Z (about 1 year ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Restify Utils
## Install
`npm i restify-utils -S`
## Usage
### Main function
`const attach = require('restify-utils')(configuration, endpointsDir, middlewareDir)`
returns Function:
1. Function(server, family, prefix = '/api') with extra properties:
2. endpoints
3. middleware
Populates `configuration.models`
Goes through endpoints, that are in format of the following:
```js
exports.VERB = {
path: '/path/relative/to/prefix/family',
middleware: [ 'middlewareName' ],
handlers: {
'1.0.0': function handler(req, res, next) {
},
'1.1.0': function xxx(req, res, next) {
}
},
};
```
It will be attached to `VERB ${prefix}/${family}/path/relative/to/prefix/family` with 2 versions: 1.0.0 and 1.1.0
### Endpoints, middleware, models
1. Models - instances of classes in the models folder:
* User
2. Endpoints - endpoints from the endpointsDir
3. Middleware - middleware from the middlewareDir