How to use the app-root-path.path function in app-root-path

To help you get started, we’ve selected a few app-root-path 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 linnovate / mean / server / config / express.js View on Github external
// enable CORS - Cross Origin Resource Sharing
app.use(cors());

// enable detailed API logging in dev env
if (config.env === 'development') {
  expressWinston.requestWhitelist.push('body');
  expressWinston.responseWhitelist.push('body');
  // app.use(expressWinston.logger({
  //   winstonInstance,
  //   meta: true, // optional: log meta data about request (defaults to true)
  //   msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
  //   colorStatus: true // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
  // }));
}
app.use(express.static(path.join(appRoot.path, 'dist')));

app.use('/api', routes);

innograph.init('/api/graphql', app, {post: postCtrl});

app.get('*', (req, res) => {
  res.sendFile(path.join(appRoot.path, 'dist/index.html'));
});

// if error is not an instanceOf APIError, convert it.
app.use((err, req, res, next) => {
  if (err instanceof expressValidation.ValidationError) {
    // validation error contains errors which is an array of error each containing message[]
    const unifiedErrorMessage = err.errors.map(error => error.messages.join('. ')).join(' and ');
    const error = new APIError(unifiedErrorMessage, err.status, true);
    return next(error);
github emyann / matron / packages / matron / src / create.ts View on Github external
const templateCacheDir = path.join(appRoot.path, 'cache/templates/src');
  if (isDev) {
    templatePath = path.join(
      appRoot.path,
      'node_modules/@matron/schematics/node_modules/@matron',
      getTemplateLocation(templateName)
    );
  } else {
    templatePath = path.join(appRoot.path, 'cache', getTemplateLocation(templateName));
    if (!p) {
      // ATM lookup matron own templates hosted in github
      // TODO: At some point, should come from npm@version package
      console.log(chalk`{hex('#00b6ff') downloading template ${templateName} from github}`);
      await githubClient().downloadTemplate(templateName, templateCacheDir);
    } else {
      const tempCacheDir = path.join(appRoot.path, 'temp_cache/templates/src');
      ensureDirectory(tempCacheDir);
      // TODO: p param should be computed from template id
      switch (p) {
        case 'now':
          {
            const nowCommmand = [p, 'init', templateName];
            logInstallTemplate(templateName, 'Now CLI');
            executeTask({ command: `npx`, args: nowCommmand }, { cwd: tempCacheDir });
          }
          break;
        case 'cra':
          {
            const craCommand = ['create-react-app', templateName, '--typescript'];
            logInstallTemplate(templateName, 'create-react-app');

            executeTask({ command: `npx`, args: craCommand }, { cwd: tempCacheDir });
github lbryio / lighthouse.js / server / utils / chainquery / index.js View on Github external
host: 'http://localhost:9200',

  log: {
    level : esLogLevel,
    type  : 'stream',
    stream: loggerStream,
  },
});

const queue = new ElasticQueue({elastic: eclient});
queue.on('drain', function () {
  console.log('elasticsearch queue is drained');
});

// Check that our syncState file exist.
fileExists(path.join(appRoot.path, 'syncState.json'), (err, exists) => {
  if (err) {
    throw err;
  }
  if (!exists) {
    fs.writeFileSync(path.join(appRoot.path, 'syncState.json'), '{}');
  }
});

let status = {info: 'startup successful'};

export async function claimSync () {
  try {
    let syncState = await getJSON(path.join(appRoot.path, 'syncState.json')); // get our persisted state
    if (!syncState.LastSyncTime) {
      syncState.LastSyncTime = '0001-01-01 00:00:00';
    }
github lbryio / lighthouse.js / server / utils / importer / index.js View on Github external
} else {
        let client = new bitcoin.Client({
          host   : 'localhost',
          port   : config.rpc_port,
          user   : config.username,
          pass   : config.password,
          timeout: 30000,
        });
        resolve(client);
      }
    });
  });
}

// Check that our cache file exist.
fileExists(path.join(appRoot.path, 'claimTrieCache.json'), (err, exists) => {
  if (err) { throw err };
  if (!exists) {
    fs.writeFileSync(path.join(appRoot.path, 'claimTrieCache.json'), '[]');
  }
});

let status = {};

export async function sync () {
  try {
    let client = await getClient();
    status.info = 'gettingClaimTrie';
    let claimTrie = await client.getClaimsInTrie().then(claimtrie => { return claimtrie }).catch(err => { throw err });
    let txList = [];
    let latestClaimTrie = [];
    for (let i in claimTrie) {
github lbryio / lighthouse.js / server / utils / chainquery / index.js View on Github external
}
        lastID = claim.id;
      }
      winston.log('info', '[Importer] Pushed ' + claims.length + ' claims to elastic search [LastID]' + lastID);
      finished = claims.length < BatchSize || (iteration * BatchSize + BatchSize >= MaxClaimsToProcessPerIteration);
      iteration++;
    }
    await deleteBlockedClaims();
    // If not finished, store last id to run again later where we left off, otherwise update last sync time.
    if (iteration * BatchSize + BatchSize >= MaxClaimsToProcessPerIteration) {
      syncState.LastID = lastID;
    } else {
      syncState.LastID = 0;
      syncState.LastSyncTime = syncState.StartSyncTime;
    }
    await saveJSON(path.join(appRoot.path, 'syncState.json'), syncState);
    status.info = 'upToDate';
    status.syncState = syncState;
    await sleep(600000);
    await claimSync();
  } catch (err) {
    await logErrorToSlack(err);
    status.err = err;
    await sleep(600000);
    await claimSync();
  }
}
github GMOD / jbrowse / postinstall.js View on Github external
var appPath = require("app-root-path").path;
var modPath = ""+require("shelljs").pwd();
var fs = require("fs-extra");

