npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sails-hook-simple-api

v0.2.6

Published

Sails hook which extends the features of the sails blueprint api. Inspired by http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api

Downloads

6

Readme

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.

Parameter | Type | Details -------------- | ------------------- |:--------------------------------- name | string | The name of your api. Used e.g. for the x-powered-by-header. version | float | The version of your api. Used e.g. for the x-powered-by-header. hostname | string | The explicit hostname of your api. Used e.g. for the pagination urls. compression | boolean | Compress 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. compressionOptions | object|boolean | If the compression is enabled you can specify some compression options here. More infos about the available options you find here. minify | boolean | Minify 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. methodOverride | boolean | Enable the possibility to override the original http method? Use true or false. Defaults to false. parameterNameMethodOverride | string | The name of the method override parameter to replace the original http method. Defaults to _method. headerNameMethodOverride | string | The name of the method override header to replace the original http method. Defaults to X-Http-Method-Override. pretty | boolean | Enables the possibility to override the minify setting by a custom parameter. Use true or false. Defaults to false. parameterNamePretty | string | The 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. defaultEnvelope | boolean | The default envelope setting to show a response of data. Use true or false. Defaults to false. parameterNameEnvelope | string | The 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. envelopeResponseKey | string | The name of the key which is used to envelope the return of the response data (if envelope is enabled). Defaults to response. jsonp | boolean | Enables the possibility to send jsonp requests. Use true or false. Defaults to false. jsonpAutoEnvelope | boolean | Enables the envelope setting automatically if a jsonp request sent. Use true or false. Defaults to true. parameterNameJsonp | string | The name of the jsonp parameter to receive a favorite jsonp callback function name by an user. Defaults to callback. defaultPage | integer | The 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. parameterNamePage | string | The name of the page parameter to receive a favorite page by an user. Defaults to page. defaultLimit | integer | The 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. parameterNameLimit | string | The name of the limit parameter to receive a favorite limit per page by an user. Defaults to limit. maximumLimit | integer|boolean | The 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. defaultPopulate | boolean|string|array | The 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. parameterNamePopulate | string | The 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. defaultPopulateLimit | integer | The 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. parameterNamePopulateLimit | string | The name of the populate limit parameter to receive a favorite populate limit by an user. Defaults to populateLimit. maximumPopulateLimit | integer|boolean | The 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. defaultSort | string | The 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. parameterNameSort | string | The name of the sort parameter to receive a favorite sorting by an user. Defaults to sort. defaultFields | string|boolean | The 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. parameterNameFields | string | The 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