How to use pathifist - 10 common examples

To help you get started, we’ve selected a few pathifist 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',
  'image/jpeg',
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 / lambda / lib / aws-config.js View on Github external
const region =
    awsConfig.region ||
    process.env.AWS_REGION ||
    process.env.AWS_DEFAULT_REGION;

  const config = {
    region,
    stackName: awsConfig.uniqueName,
    bucketName: awsConfig.uniqueName,
    runtime: getRuntimeNodeVersion(nodeVersion),
    memorySize: awsConfig.memorySize,
    stageName: awsConfig.stageName,
    domainName: awsConfig.domainName || '',
    certificateArn: awsConfig.certificateArn || '',
    basePath: trimSlashes(hopsConfig.basePath) || '(none)',
    cloudformationTemplateFile: awsConfig.cloudformationTemplateFile,
    include: [...(awsConfig.include || [])],
    exclude: [...(awsConfig.exclude || [])],
  };

  return config;
};
github untool / untool / packages / webpack / lib / configs / build.js View on Github external
  const getAssetPath = (...arg) => trimSlashes(join(config.assetPath, ...arg));
  const isProduction = process.env.NODE_ENV === 'production';
github xing / hops / packages / lambda / mixin.core.js View on Github external
if (!semver.intersects(targetNodeVersion, nodeVersionRange)) {
      warnings.push(
        [
          `AWS Lambda only supports the Node.js version range "${nodeVersionRange}".`,
          'Please specify or use a Node.js version intersecting this range',
          'in your Hops config (hops.node) to tell Babel for which version',
          'it should transpile for.',
        ].join('\n')
      );
    }

    if (
      !this.awsConfig.domainName &&
      this.awsConfig.basePath.indexOf(this.awsConfig.stageName) !== 0 &&
      trimSlashes(this.config.assetPath).indexOf(this.awsConfig.stageName) !== 0
    ) {
      warnings.push(
        `When no custom domain is configured, the stageName (${this.awsConfig.stageName}) should be the first path segment in basePath (${this.awsConfig.basePath}) and assetPath (${this.config.assetPath}).`
      );
    }

    if (this.awsConfig.domainName && !this.awsConfig.certificateArn) {
      warnings.push(
        'Setting a custom domain name also requires to specify the ACM certificate ARN.'
      );
    }
  }
}
github untool / untool / packages / webpack / lib / configs / node.js View on Github external
  const getAssetPath = (...arg) => trimSlashes(join(config.assetPath, ...arg));
  const isProduction = process.env.NODE_ENV === 'production';
github untool / untool / packages / webpack / lib / configs / develop.js View on Github external
  const getAssetPath = (...arg) => trimSlashes(join(config.assetPath, ...arg));
github xing / hops / packages / postcss / mixin.core.js View on Github external
const getAssetPath = (...args) => trimSlashes(join(...args));
github xing / hops / packages / pwa / mixin.core.js View on Github external
const getAssetPath = (...args) => trimSlashes(join(...args));
github untool / untool / packages / webpack / mixins / render / mixin.core.js View on Github external
return locations.map((location) => {
      const isString = typeof location === 'string';
      const url = ensureLeadingSlash(
        joinUrl(basePath, isString ? location : location.url)
      );
      return isString ? { url } : { ...location, url };
    });
  }

pathifist

URL Path Utility

MIT
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis

Similar packages