console.log(">>> postinstall");
console.log("appPath",appPath,"modPath",modPath);

copyMod('dojo','dojo');
copyMod('dijit','dijit');
copyMod('dojox','dojox');
copyMod('jszlib','jszlib');
copyMod('json-schema','json-schema');
copyMod('lazyload','lazyload');
copyMod('dgrid','dgrid');
copyMod('jDataView','jDataView');
copyMod('dojo-util','util');
copyMod('filesaver.js','FileSaver');
copyMod('dojo-dstore','dstore');


function copyMod(from,to) {
    var src = appPath+"/node_modules/"+from;
github lozinsky / typescript-babel-jest / source / index.js View on Github external
import appRoot from 'app-root-path';
import typescript from 'typescript';
import babelJest from 'babel-jest';

const tsConfig = require(`${appRoot.path}/tsconfig.json`);

export default {
    process(src, path) {
        const isTypeScript = path.endsWith('.ts') || path.endsWith('.tsx');
        const isJavaScript = path.endsWith('.js') || path.endsWith('.jsx');

        if (isTypeScript) {
            src = typescript.transpile(
                src,
                tsConfig.compilerOptions,
                path,
                [],
            );
        }

        if (isJavaScript || isTypeScript) {
github patternplate / patternplate / packages / boilerplate-server / source / library / boot / index.js View on Github external
this.name = options.name;
    this.subs = options.subs || [];

    this.runtime = merge(
      {},
      {
        mode: "server",
        prefix: "/",
        env:
          process.env.BOILERPLATESERVER_ENV ||
          process.env.BOILERPLATE_ENV ||
          process.env.NODE_ENV ||
          process.env.ENV ||
          "development",
        cwds: [],
        cwd: appRootPath.path
      },
      options
    );

    this.log = queuedLogger(this.name);
  }
github thenativeweb / flaschenpost / lib / Configuration.ts View on Github external
public constructor (
    debugModuleFilter: string[],
    formatter: Formatter,
    highestEnabledLogLevel: LogLevel,
    hostname: string,
    logEntryIdGenerator: LogEntryIdGenerator
  ) {
    this.application = readPackageJson(appRootPath.path);
    this.debugModuleFilter = debugModuleFilter;
    this.formatter = formatter;
    this.highestEnabledLogLevel = highestEnabledLogLevel;
    this.hostname = hostname;
    this.logEntryIdGenerator = logEntryIdGenerator;
  }
github linnovate / mean / server / config / express.js View on Github external
app.get('*', (req, res) => {
  res.sendFile(path.join(appRoot.path, 'dist/index.html'));
});

app-root-path

Determine an app's root path from anywhere inside the app

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis