Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2986 from hritvi/semicolons
Browse files Browse the repository at this point in the history
#2986
r=philbooth
  • Loading branch information
philbooth authored Mar 26, 2019
2 parents 8a6490e + 4761ad0 commit c74df5a
Show file tree
Hide file tree
Showing 263 changed files with 24,530 additions and 24,518 deletions.
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
plugins:
- fxa

extends: plugin:fxa/server

rules:
handle-callback-err: 0
no-var: 2
prefer-arrow-callback: 2
prefer-const: 2
prefer-template: 2
strict: 2
semi: 0
semi: [2, "always"]
indent: [0, 2]

parserOptions:
Expand Down
14 changes: 7 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict'
'use strict';

module.exports = function (grunt) {
require('load-grunt-tasks')(grunt)
require('load-grunt-tasks')(grunt);

grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
})
});

grunt.loadTasks('grunttasks')
grunt.loadTasks('grunttasks');

grunt.registerTask('default', ['eslint', 'copyright'])
grunt.registerTask('mailer', ['templates', 'copy:strings', 'l10n-extract'])
}
grunt.registerTask('default', ['eslint', 'copyright']);
grunt.registerTask('mailer', ['templates', 'copy:strings', 'l10n-extract']);
};
38 changes: 19 additions & 19 deletions bin/email_notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,45 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict'
'use strict';

// This MUST be the first require in the program.
// Only `require()` the newrelic module if explicity enabled.
// If required, modules will be instrumented.
require('../lib/newrelic')()
require('../lib/newrelic')();

const config = require('../config').getProperties()
const log = require('../lib/log')(config.log.level, 'fxa-email-bouncer')
const error = require('../lib/error')
const Token = require('../lib/tokens')(log, config)
const SQSReceiver = require('../lib/sqs')(log)
const bounces = require('../lib/email/bounces')(log, error)
const delivery = require('../lib/email/delivery')(log)
const notifications = require('../lib/email/notifications')(log, error)
const config = require('../config').getProperties();
const log = require('../lib/log')(config.log.level, 'fxa-email-bouncer');
const error = require('../lib/error');
const Token = require('../lib/tokens')(log, config);
const SQSReceiver = require('../lib/sqs')(log);
const bounces = require('../lib/email/bounces')(log, error);
const delivery = require('../lib/email/delivery')(log);
const notifications = require('../lib/email/notifications')(log, error);

const DB = require('../lib/db')(
config,
log,
Token
)
);

const {
bounceQueueUrl,
complaintQueueUrl,
deliveryQueueUrl,
notificationQueueUrl,
region
} = config.emailNotifications
} = config.emailNotifications;

const bounceQueue = new SQSReceiver(region, [ bounceQueueUrl, complaintQueueUrl ])
const deliveryQueue = new SQSReceiver(region, [ deliveryQueueUrl ])
const notificationQueue = new SQSReceiver(region, [ notificationQueueUrl ])
const bounceQueue = new SQSReceiver(region, [ bounceQueueUrl, complaintQueueUrl ]);
const deliveryQueue = new SQSReceiver(region, [ deliveryQueueUrl ]);
const notificationQueue = new SQSReceiver(region, [ notificationQueueUrl ]);

DB.connect(config[config.db.backend])
.then(db => {
// bounces and delivery are now deprecated, we'll delete them
// as soon as we're 100% confident in fxa-email-service
bounces(bounceQueue, db)
delivery(deliveryQueue)
notifications(notificationQueue, db)
})
bounces(bounceQueue, db);
delivery(deliveryQueue);
notifications(notificationQueue, db);
});
148 changes: 74 additions & 74 deletions bin/key_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict'
'use strict';

// This MUST be the first require in the program.
// Only `require()` the newrelic module if explicity enabled.
// If required, modules will be instrumented.
require('../lib/newrelic')()
require('../lib/newrelic')();

var jwtool = require('fxa-jwtool')
var P = require('../lib/promise')
const jwtool = require('fxa-jwtool');
const P = require('../lib/promise');


function run(config) {
var log = require('../lib/log')(config.log)
var getGeoData = require('../lib/geodb')(log)
const log = require('../lib/log')(config.log);
const getGeoData = require('../lib/geodb')(log);
// Force the geo to load and run at startup, not waiting for it to run on
// some route later.
const knownIp = '63.245.221.32' // Mozilla MTV
const location = getGeoData(knownIp)
log.info({ op: 'geodb.check', result: location })
const knownIp = '63.245.221.32'; // Mozilla MTV
const location = getGeoData(knownIp);
log.info({ op: 'geodb.check', result: location });

// RegExp instances serialise to empty objects, display regex strings instead.
const stringifiedConfig =
JSON.stringify(config, (k, v) =>
v && v.constructor === RegExp ? v.toString() : v
)
);

if (config.env !== 'prod') {
log.info(stringifiedConfig, 'starting config')
log.info(stringifiedConfig, 'starting config');
}

