How to use the hops-config.basePath function in hops-config

To help you get started, we’ve selected a few hops-config 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 xing / hops / packages / lambda / lambda.js View on Github external
'use strict';

process.env.NODE_ENV = 'production';

const serverlessHttp = require('serverless-http');
const config = require('hops-config');
const { trimSlashes } = require('pathifist');

const app = require('@untool/express').createServer('serve');

const awsConfig = require('./lib/aws-config')(config);

const shouldIncludeStageInRequest =
  trimSlashes(config.basePath).indexOf(awsConfig.stageName) === 0 &&
  trimSlashes(config.assetPath).indexOf(awsConfig.stageName) === 0;

// NOTE: If you get ERR_CONTENT_DECODING_FAILED in your browser, this is likely
// due to a compressed response (e.g. gzip) which has not been handled correctly
// by serverless-http and/or API Gateway. Add the necessary MIME types to
// binaryMimeTypes below, then redeploy.
const binaryMimeTypes = [
  'application/javascript',
  'application/json',
  'application/octet-stream',
  'application/xml',
  'font/eot',
  'font/opentype',
  'font/otf',
  'font/woff',
  'font/woff2',
github xing / hops / packages / server / index.js View on Github external
function defaultCallback(error) {
  if (error) {
    console.error(error.stack.toString());
  } else {
    console.log(
      'hops: Server listening at ' +
        url.format({
          protocol: hopsConfig.https ? 'https' : 'http',
          hostname:
            hopsConfig.host === '0.0.0.0' ? 'localhost' : hopsConfig.host,
          port: hopsConfig.port,
          pathname: hopsConfig.basePath,
        })
    );
  }
}
github xing / hops / packages / express / lib / utils.js View on Github external
function defaultCallback(error, server) {
  if (error) {
    console.error(error.stack ? error.stack.toString() : error.toString());
  } else {
    var address = server.address();
    console.log(
      'hops: Server listening at ' +
        url.format({
          protocol: hopsConfig.https ? 'https' : 'http',
          hostname:
            address.address === '0.0.0.0' ? 'localhost' : address.address,
          port: address.port,
          pathname: hopsConfig.basePath,
        })
    );
  }
}
github xing / hops / packages / express / lib / utils.js View on Github external
var location = hopsConfig.locations.find(function(location) {
      return (
        location !== hopsConfig.basePath + '/' &&
        req.url.indexOf(location) === 0
      );
    });
    if (location) {
github xing / hops / packages / server / index.js View on Github external
var location = hopsConfig.locations.find(function(location) {
      return (
        location !== hopsConfig.basePath + '/' &&
        req.url.indexOf(location) === 0
      );
    });
    if (location) {
github xing / hops / packages / react / dom.js View on Github external
exports.ReactContext = function(options) {
  if (!options) {
    options = {};
  }
  this.routerOptions = Object.assign(
    { basename: hopsConfig.basePath },
    options.router
  );
  this.mountpoint = options.mountpoint || '#main';
};
exports.ReactContext.prototype = {
github xing / hops / packages / react / node.js View on Github external
exports.ReactContext = function(options) {
  if (!options) {
    options = {};
  }
  this.routerOptions = Object.assign(
    {
      location: options.request && options.request.path,
      basename: hopsConfig.basePath,
      context: {},
    },
    options.router
  );
  this.template = options.template || defaultTemplate;
  this.assets = options.response && options.response.locals.hops.assets;
};
exports.ReactContext.prototype = {