Socket
Socket
Sign inDemoInstall

@dollarshaveclub/nodejs-server

Package Overview
Dependencies
32
Maintainers
27
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dollarshaveclub/nodejs-server

[![CircleCI](https://circleci.com/gh/dollarshaveclub/nodejs-server/tree/master.svg?style=svg&circle-token=850fd443c919134e53254d3ab098b02f085722fe)](https://circleci.com/gh/dollarshaveclub/nodejs-server/tree/master) [![codecov](https://codecov.io/gh/dolla


Version published
Weekly downloads
2
Maintainers
27
Install size
8.46 MB
Created
Weekly downloads
 

Readme

Source

Node.js Server

CircleCI codecov Greenkeeper badge

This is the main server to be used in all of Dollar Shave Club's node.js applications.

Features

  • Graceful shutdown
  • Health checks via GET /ping
  • Supports both Express and Koa
  • Datadog metrics
  • Rollbar

Environment Variables

  • NODE_ENV=development
  • PORT or LISTEN_PORT
  • SOCKET_TIMEOUT_SECONDS=120
  • GRACEFUL_SHUTDOWN_TIMEOUT_SECONDS=15
  • ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN - access token for server-side rollbar

Usage

API

serve(app, [options])

Options:

  • name - name of the repo
  • port
  • socketTimeout
  • gracefulShutdownTimeout
  • rollbarPostServerItemAccessToken

For development only:

  • proxy = false - whether to proxy requests
  • proxyHostname = process.env.PROXY_HOSTNAME || release.dollarshaveclub.com - what server to proxy
  • proxyMatch = /^\/(api|cms|face-assets)\// - regex to match paths to proxy

To support proxying locally and internationally, add the following to your /etc/hosts:

::1             localhost     # should have already been added
::1             localhost.au
::1             localhost.ca
::1             localhost.uk

Express

const serve = require('@dollarshaveclub/nodejs-server')

const app = require('express')()

// app logic

serve(app, {
  name: 'my-app',
}).then(({ port }) => {
  console.log(port)
})

Koa

const serve = require('@dollarshaveclub/nodejs-server')
const Koa = require('koa')

const app = new Koa()

// app logic

serve(app, {
  name: 'my-app'
})

Typescript w/ Koa

import serve from "@dollarshaveclub/nodejs-server"
await serve(new Koa(), {name: "my-app"})

FAQs

Last updated on 16 Dec 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc