@whook/whook

Build strong and efficient REST web services.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@whook/whook
182310.0.64 days ago4 years agoMinified + gzip package size for @whook/whook in KB

Readme

@whook/whook
Build strong and efficient REST web services.

GitHub license
whook allows you to create REST web services by providing its ingredients and the recipe to make it work altogether.
The recipe is your Open API (OAS3) definition while ingredients are handlers, wrappers, services and their configuration.

Quick start

npm init @whook

Learn more about Whook.
API

Members

defaultPromise.<String>

Initialize the APIDEFINITIONS service according to the porject handlers.

defaultPromise.<String>

Initialize the BASEURL service according to the HOST/PORT so that applications fallbacks to that default base URL.

defaultPromise.<Object>

Initialize the CONFIGS service according to the NODEENV

defaultPromise.<Number>

Initialize the PORT service from ENV or auto-detection if none specified in ENV

defaultPromise.<string>

Auto detect the Whook PROJECTDIR

defaultPromise.<Object>

Wrap the ENV service in order to filter ENV vars for the build

defaultPromise.<string>

Auto detect the Whook WHOOKPLUGINSPATHS

Functions

prepareServer(injectedNames, $)

Runs the Whook server

prepareEnvironment($)

Prepare the Whook server environment

initBuildConstants(constants)Promise.<Object>

Allow to proxy constants directly by serializing it in the build, saving some computing and increasing boot time of the build.

initENV(services)Promise.<Object>

Initialize the ENV service using process env plus dotenv files

initHost(services)Promise.<String>

Initialize the HOST service from ENV or auto-detection if none specified in ENV

initImporter(path)Promise.<Object>

Allow to import ES modules.

initResolve(path)Promise.<string>

Allow to resolve a path with the module system.


default ⇒ Promise.<String>

Initialize the APIDEFINITIONS service according to the porject handlers.
Kind: global variable
Returns: Promise.<String> - A promise of a containing the actual host.
| Param | Type | Default | Description | | --- | --- | --- | --- | | services | Object | | The services API
DEFINITIONS depends on | | services.PROJECTSRC | Object | | The project sources location | | services.WHOOKPLUGINSPATHS | Object | | The plugins paths to load services from | | services.IGNOREDFILESSUFFIXES | Object | | The files suffixes the autoloader must ignore | | services.IGNOREDFILESPREFIXES | Object | | The files prefixes the autoloader must ignore | | services.FILTERAPITAGS | Object | | Allows to only keep the endpoints taggeds with the given tags | | services.importer | Object | | A service allowing to dynamically import ES modules | | services.log | Object | noop | An optional logging service |

default ⇒ Promise.<String>

Initialize the BASEURL service according to the HOST/PORT so that applications fallbacks to that default base URL.
Kind: global variable
Returns: Promise.<String> - A promise of a containing the actual host.
| Param | Type | Default | Description | | --- | --- | --- | --- | | services | Object | | The services BASE
URL depends on | | services.ENV | Object | | The process environment | | services.CONFIG | Object | | The injected CONFIG value | | services.PROTOCOL | Object | | The injected PROTOCOL value | | services.HOST | Object | | The injected HOST value | | services.PORT | Object | | The injected PORT value | | services.log | Object | noop | An optional logging service |

default ⇒ Promise.<Object>

Initialize the CONFIGS service according to the NODEENV
Kind: global variable
Returns: Promise.<Object> - A promise of a an object the actual configuration properties.
| Param | Type | Default | Description | | --- | --- | --- | --- | | services | Object | | The services CONFIGS depends on | | services.NODE
ENV | Object | | The injected NODEENV value | | services.PROJECTSRC | Object | | The project source directory | | services.log | Object | noop | An optional logging service | | services.importer | Object | | A service allowing to dynamically import ES modules |

default ⇒ Promise.<Number>

Initialize the PORT service from ENV or auto-detection if none specified in ENV
Kind: global variable
Returns: Promise.<Number> - A promise of a number representing the actual port.
| Param | Type | Default | Description | | --- | --- | --- | --- | | services | Object | | The services PORT depends on | | services.ENV | Object | {} | An optional environment object | | services.log | Object | noop | An optional logging service | | services.importer | Object | | A service allowing to dynamically import ES modules |

