0.2.6 • Published 7 years ago

sails-hook-simple-api v0.2.6

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

npm version Dependencies

Needs at least Sails version 0.12.0 to work.

Sails JS hook which extends the features of the sails blueprint api. Inspired by the article "Best Practices for Designing a Pragmatic RESTful API".

Installation

# Get the latest release of sails-hook-simple-api
$ npm install sails-hook-simple-api --save

Configuration

By default, configuration lives in sails.config.simpleapi. The configuration key (simpleapi) can be changed by setting sails.config.hooks['sails-hook-simpleapi'].configKey.

ParameterTypeDetails
namestringThe name of your api. Used e.g. for the x-powered-by-header.
versionfloatThe version of your api. Used e.g. for the x-powered-by-header.
hostnamestringThe explicit hostname of your api. Used e.g. for the pagination urls.
compressionbooleanCompress the output of your api? Use true or false. If you do not specify, the output of your api will only be compressed if the api run in production environment.
compressionOptionsobject|booleanIf the compression is enabled you can specify some compression options here. More infos about the available options you find here.
minifybooleanMinify the json output of your api? Use true or false. If you do not specify, the json output of your api will only be minified if your api run in production environment.
methodOverridebooleanEnable the possibility to override the original http method? Use true or false. Defaults to false.
parameterNameMethodOverridestringThe name of the method override parameter to replace the original http method. Defaults to _method.
headerNameMethodOverridestringThe name of the method override header to replace the original http method. Defaults to X-Http-Method-Override.
prettybooleanEnables the possibility to override the minify setting by a custom parameter. Use true or false. Defaults to false.
parameterNamePrettystringThe name of the pretty parameter, if the pretty setting is enabled, to receive a favorite minify setting by an user. Possible settings are 1, true, 0 or false. Defaults to pretty.
defaultEnvelopebooleanThe default envelope setting to show a response of data. Use true or false. Defaults to false.
parameterNameEnvelopestringThe name of the envelope parameter to receive a favorite envelope setting by an user. Possible settings are 1, true, 0 or false. Defaults to envelope.
envelopeResponseKeystringThe name of the key which is used to envelope the return of the response data (if envelope is enabled). Defaults to response.
jsonpbooleanEnables the possibility to send jsonp requests. Use true or false. Defaults to false.
jsonpAutoEnvelopebooleanEnables the envelope setting automatically if a jsonp request sent. Use true or false. Defaults to true.
parameterNameJsonpstringThe name of the jsonp parameter to receive a favorite jsonp callback function name by an user. Defaults to callback.
defaultPageintegerThe default page number to show in the response from a find action. You can override this default setting individually for each model. Just add _config: { defaultPage: 1 } to your favorite model. Other models without an individual setting, use this default setting. Defaults to 1.
parameterNamePagestringThe name of the page parameter to receive a favorite page by an user. Defaults to page.
defaultLimitintegerThe default number of records to show in the response from a find action. You can override this default setting individually for each model. Just add _config: { defaultLimit: 30 } to your favorite model. Other models without an individual setting, use this default setting. Defaults to 30.
parameterNameLimitstringThe name of the limit parameter to receive a favorite limit per page by an user. Defaults to limit.
maximumLimitinteger|booleanThe maximum allowed number of records to show in the response from a find action. Use false for no limitation. You can override this default setting individually for each model. Just add _config: { maximumLimit: 100 } to your favorite model. Other models without an individual setting, use this default setting. Defaults to 100.
defaultPopulateboolean|string|arrayThe default populate setting to show a response of data. Use true or false to populate or hide all associations. You can also pass a comma-separated string or an array with certain associations. You can override this default setting individually for each model. Just add _config: { defaultPopulate: false } to your favorite model. Other models without an individual setting, use this default setting. Defaults to false.
parameterNamePopulatestringThe name of the populate parameter to receive a favorite populate setting by an user. Possible settings are 1, true, 0, false or a comma-separated string with certain associations. Defaults to populate.
defaultPopulateLimitintegerThe default number of populated records to show in the response from a find action. You can override this default setting individually for each model. Just add _config: { defaultPopulateLimit: 30 } to your favorite model. Other models without an individual setting, use this default setting. If the defaultPopulateLimit is nowhere set we use the defaultLimit. Defaults to defaultLimit.
parameterNamePopulateLimitstringThe name of the populate limit parameter to receive a favorite populate limit by an user. Defaults to populateLimit.
maximumPopulateLimitinteger|booleanThe maximum allowed number of populated records to show in the response from a find action. Use false for no limitation. You can override this default setting individually for each model. Just add _config: { maximumPopulateLimit: 100 } to your favorite model. Other models without an individual setting, use this default setting. If the maximumPopulateLimit is nowhere set we use the maximumLimit. Defaults to maximumLimit.
defaultSortstringThe default sort of records to show in the response from a find or a findOne action. Pass the name(s) of (an) attribute(s) to get an individual sorting of the records. The default direction for each sort attribute is ascending, use a - before the attribute name for descending sort. Separate several sorts by a comma. Note: id matches automatically the primary key attribute. Have no fear to use unavailable attributes, they will be automatically ignored. You can override this default setting individually for each model. Just add _config: { defaultSort: 'id' } to your favorite model. Other models without an individual setting, use this default setting. Defaults to id.
parameterNameSortstringThe name of the sort parameter to receive a favorite sorting by an user. Defaults to sort.
defaultFieldsstring|booleanThe default fields of records to show in the response from a find or a findOne action. Pass the name(s) of (an) attribute(s) to get an individual set of the returned record fields. Use a - at the beginning to exclude the fields from the records. Separate your favorite fields by a comma or use false to return all available fields. Note: id matches automatically the primary key attribute. Have no fear to use unavailable fields, they will be automatically ignored. You can override this default setting individually for each model. Just add _config: { defaultFields: false } to your favorite model. Other models without an individual setting, use this default setting. Defaults to false.
parameterNameFieldsstringThe name of the fields parameter to receive a favorite choice of the returned fields by an user. Defaults to fields.

License

MIT License

image_squidhome@2x.png

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago