How to use @automattic/vip-go - 6 common examples

To help you get started, we’ve selected a few @automattic/vip-go examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alleyinteractive / irving / packages / vip-go / services / monitorService.js View on Github external
const getService = () => {
  // newrelic cannot be imported in a browser environment.
  if (! process.env.BROWSER) {
    // Attempt to create newrelic client using vip go package.
    try {
      const { newrelic, logger } = require('@automattic/vip-go'); // eslint-disable-line global-require
      const client = newrelic({
        logger: logger('irving:newrelic'),
      });

      // VIP Go's package can return nothing if newrelic is not instsalled or configured improperly.
      if (! client) {
        return defaultService;
      }

      return {
        client,
        start: () => {},
        logError(err) {
          client.noticeError(err);
        },
        logTransaction(method, status, category) {
          client.setTransactionName(`${method} ${status} ${category}`);
        },
github alleyinteractive / irving / packages / vip-go / services / logService.js View on Github external
const getService = (namespace) => {
  const env = process.env.NODE_ENV;
  let service;

  /* eslint-disable global-require */
  if (! process.env.BROWSER) {
    const { logger } = require('@automattic/vip-go');
    const log = logger(namespace, {
      silent: 'test' === env,
    });

    // Map log levels to winston log levels in node.
    service = Object.keys(defaultService)
      .reduce((acc, method) => {
        acc[method] = (...messages) => {
          // Send error to production monitoring service.
          if ('production' === env) {
            monitor.logError();
          }

          log[method](...messages);
        };

        return acc;
github alleyinteractive / irving / packages / vip-go / services / createDebug.js View on Github external
const createDebug = (namespace) => (level, ...messages) => {
  let log;
  const env = process.env.NODE_ENV;

  /* eslint-disable global-require */
  if (! process.env.BROWSER) {
    const { logger } = require('@automattic/vip-go');
    log = logger(namespace, {
      silent: 'test' === env,
    })[level];
  } else {
    log = require('debug')(namespace);
  }
  /* eslint-enable */

  // In development the app should crash fast when encountering any errors.
  messages.forEach((message) => {
    if (message instanceof Error && 'development' === env) {
      throw message;
    }
  });

  // Send error to production monitoring service.
  // if ('production' === env) {
github alleyinteractive / irving / packages / vip-go / services / monitorService.js View on Github external
const getService = () => {
  // newrelic cannot be imported in a browser environment.
  if (! process.env.BROWSER) {
    // Attempt to create newrelic client using vip go package.
    try {
      const { newrelic, logger } = require('@automattic/vip-go'); // eslint-disable-line global-require
      const client = newrelic({
        logger: logger('irving:newrelic'),
      });

      // VIP Go's package can return nothing if newrelic is not instsalled or configured improperly.
      if (! client) {
        return defaultService;
      }

      return {
        client,
        start: () => {},
        logError(err) {
          client.noticeError(err);
        },
        logTransaction(method, status, category) {
          client.setTransactionName(`${method} ${status} ${category}`);
github alleyinteractive / irving / packages / vip-go / server / startServer.js View on Github external
module.exports = function startServer(app) {
  let vipServer;

  if ('development' !== NODE_ENV) {
    vipServer = server(app, { PORT });
    vipServer.listen();
  }

  return vipServer;
};
github alleyinteractive / irving / packages / vip-go / server / createServer.js View on Github external
const os = require('os');
    const fs = require('fs');
    const path = require('path');

    const key = fs.readFileSync(
      path.join(os.homedir(), HTTPS_KEY_PATH),
      'utf8'
    );
    const cert = fs.readFileSync(
      path.join(os.homedir(), HTTPS_CERT_PATH),
      'utf8'
    );

    irvingServer = https.createServer({ key, cert }, app);
  } else {
    irvingServer = server(app, { PORT });
  }

  return irvingServer;
};

@automattic/vip-go

Node package helpers for the VIP Go platform

ISC
Latest version published 4 years ago

Package Health Score

52 / 100
Full package analysis

Similar packages