default ⇒ Promise.<string>

Auto detect the Whook PROJECTDIR
Kind: global variable
Returns: Promise.<string> - A promise of a number representing the actual port.
| Param | Type | Default | Description | | --- | --- | --- | --- | | services | Object | | The services PROJECT
DIR depends on | | services.PWD | Object | | The process working directory | | services.log | Object | noop | An optional logging service |

default ⇒ Promise.<Object>

Wrap the ENV service in order to filter ENV vars for the build
Kind: global variable
Returns: Promise.<Object> - A promise of an object containing the reshaped env vars.
| Param | Type | Default | Description | | --- | --- | --- | --- | | services | Object | | The services ENV depends on | | services.NODEENV | Object | | The injected NODEENV value to add it to the build env | | services.PROXYEDENVVARS | Object | {} | A list of environment variable names to proxy | | services.log | Object | noop | An optional logging service |

default ⇒ Promise.<string>

Auto detect the Whook WHOOKPLUGINSPATHS
Kind: global variable
Returns: Promise.<string> - A promise of a number representing the actual port.
| Param | Type | Default | Description | | --- | --- | --- | --- | | services | Object | | The services WHOOKPLUGINSPATHS depends on | | services.WHOOKPLUGINS | Array.<String> | | The active whook plugins list | | services.PROJECTSRC | String | | The project source directory | | services.log | Object | noop | An optional logging service |

prepareServer(injectedNames, $) ⇒

Runs the Whook server
Kind: global function
Returns: Object A promise of the injected services
| Param | Type | Description | | --- | --- | --- | | injectedNames | Array.<String> | Root dependencies names to instanciate and return | | $ | Knifecycle | The Knifecycle instance to use for the server run |

prepareEnvironment($) ⇒

Prepare the Whook server environment
Kind: global function
Returns: Promise A promise of the Knifecycle instance
| Param | Type | Description | | --- | --- | --- | | $ | Knifecycle | The Knifecycle instance to set the various services |

initBuildConstants(constants) ⇒ Promise.<Object>

Allow to proxy constants directly by serializing it in the build, saving some computing and increasing boot time of the build.
Kind: global function
Returns: Promise.<Object> - A promise of an object containing the gathered constants.
| Param | Type | Description | | --- | --- | --- | | constants | Object | The serializable constants to gather |
Example
import { initBuildConstants } from '@whook/whook';
import { alsoInject } from 'knifecycle';

export default alsoInject(['MY_OWN_CONSTANT'], initBuildConstants);

initENV(services) ⇒ Promise.<Object>

Initialize the ENV service using process env plus dotenv files
Kind: global function
Returns: Promise.<Object> - A promise of an object containing the actual env vars.
| Param | Type | Default | Description | | --- | --- | --- | --- | | services | Object | | The services ENV depends on | | services.NODEENV | Object | | The injected NODEENV value to look for .env.${NODE_ENV} env file | | services.PWD | Object | | The process current working directory | | services.BASEENV | Object | {} | An optional base environment | | services.log | Object | noop | An optional logging service |

initHost(services) ⇒ Promise.<String>

Initialize the HOST service from ENV or auto-detection if none specified in ENV
Kind: global function
Returns: Promise.<String> - A promise of a containing the actual host.
| Param | Type | Default | Description | | --- | --- | --- | --- | | services | Object | | The services HOST depends on | | services.ENV | Object | {} | An optional environment object | | services.log | Object | noop | An optional logging service | | services.importer | Object | | A service allowing to dynamically import ES modules |

initImporter(path) ⇒ Promise.<Object>

Allow to import ES modules.
Kind: global function
Returns: Promise.<Object> - A promise of an imported module.
| Param | Type | Description | | --- | --- | --- | | path | string | The module path |

initResolve(path) ⇒ Promise.<string>

Allow to resolve a path with the module system.
Kind: global function
Returns: Promise.<string> - A promise of a fully qualified module path
| Param | Type | Description | | --- | --- | --- | | path | string | The serializable constants to gather |
Authors
License
MIT