var error = require('../lib/error')
var Token = require('../lib/tokens')(log, config)
var Password = require('../lib/crypto/password')(log, config)
var UnblockCode = require('../lib/crypto/random').base32(config.signinUnblock.codeLength)
const error = require('../lib/error');
const Token = require('../lib/tokens')(log, config);
const Password = require('../lib/crypto/password')(log, config);
const UnblockCode = require('../lib/crypto/random').base32(config.signinUnblock.codeLength);

var signer = require('../lib/signer')(config.secretKeyFile, config.domain)
var serverPublicKeys = {
const signer = require('../lib/signer')(config.secretKeyFile, config.domain);
const serverPublicKeys = {
primary: jwtool.JWK.fromFile(
config.publicKeyFile,
{
Expand All @@ -57,45 +57,45 @@ function run(config) {
}
)
: null
}
};

var Customs = require('../lib/customs')(log, error)
const Customs = require('../lib/customs')(log, error);

const Server = require('../lib/server')
let server = null
let senders = null
let statsInterval = null
let database = null
let customs = null
let oauthdb = null
const Server = require('../lib/server');
let server = null;
let senders = null;
let statsInterval = null;
let database = null;
let customs = null;
let oauthdb = null;

function logStatInfo() {
log.stat(server.stat())
log.stat(Password.stat())
log.stat(server.stat());
log.stat(Password.stat());
}

var DB = require('../lib/db')(
const DB = require('../lib/db')(
config,
log,
Token,
UnblockCode
)
);

return P.all([
DB.connect(config[config.db.backend]),
require('../lib/senders/translator')(config.i18n.supportedLanguages, config.i18n.defaultLanguage)
])
.spread(
(db, translator) => {
database = db
const bounces = require('../lib/bounces')(config, db)
oauthdb = require('../lib/oauthdb')(log, config)
database = db;
const bounces = require('../lib/bounces')(config, db);
oauthdb = require('../lib/oauthdb')(log, config);

return require('../lib/senders')(log, config, error, bounces, translator, oauthdb)
.then(result => {
senders = result
customs = new Customs(config.customsUrl)
var routes = require('../lib/routes')(
senders = result;
customs = new Customs(config.customsUrl);
const routes = require('../lib/routes')(
log,
serverPublicKeys,
signer,
Expand All @@ -106,89 +106,89 @@ function run(config) {
Password,
config,
customs
)
);

statsInterval = setInterval(logStatInfo, 15000)
statsInterval = setInterval(logStatInfo, 15000);

async function init() {
server = await Server.create(log, error, config, routes, db, oauthdb, translator)
server = await Server.create(log, error, config, routes, db, oauthdb, translator);
try {
await server.start()
log.info({op: 'server.start.1', msg: 'running on ' + server.info.uri})
await server.start();
log.info({op: 'server.start.1', msg: `running on ${ server.info.uri}`});
} catch (err) {
log.error(
{
op: 'server.start.1', msg: 'failed startup with error',
err: {message: err.message}
}
)
);
}
}

init()
init();

})
});
},
function (err) {
log.error({ op: 'DB.connect', err: { message: err.message } })
process.exit(1)
(err) => {
log.error({ op: 'DB.connect', err: { message: err.message } });
process.exit(1);
}
)
.then(() => {
return {
log: log,
close() {
return new P((resolve) => {
log.info({ op: 'shutdown' })
clearInterval(statsInterval)
log.info({ op: 'shutdown' });
clearInterval(statsInterval);
server.stop().then(() => {
customs.close()
oauthdb.close()
customs.close();
oauthdb.close();
try {
senders.email.stop()
senders.email.stop();
} catch (e) {
// XXX: simplesmtp module may quit early and set socket to `false`, stopping it may fail
log.warn({op: 'shutdown', message: 'Mailer client already disconnected'})
log.warn({op: 'shutdown', message: 'Mailer client already disconnected'});
}
database.close()
resolve()
})
})
database.close();
resolve();
});
});
}
}
})
};
});
}

function main() {
const config = require('../config').getProperties()
const config = require('../config').getProperties();
run(config).then(server => {
process.on('uncaughtException', (err) => {
server.log.fatal(err)
process.exit(8)
})
server.log.fatal(err);
process.exit(8);
});
process.on('unhandledRejection', (reason, promise) => {
server.log.fatal({
op: 'promise.unhandledRejection',
error: reason
})
})
process.on('SIGINT', shutdown)
server.log.on('error', shutdown)
});
});
process.on('SIGINT', shutdown);
server.log.on('error', shutdown);

function shutdown() {
server.close().then(() => {
process.exit() //XXX: because of openid dep ಠ_ಠ
})
process.exit(); //XXX: because of openid dep ಠ_ಠ
});
}
})
.catch((err) => {
console.error(err) // eslint-disable-line no-console
process.exit(8)
})
console.error(err); // eslint-disable-line no-console
process.exit(8);
});
}

if (require.main === module) {
main()
main();
} else {
module.exports = run
module.exports = run;
}
Loading

0 comments on commit c74df5a

Please sign in to comment.