How to use the config.host function in config

To help you get started, we’ve selected a few 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 davidmerfield / Blot / scripts / user / create.js View on Github external
User.generateAccessToken(email, function(err, token) {
    if (err) throw err;

    // The full one-time log-in link to be sent to the user
    var url = format({
      protocol: "https",
      host: config.host,
      pathname: "/sign-up",
      query: {
        already_paid: token
      }
    });

    console.log("Use this link to create an account for:", email);
    console.log(url);
    callback();
  });
}
github qious / ss-panel-server / spec / index.js View on Github external
let location = path.join(CWD, file)
  let uri = translate.fromSpec(file)
  let handle = YAML.load(fs.readFileSync(location, 'utf8'))
  paths[uri] = handle
  return paths
}, {})

spec.definitions = glob.sync('server/spec/definitions/*.yaml', {cwd: CWD}).reduce((defs, file) => {
  let location = path.join(CWD, file)
  let name = path.parse(file).name
  defs[name] = YAML.load(fs.readFileSync(location, 'utf8'))
  return defs
}, {})

// merge config.swagger and swagger.yaml
let host = `${config.host}:${config.port}`
_.merge(spec, config.swagger, {host})

/**
 * - require responses.default.schema
 * - if security exist, it should be array
 */
let paths = spec.paths
for (let uri in paths) {
  for (let method in paths[uri]) {
    let operation = paths[uri][method]

    if (operation.security && !_.isArray(operation.security)) {
      throw new Error(`InvalidSchema ${uri}.${method}.security should be array find ${operation.security}`)
    }

    if (!operation.responses.default || !operation.responses.default.schema) {
github opencollective / opencollective-website / frontend / src / components / Invoice.js View on Github external
let hostAddress = '';
    if (transaction.host.locationName) {
      hostAddress = `${transaction.host.locationName}\n`;
    }
    const hostBillingAddress = { __html : `${hostAddress}${transaction.host.address || ''}`.replace(/\n/g,'<br>') };

    let userAddress = '';
    if (fromCollective.address) {
      userAddress = `${fromCollective.address}\n`;
    }
    const userBillingAddress = { __html : (transaction.createdByUser.billingAddress || userAddress || '').replace(/\n/g,'<br>') };
    const styles = getGroupCustomStyles(collective);

    // We need to load images in absolute path for PhantomJS
    if (styles.hero.cover.backgroundImage &amp;&amp; styles.hero.cover.backgroundImage.match(/url\('?\//)) {
      styles.hero.cover.backgroundImage = styles.hero.cover.backgroundImage.replace(/url\(('?)\//, `url($1${config.host.website}/`);
    }

    const pageStyle = {
      'A4': {
        width: '210mm',
        height: '297mm'
      },
      'Letter': {
        width: '8.5in',
        height: '11in'
      }
    }

    return (
      <div style="{pageStyle[paperSize]}">
        <style>{`</style></div>
github opencollective / opencollective-website / test / e2e / donate_page.js View on Github external
'Donate button shows €100.00': (client) => {
    client
      .url(`${config.host.website}/testcollective/donate/100/February Meetup`)
      .waitForElementVisible('body', 1000)
      .assert.containsText('div[class=Tier]', 'February Meetup')
      .assert.containsText('div[class=DonateDisclaimer]', '€100,00')
      .end();
   },
github opencollective / opencollective-api / cron / monthly / user-report.js View on Github external
async host => {
        const filename = `${year}${month2digit}-${host.slug}-${backerCollective.slug}.pdf`;
        const invoiceUrl = `${config.host.website}/${backerCollective.slug}/invoices/${filename}`;
        console.log('>>> downloading', invoiceUrl);
        await fetch(invoiceUrl, { headers })
          .then(response => {
            if (response.status === 200) {
              return response.buffer();
            } else {
              console.error(`Unable to download the invoice ${invoiceUrl}`);
            }
          })
          .then(blob => {
            if (!blob) return;
            attachments.push({
              filename,
              content: blob,
            });
          });
github opencollective / opencollective-api / server / controllers / transactions.js View on Github external
paypal: (data, callback) => {
    const uri = `/groups/${data.group.id}/transactions/${data.transaction.id}/paykey/`;
    const baseUrl = config.host.webapp + uri;
    const amount = data.transaction.amount;
    const payload = {
      requestEnvelope: {
        errorLanguage: 'en_US',
        detailLevel: 'ReturnAll'
      },
      actionType: 'PAY',
      currencyCode: data.transaction.currency.toUpperCase() || 'USD',
      feesPayer: 'SENDER',
      memo: `Reimbursement transaction ${data.transaction.id}: ${data.transaction.description}`,
      trackingId: [uuid.v1().substr(0, 8), data.transaction.id].join(':'),
      preapprovalKey: data.paymentMethod.token,
      returnUrl: `${baseUrl}/success`,
      cancelUrl: `${baseUrl}/cancel`,
      receiverList: {
        receiver: [
github opencollective / opencollective-api / server / controllers / comments.js View on Github external
.then(() =&gt; {
      res.send(`Comment on expense "${req.expense.description}" approved. [<a href="${config.host.website}/${req.collective.slug}/expenses/${req.expense.id}">view the expense</a>]`);
    })
    .catch(next);
github easy-mock / easy-mock / build / webpack.base.config.js View on Github external
'use strict'

const fs = require('fs')
const path = require('path')
const config = require('config')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')

const vueConfig = require('./vue-loader.config')

const isProd = process.env.NODE_ENV === 'production'
const resolve = dir => path.resolve(__dirname, dir)

config.fe.host = config.host
config.fe.port = config.port
config.fe.ldap = !!config.ldap.server
fs.writeFileSync(resolve('../views/config.json'), JSON.stringify(config.fe))

module.exports = {
  devtool: isProd ? false : '#cheap-module-source-map',
  output: {
    path: resolve('../dist'),
    publicPath: config.get('fe.publicPath'),
    filename: '[name].[chunkhash].js'
  },
  resolve: {
    extensions: ['.js', '.vue', '.json', '.md'],
    alias: {
      'pages': resolve('../views/pages'),
      'components': resolve('../views/components'),
github davidmerfield / Blot / scripts / blog / switch-blog-id-format / cli.js View on Github external
function endMessage(oldBlogID, blog, access) {
  return (
    colors.dim("Blog: " + oldBlogID) +
    " New ID:    " +
    colors.cyan(blog.id) +
    "\n" +
    colors.dim("Blog: " + oldBlogID) +
    " Live site: " +
    colors.yellow(
      "https://" +
        blog.handle +
        "." +
        config.host +
        (blog.domain ? " - https://" + blog.domain : "")
    ) +
    "\n" +
    colors.dim("Blog: " + oldBlogID) +
    " Dashboard: " +
    colors.green(access)
  );
}
github opencollective / opencollective-api / server / lib / subscriptions.js View on Github external
const user = order.createdByUser;
  return emailLib.send(
    'thankyou',
    user.email,
    {
      order: order.info,
      transaction: transaction.info,
      user: user.info,
      firstPayment: false,
      collective: order.collective.info,
      fromCollective: order.fromCollective.minimal,
      relatedCollectives,
      recommendedCollectives,
      config: { host: config.host },
      interval: order.Subscription.interval,
      subscriptionsLink: `${config.host.website}/${order.fromCollective.slug}/subscriptions`,
    },
    {
      from: `${order.collective.name} `,
    },
  );
}