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

fastify-cli

Package Overview
Dependencies
Maintainers
17
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-cli - npm Package Compare versions

Comparing version 5.7.0 to 5.7.1

2

package.json
{
"name": "fastify-cli",
"version": "5.7.0",
"version": "5.7.1",
"description": "Run a fastify route with one command!",

@@ -5,0 +5,0 @@ "main": "cli.js",

@@ -160,3 +160,3 @@ # fastify-cli

| Set the inspector port (default: 9320) | `-I` | `--debug-port` | `FASTIFY_DEBUG_PORT` |
| Set the inspector host to listen on (default: loopback address or `0.0.0.0` inside Docker) | | `--debug-host` | `FASTIFY_DEBUG_HOST` |
| Set the inspector host to listen on (default: loopback address or `0.0.0.0` inside Docker or Kubernetes) | | `--debug-host` | `FASTIFY_DEBUG_HOST` |
| Prints pretty logs | `-P` | `--pretty-logs` | `FASTIFY_PRETTY_LOGS` |

@@ -179,5 +179,5 @@ | Watch process.cwd() directory for changes, recursively; when that happens, the process will auto reload | `-w` | `--watch` | `FASTIFY_WATCH` |

When deploying to a Docker, and potentially other, containers, it is advisable to set a fastify address of `0.0.0.0` because these containers do not default to exposing mapped ports to localhost.
When deploying to a Docker container, and potentially other, containers, it is advisable to set a fastify address of `0.0.0.0` because these containers do not default to exposing mapped ports to localhost.
For containers built and run specifically by the Docker Daemon, fastify-cli is able to detect that the server process is running within a Docker container and the `0.0.0.0` listen address is set automatically.
For containers built and run specifically by the Docker Daemon or inside a Kubernetes cluster, fastify-cli is able to detect that the server process is running within a container and the `0.0.0.0` listen address is set automatically.

@@ -184,0 +184,0 @@ Other containerization tools (eg. Buildah and Podman) are not detected automatically, so the `0.0.0.0` listen address must be set explicitly with either the `--address` flag or the `FASTIFY_ADDRESS` environment variable.

@@ -20,3 +20,4 @@ #! /usr/bin/env node

requireServerPluginFromPath,
showHelpForCommand
showHelpForCommand,
isKubernetes
} = require('./util')

@@ -129,3 +130,3 @@

opts.debugPort,
opts.debugHost || isDocker() ? listenAddressDocker : undefined
opts.debugHost || isDocker() || isKubernetes() ? listenAddressDocker : undefined
)

@@ -170,3 +171,3 @@ }

await fastify.listen({ path: opts.socket })
} else if (isDocker()) {
} else if (isDocker() || isKubernetes()) {
await fastify.listen({ port: opts.port, host: listenAddressDocker })

@@ -173,0 +174,0 @@ } else {

@@ -538,2 +538,23 @@ /* global GLOBAL_MODULE_1, GLOBAL_MODULE_2 */

test('should start the server listening on 0.0.0.0 when running in kubernetes', async t => {
t.plan(2)
const isKubernetes = sinon.stub()
isKubernetes.returns(true)
const start = proxyquire('../start', {
'./util': {
...require('../util'),
isKubernetes
}
})
const argv = ['-p', getPort(), './examples/plugin.js']
const fastify = await start.start(argv)
t.equal(fastify.server.address().address, '0.0.0.0')
await fastify.close()
t.pass('server closed')
})
test('should start the server with watch options that the child process restart when directory changed', { skip: process.platform === 'win32' }, async (t) => {

@@ -540,0 +561,0 @@ t.plan(3)

@@ -101,2 +101,8 @@ const fs = require('fs')

module.exports = { exit, requireModule, requireFastifyForModule, showHelpForCommand, requireServerPluginFromPath }
function isKubernetes () {
// Detection based on https://kubernetes.io/docs/reference/kubectl/#in-cluster-authentication-and-namespace-overrides
return process.env.KUBERNETES_SERVICE_HOST !== undefined ||
fs.existsSync('/run/secrets/kubernetes.io/serviceaccount/token')
}
module.exports = { isKubernetes, exit, requireModule, requireFastifyForModule, showHelpForCommand, requireServerPluginFromPath }
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