Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vrbo/catalyst-server

Package Overview
Dependencies
Maintainers
7
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vrbo/catalyst-server - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

tests/fixtures/basedir/basedirTestPlugin.js

2

lib/config.json

@@ -11,3 +11,3 @@ {

"crumb": {
"plugin": "require:crumb",
"plugin": "require:@hapi/crumb",
"options": "require:./plugins/config/crumb.js"

@@ -14,0 +14,0 @@ },

@@ -17,10 +17,8 @@ /*

const Joi = require('joi')
const Path = require('path')
const Hoek = require('@hapi/hoek')
const Joi = require('@hapi/joi')
const Handlers = require('shortstop-handlers')
const Hoek = require('hoek')
const Determination = require('determination')
const Steerage = require('steerage')
const Utils = require('./utils')
const evalHandler = require('./shortstop/eval')

@@ -92,2 +90,3 @@ const { manifestSchema, optionsSchema } = require('./schemas')

// shutdown gracefully
/* istanbul ignore next */
function end () {

@@ -103,3 +102,5 @@ server.stop()

/* istanbul ignore next */
process.once('SIGINT', end)
/* istanbul ignore next */
process.once('SIGTERM', end)

@@ -106,0 +107,0 @@

@@ -17,3 +17,3 @@ /*

const Joi = require('joi')
const Joi = require('@hapi/joi')

@@ -35,6 +35,5 @@ const manifestSchema = Joi.object().keys({

environment: Joi.object().default(defaults.environment),
shortstopHandlers: Joi.object().default(defaults.shortstopHandlers),
secretsConfig: Joi.object()
shortstopHandlers: Joi.object().default(defaults.shortstopHandlers)
}).default(defaults)
module.exports = { manifestSchema, optionsSchema }

@@ -21,3 +21,3 @@ /*

resolvePort () {
return parseInt(process.env.NODE_PORT || '8080')
return process.env.NODE_PORT || '8080'
},

@@ -24,0 +24,0 @@

{
"name": "@vrbo/catalyst-server",
"version": "1.0.1",
"version": "2.0.0",
"description": "Configuration and composition management for Hapi.js applications.",

@@ -19,6 +19,7 @@ "main": "lib/index.js",

"scripts": {
"test:unit": "NODE_ENV=test tape ./tests/unit/**/*.test.js | tap-spec",
"test:integration": "NODE_ENV=test tape ./tests/integration/**/*.test.js | tap-spec",
"test:coverage": "nyc --reporter=text --reporter=text-summary --reporter=html --lines 0 --functions 0 --branches 0 npm run test:unit",
"test": "standard ./lib/**/*.js && npm run test:integration && npm run test:coverage"
"build": "echo 'noop'",
"test": "standard --env mocha './lib/**/*.js' './tests/**/*.js' && npm run nyc",
"mocha": "mocha 'tests/**/*.js'",
"nyc": "nyc --reporter=text --reporter=text-summary --reporter=html --report-dir=docs/reports/coverage npm run mocha",
"postnyc": "nyc check-coverage --statements 100 --branches 100 --functions 100 --lines 100"
},

@@ -45,21 +46,22 @@ "repository": {

"peerDependencies": {
"hapi": ">=17.0.0"
"@hapi/hapi": ">=18.3.1"
},
"devDependencies": {
"hapi": "^17.8.4",
"nyc": "^13.1.0",
"sinon": "^7.2.2",
"standard": "^12.0.1",
"tap-spec": "^5.0.0",
"tape": "^4.9.1"
"@hapi/hapi": "^18.3.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"nyc": "^14.1.1",
"sinon": "^7.3.2",
"standard": "^13.0.2",
"mocha": "^6.1.4"
},
"dependencies": {
"crumb": "^7.2.3",
"@hapi/crumb": "^7.2.3",
"@hapi/hoek": "^8.0.2",
"@hapi/joi": "^15.1.0",
"determination": "^2.0.0",
"hapi-pino": "^5.2.0",
"hoek": "^6.1.2",
"joi": "^14.3.0",
"hapi-pino": "^6.0.1",
"shortstop-handlers": "^1.0.1",
"steerage": "^7.0.2"
"steerage": "^8.0.0"
}
}
# @vrbo/catalyst-server
[![NPM Version](https://img.shields.io/npm/v/@vrbo/catalyst-server.svg?style=flat-square)](https://www.npmjs.com/package/@vrbo/catalyst-server)
[![Build Status](https://travis-ci.org/homeaway/catalyst-server.svg?branch=master)](https://travis-ci.org/homeaway/catalyst-server)
[![Dependency Status](https://david-dm.org/homeaway/catalyst-server.svg?theme=shields.io)](https://david-dm.org/homeaway/catalyst-server)
[![NPM Downloads](https://img.shields.io/npm/dm/@vrbo/catalyst-server.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@vrbo/catalyst-server)

@@ -16,3 +20,3 @@ * [Introduction](#introduction)

1. Install hapi and catalyst-server `npm i @vrbo/catalyst-server hapi` into an empty node project
1. Install catalyst-server and hapi into an empty node project with `npm i @vrbo/catalyst-server @hapi/hapi`
2. Create an `index.js` file for starting your server (example below).

@@ -32,4 +36,7 @@ 3. Create a `manifest.json` for composition and configuration (example below).

});
await server.start();
server.log(['info'], `server running: ${server.info.uri}`);
return server;

@@ -59,9 +66,9 @@ }

### Basic
### Basic example
At its core, catalyst-server loads a `manifest.json` to initial and start a Hapi.js server. This file has a section for application configuration and composition via registering plugins.
At its core, `catalyst-server` loads a `manifest.json` file to initialize and start up a Hapi.js server. This file has a section for application configuration and composition via registering plugins.
Below is a basic example of a `manifest.json` file:
#### Basic manifest.json
#### manifest.json

@@ -95,3 +102,3 @@ ```js

For the configuration you can access the values in the `server/app` section from inside your code from the the `server.app.config` object. So the code to retrieve the example values look like this:
You can access all the configuration values in your code from the `server.app.config` object. So the code to retrieve the example values looks like this:

@@ -103,5 +110,5 @@ ```javascript

The `register` block registers the plugins referenced. In this example it is using [shortstop](https://github.com/krakenjs/shortstop) to resolve node modules using `require:[module]` and resolve paths using `path:[file_path]`.
The `register` block registers the plugins referenced. In this example, it is using [shortstop](https://github.com/krakenjs/shortstop) to resolve node modules using `require:[module]` and resolve paths using `path:[file_path]`.
Catalyst-server comes with the following short-stop resolvers:
Catalyst-server ships with the following `shortstop` resolvers by default:

@@ -120,3 +127,3 @@ * __file__ - read a file.

Steerage also uses [confidence](https://github.com/hapijs/confidence) to give you the ability to build environmentally aware servers. See the example `manifest.json` file below.
`Steerage` uses [confidence](https://github.com/hapijs/confidence) to give you the ability to build environmentally aware servers. See the example `manifest.json` file below.

@@ -156,4 +163,8 @@ #### Environment based manifest.json

Here you can see the `$filter` and `$default` fields. These fields allow for filtering on a resolver like `env.NODE_ENV`. The `$filter` field evaluates the environment variable `NODE_ENV`. Then it will look to the following fields for a match in the keys for that value, otherwise the `$default` value is used. So the configuration values and options for plugins will change based on the environment variable `NODE_ENV`. You could also determine whether plugin should be registered at all. See the code below for an example based on this `manifest.json` file.
In this example, the `$filter` and `$default` fields allow for filtering based on a resolver like `env.NODE_ENV`.
The `$filter` field evaluates the environment variable `NODE_ENV`. Then, it will look to the following fields for a match in the keys for that value. Otherwise, the `$default` value is used. So the configuration values and options for plugins will change based on the environment variable `NODE_ENV`.
This is what the above manifest configuration will return in code for different environments:
```javascript

@@ -171,5 +182,21 @@ // ENVIRONMENT VARIABLE NODE_ENV='development'

Using a filter, you can easily enable/disable a plugin for a given environment. See the code below for an example, where we disable `hapi-pino` in development mode, and enable it in all other environments:
```javascript
{
"register": {
"hapi-pino": {
"enabled": {
"$filter": "env.NODE_ENV",
"development": false,
"$default": true
}
}
}
}
```
### Advanced
Here are some examples of the short-stop resolvers available that makes handling complex configuration and composition rather straight forward.
Here are some examples of the `shortstop` resolvers which make handling complex configuration and composition rather straight forward.

@@ -244,7 +271,7 @@ #### `file:` Reading a file into a value.

* eval can also be used to reference other values in the `manifest`. In the above example the `child/value` in `server/app` will be set to `'abc_xyz'`.
* `eval` can also be used to reference other values in the `manifest`. In the above example the `child/value` in `server/app` will be set to `'abc_xyz'`.
## Example Code
See the [examples folder](examples) for an example.
See the [examples](examples) folder for example code.

@@ -251,0 +278,0 @@ ## Further Reading

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc