How to use the config.port 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 sirodoht / aspen / back / app.js View on Github external
.catch((err) => {
      console.log('Passport error:', err);
      done(err);
    });
}
));

app.use(cors());

app.use(router.routes());

app.use(static(path.join(__dirname, '../front/static')));

app.use(favicon(path.join(__dirname, '../front/static/favicon.ico')));

const port = process.env.PORT || config.port;

// models.sequelize.sync({ force: true })
models.sequelize.sync()
  .then(() => {
    app.listen(port);
    app.on('error', (error) => {
      console.error('App error:', error);
      process.exit(1);
    });
    console.log(`Server running on port ${port}`);
  });
github opencollective / opencollective-api / server / index.js View on Github external
import logger from './lib/logger';

const app = express();

expressLib(app);

/**
 * Routes.
 */

routes(app);

/**
 * Start server
 */
const server = app.listen(config.port, () => {
  const host = os.hostname();
  logger.info(
    'Open Collective API listening at http://%s:%s in %s environment.\n',
    host,
    server.address().port,
    config.env,
  );
  if (config.maildev.server) {
    const maildev = require('./maildev'); // eslint-disable-line @typescript-eslint/no-var-requires
    maildev.listen();
  }
});

server.timeout = 25000; // sets timeout to 25 seconds

/**
github brave / sync / server / index.js View on Github external
origin: '*'
}))

const UsersRouter = require('./users.js')
app.use('/', UsersRouter)

// Exception handling. The Sentry error handler must be before any other error middleware.
if (Config.sentryUrl) {
  app.use(raven.middleware.express.errorHandler(Config.sentryUrl))
  app.use(ravenOnError)
}

app.listen(Config.port)

Util.logger.info(`NODE_ENV: ${Config.util.getEnv('NODE_ENV')}`)
Util.logger.info(`sync server up on localhost:${Config.port}`)
github paralect / stack / koa-api-starter / src / app.js View on Github external
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

const { logger } = global;
const config = require('config');
const Koa = require('koa');

process.on('unhandledRejection', (reason, p) => {
  logger.log('Possibly Unhandled Rejection at: Promise ', p, ' reason: ', reason);
  // application specific logging here
});

const app = new Koa();
require('./config/koa')(app);

app.listen(config.port, () => {
  logger.warn(`Api server listening on ${config.port}, in ${process.env.NODE_ENV} mode`);
});

module.exports = app;
github miguelcobain / hapi-boilerplate / server.js View on Github external
var Hapi = require('hapi');

var path = require('path');
var settings = require('config');

var routes = require('./routes');
var plugins = require('./plugins');
var models = require('./models');

const internals = {
  templatePath: '.'
};

const server = new Hapi.Server({
  host:settings.host,
  port: settings.port
});

// server.connection({port:settings.port, host:settings.host});

// Export the server to be required elsewhere.

var initDb = function(cb){
  var sequelize = models.sequelize;

  //Test if we're in a sqlite memory database. we may need to run migrations.
  if(sequelize.getDialect()==='sqlite' &&
      (!sequelize.options.storage || sequelize.options.storage === ':memory:')){
    sequelize.getMigrator({
      path: process.cwd() + '/migrations',
    }).migrate().success(function(){
      // The migrations have been executed!
github gregtillbrook / react-head-start / src / server / index.js View on Github external
//static files
app.use(favicon(path.join(__dirname, '../static/favicon.ico')));
app.use('/', express.static(path.join(__dirname, '../static')));
//bundles are mapped like this so dev and prod builds both work (as dev uses src/static while prod uses dist/static)
app.use('/bundles', express.static(path.join(__dirname, '../../dist/bundles')));

//API
app.get('/api/users', getUsers);

//all page rendering
//Note: handles page routing and 404/500 error pages where necessary
app.get('*', renderPageRoute);


const server = app.listen(config.port, function () {
  banner();
  log.info(`Server started on port ${server.address().port} in ${app.get('env')} mode`);
  //Its very useful to output init config to console at startup but we deliberately dont dump it to
  //log files incase it contains sensetive info (like keys for services etc)
  console.log(config);//eslint-disable-line no-console
  //'ready' is a hook used by the e2e (integration) tests (see node-while)
  server.emit('ready');
});

//export server instance so we can hook into it in e2e tests etc
export default server;
github luoyjx / gaoqi-blog / bin / run.js View on Github external
'use strict'

require('../models')
const config = require('config')
const app = require('../app')

app.listen(config.port, () => {
  console.log(`Server listening on port => ${config.port} at ${new Date()}`)
})
github ceoworks / tutorial1-api-koa / app.js View on Github external
.then(() => {
	app.listen(config.port, () => {
		console.info(`Listening to http://localhost:${config.port}`);
	});
})
.catch((err) => {
github koopjs / koop-provider-marklogic / src / koop / server.js View on Github external
cert: fs.readFileSync(config.ssl.cert)
  };

  https.createServer(
    options,
    app.use('/', koop.server)
  ).listen(config.ssl.port || 443);

  log.info("Koop MarkLogic Provider listening for HTTPS on ${config.ssl.port}");
}

koop.server.listen(config.port || 80);

const message = `

Koop MarkLogic Provider listening for HTTP on ${config.port}

Press control + c to exit
`
log.info(message)